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 ;
12
13
class EventWebsiteControllerTest extends SuluTestCase
13
14
{
14
15
use EventTrait;
16
+ use EventRegistrationTrait;
15
17
16
18
/**
17
19
* @var KernelBrowser
@@ -37,4 +39,37 @@ public function testIndexAction(): void
37
39
38
40
$ this ->assertStringContainsString ('Sulu is awesome ' , $ crawler ->filter ('h1 ' )->html ());
39
41
}
42
+
43
+ public function testRegister (): void
44
+ {
45
+ $ event = $ this ->createEvent ('Sulu is awesome ' , 'en ' );
46
+
47
+ $ crawler = $ this ->client ->request ('GET ' , '/en/event/ ' . $ event ->getId ());
48
+
49
+ $ response = $ this ->client ->getResponse ();
50
+ $ this ->assertInstanceOf (Response::class, $ response );
51
+ $ this ->assertHttpStatusCode (200 , $ response );
52
+
53
+ $ form = $ crawler ->filter ('#event_registration_submit ' )->form (
54
+ [
55
+ 'event_registration[firstName] ' => 'Max ' ,
56
+ 'event_registration[lastName] ' => 'Mustermann ' ,
57
+ 'event_registration[email] ' =>
'[email protected] ' ,
58
+ 'event_registration[message] ' => 'I would love to see this. ' ,
59
+ ]
60
+ );
61
+
62
+ $ this ->client ->submit ($ form );
63
+ $ crawler = $ this ->client ->followRedirect ();
64
+
65
+ $ this ->assertStringContainsString ('Thanks for your registration ' , $ crawler ->filter ('.success ' )->html ());
66
+
67
+ $ registrations = $ this ->findEventRegistrations ($ event );
68
+
69
+ $ this ->assertCount (1 , $ registrations );
70
+ $ this ->assertSame ('Max ' , $ registrations [0 ]->getFirstName ());
71
+ $ this ->assertSame ('Mustermann ' , $ registrations [0 ]->getLastName ());
72
+ $ this ->
assertSame (
'[email protected] ' ,
$ registrations[
0 ]->
getEmail ());
73
+ $ this ->assertSame ('I would love to see this. ' , $ registrations [0 ]->getMessage ());
74
+ }
40
75
}
0 commit comments