1 | <?php |
||
28 | class SharedSessionStrategy implements ISessionStrategy |
||
29 | { |
||
30 | |||
31 | /** |
||
32 | * Original session strategy. |
||
33 | * |
||
34 | * @var ISessionStrategy |
||
35 | */ |
||
36 | private $_originalStrategy; |
||
37 | |||
38 | /** |
||
39 | * Reference to created session. |
||
40 | * |
||
41 | * @var Session |
||
42 | */ |
||
43 | private $_session; |
||
44 | |||
45 | /** |
||
46 | * Remembers if last test failed. |
||
47 | * |
||
48 | * @var boolean |
||
49 | */ |
||
50 | private $_lastTestFailed = false; |
||
51 | |||
52 | /** |
||
53 | * Remembers original session strategy upon shared strategy creation. |
||
54 | * |
||
55 | * @param ISessionStrategy $original_strategy Original session strategy. |
||
56 | */ |
||
57 | 7 | public function __construct(ISessionStrategy $original_strategy) |
|
61 | |||
62 | /** |
||
63 | * Returns an array of event names this subscriber wants to listen to. |
||
64 | * |
||
65 | * @return array The event names to listen to |
||
66 | */ |
||
67 | 7 | public static function getSubscribedEvents() |
|
74 | |||
75 | /** |
||
76 | * Sets event dispatcher. |
||
77 | * |
||
78 | * @param EventDispatcherInterface $event_dispatcher Event dispatcher. |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | 7 | public function setEventDispatcher(EventDispatcherInterface $event_dispatcher) |
|
86 | |||
87 | /** |
||
88 | * Returns Mink session with given browser configuration. |
||
89 | * |
||
90 | * @param BrowserConfiguration $browser Browser configuration for a session. |
||
91 | * |
||
92 | * @return Session |
||
93 | */ |
||
94 | 5 | public function session(BrowserConfiguration $browser) |
|
110 | |||
111 | /** |
||
112 | * Stops session. |
||
113 | * |
||
114 | * @return void |
||
115 | */ |
||
116 | 2 | protected function stopSession() |
|
125 | |||
126 | /** |
||
127 | * Switches to window, that was created upon session creation. |
||
128 | * |
||
129 | * @return void |
||
130 | */ |
||
131 | 4 | private function _switchToMainWindow() |
|
135 | |||
136 | /** |
||
137 | * Called, when test fails. |
||
138 | * |
||
139 | * @param TestFailedEvent $event Test failed event. |
||
140 | * |
||
141 | * @return void |
||
142 | */ |
||
143 | 4 | public function onTestFailed(TestFailedEvent $event) |
|
154 | |||
155 | /** |
||
156 | * Called, when test case ends. |
||
157 | * |
||
158 | * @param TestEvent $event Test event. |
||
159 | * |
||
160 | * @return void |
||
161 | */ |
||
162 | 1 | public function onTestSuiteEnd(TestEvent $event) |
|
174 | |||
175 | /** |
||
176 | * Checks, that event can be handled by this class. |
||
177 | * |
||
178 | * @param TestEvent $event Test event. |
||
179 | * |
||
180 | * @return boolean |
||
181 | */ |
||
182 | 1 | private function _isEventForMe(TestEvent $event) |
|
186 | |||
187 | } |
||
188 |