5
5
namespace App \Tests \Functional \Pages ;
6
6
7
7
use App \Tests \Functional \Traits \EventTrait ;
8
+ use App \Tests \Functional \Traits \LocationTrait ;
8
9
use App \Tests \Functional \Traits \PageTrait ;
9
10
use Sulu \Bundle \TestBundle \Testing \SuluTestCase ;
10
11
use Sulu \Component \DocumentManager \DocumentManagerInterface ;
15
16
class EventOverviewTest extends SuluTestCase
16
17
{
17
18
use EventTrait;
19
+ use LocationTrait;
18
20
use PageTrait;
19
21
20
22
/**
@@ -26,6 +28,7 @@ public function setUp(): void
26
28
{
27
29
$ this ->client = $ this ->createWebsiteClient ();
28
30
$ this ->initPhpcr ();
31
+ $ this ->purgeDatabase ();
29
32
}
30
33
31
34
public function testEventOverview (): void
@@ -58,6 +61,56 @@ public function testEventOverview(): void
58
61
$ this ->assertStringContainsString ($ event2 ->getTitle () ?: '' , $ content );
59
62
}
60
63
64
+ public function testEventOverviewWithLocations (): void
65
+ {
66
+ $ location1 = $ this ->createLocation ('Dornbirn ' );
67
+ $ location2 = $ this ->createLocation ('Berlin ' );
68
+
69
+ $ event1 = $ this ->createEvent ('Sulu is awesome ' , 'en ' );
70
+ $ event1 ->setLocation ($ location1 );
71
+ $ this ->enableEvent ($ event1 );
72
+ $ event2 = $ this ->createEvent ('Symfony Live is awesome ' , 'en ' );
73
+ $ event2 ->setLocation ($ location2 );
74
+ $ this ->enableEvent ($ event2 );
75
+ $ event3 = $ this ->createEvent ('Disabled ' , 'en ' );
76
+
77
+ $ this ->createPage (
78
+ 'event_overview ' ,
79
+ 'example ' ,
80
+ [
81
+ 'title ' => 'Symfony Live ' ,
82
+ 'url ' => '/events ' ,
83
+ 'published ' => true ,
84
+ ]
85
+ );
86
+
87
+ $ crawler = $ this ->client ->request (Request::METHOD_GET , '/en/events ' );
88
+
89
+ $ response = $ this ->client ->getResponse ();
90
+ $ this ->assertInstanceOf (Response::class, $ response );
91
+ $ this ->assertSame (Response::HTTP_OK , $ response ->getStatusCode ());
92
+ $ this ->assertCount (2 , $ crawler ->filter ('.event-title ' ));
93
+ $ this ->assertNotNull ($ content = $ crawler ->filter ('.event-title ' )->eq (0 )->html ());
94
+ $ this ->assertStringContainsString ($ event1 ->getTitle () ?: '' , $ content );
95
+ $ this ->assertNotNull ($ content = $ crawler ->filter ('.event-title ' )->eq (1 )->html ());
96
+ $ this ->assertStringContainsString ($ event2 ->getTitle () ?: '' , $ content );
97
+
98
+ $ form = $ crawler ->filter ('#location_submit ' )->form (
99
+ [
100
+ 'location ' => $ location1 ->getId (),
101
+ ]
102
+ );
103
+
104
+ $ crawler = $ this ->client ->submit ($ form );
105
+
106
+ $ response = $ this ->client ->getResponse ();
107
+ $ this ->assertInstanceOf (Response::class, $ response );
108
+ $ this ->assertSame (Response::HTTP_OK , $ response ->getStatusCode ());
109
+ $ this ->assertCount (1 , $ crawler ->filter ('.event-title ' ));
110
+ $ this ->assertNotNull ($ content = $ crawler ->filter ('.event-title ' )->eq (0 )->html ());
111
+ $ this ->assertStringContainsString ($ event1 ->getTitle () ?: '' , $ content );
112
+ }
113
+
61
114
protected function getDocumentManager (): DocumentManagerInterface
62
115
{
63
116
return $ this ->getContainer ()->get ('sulu_document_manager.document_manager ' );
0 commit comments