Skip to content

Commit

Permalink
feat: added UT for RestTraitTest
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwarajanand committed Jan 3, 2024
1 parent 4de3589 commit 039c115
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Core/tests/Unit/RestTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Http\Message\RequestInterface;
use UnexpectedValueException;

/**
* @group core
Expand Down Expand Up @@ -172,6 +173,21 @@ public function testGetApiEndpoint($input = null, $expected = null)
);
}

/**
* @dataProvider universeDomains
*/
public function testGetApiEndpointFromUniverseDomain($config, $template, $expected = null, $expectException = false)
{
if ($expectException) {
$this->expectException(UnexpectedValueException::class);
}

$this->assertEquals(
$expected,
TestHelpers::impl(RestTrait::class)->call('getApiEndpoint', [null, $config, $template])
);
}

public function testAppendsPrettyPrintParameter()
{
$requestBuilder = $this->prophesize(RequestBuilder::class);
Expand All @@ -196,6 +212,18 @@ public function testAppendsPrettyPrintParameter()
$this->assertEquals('prettyPrint=false', $this->implementation->send('foo', 'bar', []));
}

public function universeDomains()
{
return [
[[], '', null, true],
[[], null, null, true],
[['universeDomain' => null], 'ab.cd', null, true],
[['universeDomain' => ''], 'ab.cd', null, true],
[['universeDomain' => 'defg'], 'ab.cd', 'ab.cd/'],
[['universeDomain' => 'defg'], 'ab.UNIVERSE_DOMAIN.cd', 'ab.defg.cd/'],
];
}

public function endpoints()
{
return [
Expand Down

0 comments on commit 039c115

Please sign in to comment.