Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Oct 10, 2024
1 parent c286eed commit cfeff21
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tests/Unit/ResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
final class ResultTest extends TestCase
{
/** @dataProvider isClientSafe */
public function testThrowErrors(bool $isClientSafe): void
public function testAssertErrorFree(bool $isClientSafe): void
{
$endpoint = \Mockery::mock(EndpointConfig::class);
$endpoint->expects('errorsAreClientSafe')
Expand Down Expand Up @@ -56,14 +56,22 @@ public function testErrorFree(bool $isClientSafe): void
->andReturn($isClientSafe);
Configuration::setEndpointFor(MyScalarQueryResult::class, $endpoint);

$result = new MyScalarQueryResult();
$result->data = MyScalarQuery::make(
$data = MyScalarQuery::make(
/* scalarWithArg: */
null,
);
$extensions = (object) [
'foo' => 'bar',
];

$result = new MyScalarQueryResult();
$result->data = $data;
$result->extensions = $extensions;

// No errors
$result->errorFree();
$errorFreeResult = $result->errorFree();
self::assertSame($data, $errorFreeResult->data);
self::assertSame($extensions, $errorFreeResult->extensions);

$result->errors = [new Error('foo')];

Expand All @@ -78,7 +86,7 @@ public function testErrorFree(bool $isClientSafe): void
self::assertSame($isClientSafe, $exception->isClientSafe());
}

public function testWithErrors(): void
public function testFromStdClass(): void
{
$endpoint = \Mockery::mock(EndpointConfig::class)->makePartial();
Configuration::setEndpointFor(MyScalarQueryResult::class, $endpoint);
Expand Down

0 comments on commit cfeff21

Please sign in to comment.