|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace App\Tests\Functional\Controller\Admin; |
| 6 | + |
| 7 | +use App\Tests\Functional\Traits\EventRegistrationTrait; |
| 8 | +use App\Tests\Functional\Traits\EventTrait; |
| 9 | +use Sulu\Bundle\TestBundle\Testing\SuluTestCase; |
| 10 | +use Symfony\Bundle\FrameworkBundle\KernelBrowser; |
| 11 | +use Symfony\Component\HttpFoundation\Response; |
| 12 | + |
| 13 | +class EventRegistrationControllerTest extends SuluTestCase |
| 14 | +{ |
| 15 | + use EventRegistrationTrait; |
| 16 | + use EventTrait; |
| 17 | + |
| 18 | + /** |
| 19 | + * @var KernelBrowser |
| 20 | + */ |
| 21 | + private $client; |
| 22 | + |
| 23 | + protected function setUp(): void |
| 24 | + { |
| 25 | + $this->client = $this->createAuthenticatedClient(); |
| 26 | + $this->purgeDatabase(); |
| 27 | + } |
| 28 | + |
| 29 | + public function testCGet(): void |
| 30 | + { |
| 31 | + $event1 = $this->createEvent('Sulu is awesome', 'de'); |
| 32 | + $event2 = $this->createEvent('Symfony live is awesome', 'de'); |
| 33 | + |
| 34 | + $registration1 = $this->createEventRegistration($event1, 'Max', 'Mustermann'); |
| 35 | + $registration2 = $this->createEventRegistration($event2, 'Mira', 'Musterfrau'); |
| 36 | + |
| 37 | + $this->client->request('GET', '/admin/api/events/' . $event1->getId() . '/registrations'); |
| 38 | + |
| 39 | + $response = $this->client->getResponse(); |
| 40 | + $this->assertInstanceOf(Response::class, $response); |
| 41 | + $result = json_decode($response->getContent() ?: '', true); |
| 42 | + $this->assertHttpStatusCode(200, $response); |
| 43 | + |
| 44 | + $this->assertSame(1, $result['total']); |
| 45 | + $this->assertCount(1, $result['_embedded']['event_registrations']); |
| 46 | + $items = $result['_embedded']['event_registrations']; |
| 47 | + |
| 48 | + $this->assertSame($registration1->getId(), $items[0]['id']); |
| 49 | + |
| 50 | + $this->assertSame($registration1->getFirstName(), $items[0]['firstName']); |
| 51 | + $this->assertSame($registration1->getLastName(), $items[0]['lastName']); |
| 52 | + $this->assertArrayHasKey('email', $items[0]); |
| 53 | + } |
| 54 | +} |
0 commit comments