1 | <?php |
||
25 | class SharedSessionStrategy implements ISessionStrategy |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * Original session strategy. |
||
30 | * |
||
31 | * @var ISessionStrategy |
||
32 | */ |
||
33 | private $_originalStrategy; |
||
34 | |||
35 | /** |
||
36 | * Reference to created session. |
||
37 | * |
||
38 | * @var Session |
||
39 | */ |
||
40 | private $_session; |
||
41 | |||
42 | /** |
||
43 | * Remembers if last test failed. |
||
44 | * |
||
45 | * @var boolean |
||
46 | */ |
||
47 | private $_lastTestFailed = false; |
||
48 | |||
49 | /** |
||
50 | * Remembers original session strategy upon shared strategy creation. |
||
51 | * |
||
52 | * @param ISessionStrategy $original_strategy Original session strategy. |
||
53 | */ |
||
54 | 7 | public function __construct(ISessionStrategy $original_strategy) |
|
58 | |||
59 | /** |
||
60 | * Returns an array of event names this subscriber wants to listen to. |
||
61 | * |
||
62 | * @return array The event names to listen to |
||
63 | */ |
||
64 | 7 | public static function getSubscribedEvents() |
|
71 | |||
72 | /** |
||
73 | * Sets event dispatcher. |
||
74 | * |
||
75 | * @param EventDispatcherInterface $event_dispatcher Event dispatcher. |
||
76 | * |
||
77 | * @return void |
||
78 | */ |
||
79 | 7 | public function setEventDispatcher(EventDispatcherInterface $event_dispatcher) |
|
83 | |||
84 | /** |
||
85 | * Returns Mink session with given browser configuration. |
||
86 | * |
||
87 | * @param BrowserConfiguration $browser Browser configuration for a session. |
||
88 | * |
||
89 | * @return Session |
||
90 | */ |
||
91 | 5 | public function session(BrowserConfiguration $browser) |
|
106 | |||
107 | /** |
||
108 | * Stops session. |
||
109 | * |
||
110 | * @return void |
||
111 | */ |
||
112 | 2 | protected function stopSession() |
|
121 | |||
122 | /** |
||
123 | * Switches to window, that was created upon session creation. |
||
124 | * |
||
125 | * @return void |
||
126 | */ |
||
127 | 4 | private function _switchToMainWindow() |
|
131 | |||
132 | /** |
||
133 | * Called, when test fails. |
||
134 | * |
||
135 | * @param TestFailedEvent $event Test failed event. |
||
136 | * |
||
137 | * @return void |
||
138 | */ |
||
139 | 4 | public function onTestFailed(TestFailedEvent $event) |
|
149 | |||
150 | /** |
||
151 | * Called, when test case ends. |
||
152 | * |
||
153 | * @param TestEvent $event Test event. |
||
154 | * |
||
155 | * @return void |
||
156 | */ |
||
157 | 1 | public function onTestSuiteEnd(TestEvent $event) |
|
169 | |||
170 | /** |
||
171 | * Checks, that event can be handled by this class. |
||
172 | * |
||
173 | * @param TestEvent $event Test event. |
||
174 | * |
||
175 | * @return boolean |
||
176 | */ |
||
177 | 1 | private function _isEventForMe(TestEvent $event) |
|
181 | } |
||
182 |