4
4
5
5
namespace App \Tests \Functional \Controller \Website ;
6
6
7
+ use App \Tests \Functional \Traits \EventRegistrationTrait ;
7
8
use App \Tests \Functional \Traits \EventTrait ;
8
9
use Sulu \Bundle \TestBundle \Testing \SuluTestCase ;
9
10
use Symfony \Bundle \FrameworkBundle \KernelBrowser ;
10
11
use Symfony \Component \HttpFoundation \Response ;
11
12
12
13
class EventWebsiteControllerTest extends SuluTestCase
13
14
{
15
+ use EventRegistrationTrait;
14
16
use EventTrait;
15
17
16
18
private KernelBrowser $ client ;
@@ -34,4 +36,37 @@ public function testIndexAction(): void
34
36
35
37
$ this ->assertStringContainsString ('Sulu is awesome ' , $ crawler ->filter ('h1 ' )->html ());
36
38
}
39
+
40
+ public function testRegister (): void
41
+ {
42
+ $ event = $ this ->createEvent ('Sulu is awesome ' , 'en ' );
43
+
44
+ $ crawler = $ this ->client ->request ('GET ' , '/en/event/ ' . $ event ->getId ());
45
+
46
+ $ response = $ this ->client ->getResponse ();
47
+ $ this ->assertInstanceOf (Response::class, $ response );
48
+ $ this ->assertHttpStatusCode (200 , $ response );
49
+
50
+ $ form = $ crawler ->filter ('#event_registration_submit ' )->form (
51
+ [
52
+ 'event_registration[firstName] ' => 'Max ' ,
53
+ 'event_registration[lastName] ' => 'Mustermann ' ,
54
+ 'event_registration[email] ' =>
'[email protected] ' ,
55
+ 'event_registration[message] ' => 'I would love to see this. ' ,
56
+ ],
57
+ );
58
+
59
+ $ this ->client ->submit ($ form );
60
+ $ crawler = $ this ->client ->followRedirect ();
61
+
62
+ $ this ->assertStringContainsString ('Thanks for your registration ' , $ crawler ->filter ('.success ' )->html ());
63
+
64
+ $ registrations = $ this ->findEventRegistrations ($ event );
65
+
66
+ $ this ->assertCount (1 , $ registrations );
67
+ $ this ->assertSame ('Max ' , $ registrations [0 ]->getFirstName ());
68
+ $ this ->assertSame ('Mustermann ' , $ registrations [0 ]->getLastName ());
69
+ $ this ->
assertSame (
'[email protected] ' ,
$ registrations[
0 ]->
getEmail ());
70
+ $ this ->assertSame ('I would love to see this. ' , $ registrations [0 ]->getMessage ());
71
+ }
37
72
}
0 commit comments