Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Dec 20, 2024
1 parent 632b748 commit 8597744
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
15 changes: 8 additions & 7 deletions Core/tests/Unit/GrpcRequestWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ public function testExceptionMetadata()
new FieldViolation([
'field' => 'foo',
'description' => 'bar',
'reason' => 'REASON'
])
]
]);
Expand Down Expand Up @@ -325,13 +324,15 @@ public function testExceptionMetadata()

$this->assertFalse(true, 'Exception not thrown!');
} catch (ServiceException $ex) {
$this->assertEquals(
json_decode($metadata->serializeToJsonString(), true),
$ex->getMetadata()[0]
);

$metadata = $ex->getMetadata();
// Assert only whitelisted types are included.
$this->assertCount(1, $ex->getMetadata());
$this->assertCount(1, $metadata);

$this->assertArrayHasKey('fieldViolations', $metadata[0]);
$this->assertCount(1, $metadata[0]['fieldViolations']);
$fieldViolation = $metadata[0]['fieldViolations'][0];
$this->assertEquals('foo', $fieldViolation['field']);
$this->assertEquals('bar', $fieldViolation['description']);
}
}
}
17 changes: 9 additions & 8 deletions Core/tests/Unit/RequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function responseProvider()
{
$expectedMessage = ['successful' => 'request'];
$message = new Http();

$pagedMessage = $this->prophesize(PagedListResponse::class);
$page = $this->prophesize(Page::class);
$page->getResponseObject()->willReturn($message);
Expand Down Expand Up @@ -292,7 +292,6 @@ public function testExceptionMetadata()
new FieldViolation([
'field' => 'foo',
'description' => 'bar',
'reason' => 'REASON',
])
]
]);
Expand Down Expand Up @@ -332,13 +331,15 @@ public function testExceptionMetadata()

$this->assertFalse(true, 'Exception not thrown!');
} catch (ServiceException $ex) {
$this->assertEquals(
json_decode($metadata->serializeToJsonString(), true),
$ex->getMetadata()[0]
);

$metadata = $ex->getMetadata();
// Assert only whitelisted types are included.
$this->assertCount(1, $ex->getMetadata());
$this->assertCount(1, $metadata);

$this->assertArrayHasKey('fieldViolations', $metadata[0]);
$this->assertCount(1, $metadata[0]['fieldViolations']);
$fieldViolation = $metadata[0]['fieldViolations'][0];
$this->assertEquals('foo', $fieldViolation['field']);
$this->assertEquals('bar', $fieldViolation['description']);
}
}
}

0 comments on commit 8597744

Please sign in to comment.