Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ActiveTest extends TestCase
- {
- use ApiTesterTrait;
- private const ACTION_URI = '/events/active';
- public function setUp(): void
- {
- $this->setUpClient();
- }
- public function testReturnExpectedEvents(): void
- {
- $mock = json_decode(file_get_contents(__DIR__ . '/mocks/active.json'), true);
- $response = $this->client->get(self::ACTION_URI, [
- 'query' => [
- 'idClient' => 1
- ],
- 'headers' => [
- 'Authorization' => $this->authorization
- ]
- ]);
- $body = json_decode($response->getBody(), true);
- $props = ['idEvent', 'sellingDateStart', 'sellingDateEnd', 'reservationExpirationDays', 'reservationExpirationDate', 'reservationDelay', 'eventObject', 'image', 'clientPoolsAllowed', 'isClientAllowed'];
- foreach ($body as $index => $event) {
- foreach ($props as $prop) {
- $events[$index][$prop] = $event[$prop];
- }
- }
- $this->assertEquals($mock, $events ?? []);
- }
- public function testReturnExpectedEventsOnNonEmptyServiceType(): void
- {
- $mock = json_decode(file_get_contents(__DIR__ . '/mocks/active.json'), true);
- $response = $this->client->get(self::ACTION_URI, [
- 'query' => [
- 'idClient' => 1,
- 'serviceType' => 'dms'
- ],
- 'headers' => [
- 'Authorization' => $this->authorization
- ]
- ]);
- $body = json_decode($response->getBody(), true);
- $props = ['idEvent', 'sellingDateStart', 'sellingDateEnd', 'reservationExpirationDays', 'reservationExpirationDate', 'reservationDelay', 'eventObject', 'image', 'clientPoolsAllowed', 'isClientAllowed'];
- foreach ($body as $index => $event) {
- foreach ($props as $prop) {
- $events[$index][$prop] = $event[$prop];
- }
- }
- $this->assertEquals($mock, $events ?? []);
- }
- public function testReturnBadRequestOnNonExistentClient(): void
- {
- $response = $this->client->get(self::ACTION_URI, [
- 'query' => [
- 'idClient' => 9999
- ],
- 'headers' => [
- 'Authorization' => $this->authorization
- ],
- 'http_errors' => false
- ]);
- $this->assertEquals(400, $response->getStatusCode());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement