@@ -91,7 +91,6 @@ discard block |
||
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @param $name |
94 | - * @param array $params |
|
95 | 94 | * |
96 | 95 | * @return string |
97 | 96 | */ |
@@ -102,6 +101,7 @@ discard block |
||
102 | 101 | |
103 | 102 | /** |
104 | 103 | * @When /^I hover over the element "([^"]*)"$/ |
104 | + * @param string $locator |
|
105 | 105 | */ |
106 | 106 | public function iHoverOverTheElement($locator) |
107 | 107 | { |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
250 | - * @param $locator |
|
250 | + * @param string $locator |
|
251 | 251 | * @param string $selector |
252 | 252 | * |
253 | - * @return \Behat\Mink\Element\NodeElement|mixed|null |
|
253 | + * @return \Behat\Mink\Element\NodeElement|null |
|
254 | 254 | */ |
255 | 255 | public function getElement($locator,$selector='css') |
256 | 256 | { |
@@ -25,283 +25,283 @@ |
||
25 | 25 | { |
26 | 26 | use CommonContextTrait; |
27 | 27 | |
28 | - static protected $application; |
|
28 | + static protected $application; |
|
29 | 29 | |
30 | - static private $jobCategoryChecked = false; |
|
30 | + static private $jobCategoryChecked = false; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @BeforeScenario |
|
34 | - * @param BeforeScenarioScope $scope |
|
35 | - */ |
|
36 | - public function setupContexts(BeforeScenarioScope $scope) |
|
37 | - { |
|
38 | - if(false === static::$jobCategoryChecked){ |
|
39 | - /* @var Categories $catRepo */ |
|
40 | - $catRepo = $this->getRepositories()->get('Jobs/Category'); |
|
41 | - $all = $catRepo->findAll(); |
|
42 | - if(count($all) <= 1){ |
|
43 | - $catRepo->createDefaultCategory('professions'); |
|
44 | - $catRepo->createDefaultCategory('industries'); |
|
45 | - $catRepo->createDefaultCategory('employmentTypes'); |
|
46 | - } |
|
47 | - static::$jobCategoryChecked = true; |
|
48 | - } |
|
49 | - } |
|
32 | + /** |
|
33 | + * @BeforeScenario |
|
34 | + * @param BeforeScenarioScope $scope |
|
35 | + */ |
|
36 | + public function setupContexts(BeforeScenarioScope $scope) |
|
37 | + { |
|
38 | + if(false === static::$jobCategoryChecked){ |
|
39 | + /* @var Categories $catRepo */ |
|
40 | + $catRepo = $this->getRepositories()->get('Jobs/Category'); |
|
41 | + $all = $catRepo->findAll(); |
|
42 | + if(count($all) <= 1){ |
|
43 | + $catRepo->createDefaultCategory('professions'); |
|
44 | + $catRepo->createDefaultCategory('industries'); |
|
45 | + $catRepo->createDefaultCategory('employmentTypes'); |
|
46 | + } |
|
47 | + static::$jobCategoryChecked = true; |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return Application |
|
53 | - */ |
|
54 | - public function getApplication() |
|
55 | - { |
|
56 | - if(!is_object(static::$application)){ |
|
57 | - $configFile = realpath(__DIR__.'/../../../config/config.php'); |
|
58 | - $config = include($configFile); |
|
59 | - static::$application = Application::init($config); |
|
60 | - } |
|
61 | - return static::$application; |
|
62 | - } |
|
51 | + /** |
|
52 | + * @return Application |
|
53 | + */ |
|
54 | + public function getApplication() |
|
55 | + { |
|
56 | + if(!is_object(static::$application)){ |
|
57 | + $configFile = realpath(__DIR__.'/../../../config/config.php'); |
|
58 | + $config = include($configFile); |
|
59 | + static::$application = Application::init($config); |
|
60 | + } |
|
61 | + return static::$application; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return \Zend\ServiceManager\ServiceManager |
|
66 | - */ |
|
67 | - public function getServiceManager() |
|
68 | - { |
|
69 | - return $this->getApplication()->getServiceManager(); |
|
70 | - } |
|
64 | + /** |
|
65 | + * @return \Zend\ServiceManager\ServiceManager |
|
66 | + */ |
|
67 | + public function getServiceManager() |
|
68 | + { |
|
69 | + return $this->getApplication()->getServiceManager(); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return \Zend\EventManager\EventManagerInterface |
|
74 | - */ |
|
75 | - public function getEventManager() |
|
76 | - { |
|
77 | - return $this->getApplication()->getEventManager(); |
|
78 | - } |
|
72 | + /** |
|
73 | + * @return \Zend\EventManager\EventManagerInterface |
|
74 | + */ |
|
75 | + public function getEventManager() |
|
76 | + { |
|
77 | + return $this->getApplication()->getEventManager(); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return RepositoryService |
|
82 | - */ |
|
83 | - public function getRepositories() |
|
84 | - { |
|
85 | - return $this->getServiceManager()->get('repositories'); |
|
86 | - } |
|
80 | + /** |
|
81 | + * @return RepositoryService |
|
82 | + */ |
|
83 | + public function getRepositories() |
|
84 | + { |
|
85 | + return $this->getServiceManager()->get('repositories'); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @param $name |
|
90 | - * @param array $params |
|
91 | - * |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function generateUrl($name) |
|
95 | - { |
|
96 | - return $this->minkContext->locatePath($name); |
|
97 | - } |
|
88 | + /** |
|
89 | + * @param $name |
|
90 | + * @param array $params |
|
91 | + * |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function generateUrl($name) |
|
95 | + { |
|
96 | + return $this->minkContext->locatePath($name); |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * @When /^I hover over the element "([^"]*)"$/ |
|
101 | - */ |
|
102 | - public function iHoverOverTheElement($locator) |
|
103 | - { |
|
104 | - $session = $this->minkContext->getSession(); // get the mink session |
|
105 | - $element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element |
|
99 | + /** |
|
100 | + * @When /^I hover over the element "([^"]*)"$/ |
|
101 | + */ |
|
102 | + public function iHoverOverTheElement($locator) |
|
103 | + { |
|
104 | + $session = $this->minkContext->getSession(); // get the mink session |
|
105 | + $element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element |
|
106 | 106 | |
107 | - // errors must not pass silently |
|
108 | - if (null === $element) { |
|
109 | - throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator)); |
|
110 | - } |
|
107 | + // errors must not pass silently |
|
108 | + if (null === $element) { |
|
109 | + throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator)); |
|
110 | + } |
|
111 | 111 | |
112 | - // ok, let's hover it |
|
113 | - $element->mouseOver(); |
|
114 | - } |
|
112 | + // ok, let's hover it |
|
113 | + $element->mouseOver(); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * @Given /^I wait for (\d+) seconds$/ |
|
118 | - */ |
|
119 | - public function iWaitForSecond($second) |
|
120 | - { |
|
121 | - sleep($second); |
|
122 | - } |
|
116 | + /** |
|
117 | + * @Given /^I wait for (\d+) seconds$/ |
|
118 | + */ |
|
119 | + public function iWaitForSecond($second) |
|
120 | + { |
|
121 | + sleep($second); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * @Then /^I wait for the ajax response$/ |
|
126 | - */ |
|
127 | - public function iWaitForTheAjaxResponse() |
|
128 | - { |
|
129 | - $this->getSession()->wait(5000, '(0 === jQuery.active)'); |
|
130 | - } |
|
124 | + /** |
|
125 | + * @Then /^I wait for the ajax response$/ |
|
126 | + */ |
|
127 | + public function iWaitForTheAjaxResponse() |
|
128 | + { |
|
129 | + $this->getSession()->wait(5000, '(0 === jQuery.active)'); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Some forms do not have a Submit button just pass the ID |
|
134 | - * |
|
135 | - * @Given /^I submit the form with id "([^"]*)"$/ |
|
136 | - */ |
|
137 | - public function iSubmitTheFormWithId($arg) |
|
138 | - { |
|
139 | - $node = $this->minkContext->getSession()->getPage()->find('css', $arg); |
|
140 | - if($node) { |
|
141 | - $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();"); |
|
142 | - } else { |
|
143 | - throw new \Exception('Element not found'); |
|
144 | - } |
|
145 | - } |
|
132 | + /** |
|
133 | + * Some forms do not have a Submit button just pass the ID |
|
134 | + * |
|
135 | + * @Given /^I submit the form with id "([^"]*)"$/ |
|
136 | + */ |
|
137 | + public function iSubmitTheFormWithId($arg) |
|
138 | + { |
|
139 | + $node = $this->minkContext->getSession()->getPage()->find('css', $arg); |
|
140 | + if($node) { |
|
141 | + $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();"); |
|
142 | + } else { |
|
143 | + throw new \Exception('Element not found'); |
|
144 | + } |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * @Then I switch to popup :name |
|
149 | - * |
|
150 | - * @param $name |
|
151 | - */ |
|
152 | - public function iSwitchToPopup($name) |
|
153 | - { |
|
154 | - $this->iSetMainWindowName(); |
|
155 | - $this->getSession()->switchToWindow($name); |
|
156 | - } |
|
147 | + /** |
|
148 | + * @Then I switch to popup :name |
|
149 | + * |
|
150 | + * @param $name |
|
151 | + */ |
|
152 | + public function iSwitchToPopup($name) |
|
153 | + { |
|
154 | + $this->iSetMainWindowName(); |
|
155 | + $this->getSession()->switchToWindow($name); |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * @Then I set main window name |
|
160 | - */ |
|
161 | - public function iSetMainWindowName() |
|
162 | - { |
|
163 | - $window_name = 'main_window'; |
|
164 | - $script = 'window.name = "' . $window_name . '"'; |
|
165 | - $this->getSession()->executeScript($script); |
|
166 | - } |
|
158 | + /** |
|
159 | + * @Then I set main window name |
|
160 | + */ |
|
161 | + public function iSetMainWindowName() |
|
162 | + { |
|
163 | + $window_name = 'main_window'; |
|
164 | + $script = 'window.name = "' . $window_name . '"'; |
|
165 | + $this->getSession()->executeScript($script); |
|
166 | + } |
|
167 | 167 | |
168 | - /** |
|
169 | - * @Then I switch back to main window |
|
170 | - */ |
|
171 | - public function iSwitchBackToMainWindow() |
|
172 | - { |
|
173 | - $this->getSession()->switchToWindow('main_window'); |
|
174 | - } |
|
168 | + /** |
|
169 | + * @Then I switch back to main window |
|
170 | + */ |
|
171 | + public function iSwitchBackToMainWindow() |
|
172 | + { |
|
173 | + $this->getSession()->switchToWindow('main_window'); |
|
174 | + } |
|
175 | 175 | |
176 | - public function iVisit($url) |
|
177 | - { |
|
178 | - $this->minkContext->getSession()->visit($url); |
|
179 | - } |
|
176 | + public function iVisit($url) |
|
177 | + { |
|
178 | + $this->minkContext->getSession()->visit($url); |
|
179 | + } |
|
180 | 180 | |
181 | - /** |
|
182 | - * @When I scroll :selector into view |
|
183 | - * |
|
184 | - * @param string $selector Allowed selectors: #id, .className, //xpath |
|
185 | - * |
|
186 | - * @throws \Exception |
|
187 | - */ |
|
188 | - public function scrollIntoView($selector) |
|
189 | - { |
|
190 | - $locator = substr($selector, 0, 1); |
|
181 | + /** |
|
182 | + * @When I scroll :selector into view |
|
183 | + * |
|
184 | + * @param string $selector Allowed selectors: #id, .className, //xpath |
|
185 | + * |
|
186 | + * @throws \Exception |
|
187 | + */ |
|
188 | + public function scrollIntoView($selector) |
|
189 | + { |
|
190 | + $locator = substr($selector, 0, 1); |
|
191 | 191 | |
192 | - switch ($locator) { |
|
193 | - case '/' : // XPath selector |
|
194 | - $function = <<<JS |
|
192 | + switch ($locator) { |
|
193 | + case '/' : // XPath selector |
|
194 | + $function = <<<JS |
|
195 | 195 | (function(){ |
196 | 196 | var elem = document.evaluate($selector, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; |
197 | 197 | elem.scrollIntoView(false); |
198 | 198 | })() |
199 | 199 | JS; |
200 | - break; |
|
200 | + break; |
|
201 | 201 | |
202 | - case '#' : // ID selector |
|
203 | - $selector = substr($selector, 1); |
|
204 | - $function = <<<JS |
|
202 | + case '#' : // ID selector |
|
203 | + $selector = substr($selector, 1); |
|
204 | + $function = <<<JS |
|
205 | 205 | (function(){ |
206 | 206 | var elem = document.getElementById("$selector"); |
207 | 207 | elem.scrollIntoView(false); |
208 | 208 | })() |
209 | 209 | JS; |
210 | - break; |
|
210 | + break; |
|
211 | 211 | |
212 | - case '.' : // Class selector |
|
213 | - $selector = substr($selector, 1); |
|
214 | - $function = <<<JS |
|
212 | + case '.' : // Class selector |
|
213 | + $selector = substr($selector, 1); |
|
214 | + $function = <<<JS |
|
215 | 215 | (function(){ |
216 | 216 | var elem = document.getElementsByClassName("$selector"); |
217 | 217 | elem[0].scrollIntoView(false); |
218 | 218 | })() |
219 | 219 | JS; |
220 | - break; |
|
220 | + break; |
|
221 | 221 | |
222 | - default: |
|
223 | - throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath'); |
|
224 | - break; |
|
225 | - } |
|
222 | + default: |
|
223 | + throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath'); |
|
224 | + break; |
|
225 | + } |
|
226 | 226 | |
227 | - try { |
|
228 | - $this->getSession()->executeScript($function); |
|
229 | - } catch (\Exception $e) { |
|
230 | - throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"'); |
|
231 | - } |
|
232 | - } |
|
227 | + try { |
|
228 | + $this->getSession()->executeScript($function); |
|
229 | + } catch (\Exception $e) { |
|
230 | + throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"'); |
|
231 | + } |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * @When I click location selector |
|
236 | - */ |
|
237 | - public function iClickLocationSelector() |
|
238 | - { |
|
239 | - $locator = '#jobBase-geoLocation-span .select2'; |
|
240 | - $element = $this->getElement($locator); |
|
241 | - $element->click(); |
|
242 | - } |
|
234 | + /** |
|
235 | + * @When I click location selector |
|
236 | + */ |
|
237 | + public function iClickLocationSelector() |
|
238 | + { |
|
239 | + $locator = '#jobBase-geoLocation-span .select2'; |
|
240 | + $element = $this->getElement($locator); |
|
241 | + $element->click(); |
|
242 | + } |
|
243 | 243 | |
244 | - /** |
|
245 | - * @param $locator |
|
246 | - * @param string $selector |
|
247 | - * |
|
248 | - * @return \Behat\Mink\Element\NodeElement|mixed|null |
|
249 | - */ |
|
250 | - public function getElement($locator,$selector='css') |
|
251 | - { |
|
252 | - $page = $this->minkContext->getSession()->getPage(); |
|
253 | - $element = $page->find('css',$locator); |
|
254 | - return $element; |
|
255 | - } |
|
244 | + /** |
|
245 | + * @param $locator |
|
246 | + * @param string $selector |
|
247 | + * |
|
248 | + * @return \Behat\Mink\Element\NodeElement|mixed|null |
|
249 | + */ |
|
250 | + public function getElement($locator,$selector='css') |
|
251 | + { |
|
252 | + $page = $this->minkContext->getSession()->getPage(); |
|
253 | + $element = $page->find('css',$locator); |
|
254 | + return $element; |
|
255 | + } |
|
256 | 256 | |
257 | - /** |
|
258 | - * @When I fill in location search with :term |
|
259 | - * @param $term |
|
260 | - */ |
|
261 | - public function iFillInLocationSearch($term) |
|
262 | - { |
|
263 | - $locator = '.select2-container--open .select2-search__field'; |
|
264 | - $element = $this->getElement($locator); |
|
265 | - $element->focus(); |
|
266 | - $element->setValue($term); |
|
267 | - $this->iWaitForTheAjaxResponse(); |
|
268 | - } |
|
257 | + /** |
|
258 | + * @When I fill in location search with :term |
|
259 | + * @param $term |
|
260 | + */ |
|
261 | + public function iFillInLocationSearch($term) |
|
262 | + { |
|
263 | + $locator = '.select2-container--open .select2-search__field'; |
|
264 | + $element = $this->getElement($locator); |
|
265 | + $element->focus(); |
|
266 | + $element->setValue($term); |
|
267 | + $this->iWaitForTheAjaxResponse(); |
|
268 | + } |
|
269 | 269 | |
270 | - public function iClickOn() |
|
271 | - { |
|
270 | + public function iClickOn() |
|
271 | + { |
|
272 | 272 | |
273 | - } |
|
273 | + } |
|
274 | 274 | |
275 | - /** |
|
276 | - * Click some text |
|
277 | - * |
|
278 | - * @When /^I click on the text "([^"]*)"$/ |
|
279 | - */ |
|
280 | - public function iClickOnTheText($text) |
|
281 | - { |
|
282 | - $session = $this->getSession(); |
|
283 | - $element = $session->getPage()->find( |
|
284 | - 'xpath', |
|
285 | - $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]') |
|
286 | - ); |
|
287 | - if(null === $element){ |
|
288 | - $element = $session->getPage()->find( |
|
289 | - 'named', |
|
290 | - array('id',$text) |
|
291 | - ); |
|
292 | - } |
|
293 | - if (null === $element) { |
|
294 | - throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text)); |
|
295 | - } |
|
275 | + /** |
|
276 | + * Click some text |
|
277 | + * |
|
278 | + * @When /^I click on the text "([^"]*)"$/ |
|
279 | + */ |
|
280 | + public function iClickOnTheText($text) |
|
281 | + { |
|
282 | + $session = $this->getSession(); |
|
283 | + $element = $session->getPage()->find( |
|
284 | + 'xpath', |
|
285 | + $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]') |
|
286 | + ); |
|
287 | + if(null === $element){ |
|
288 | + $element = $session->getPage()->find( |
|
289 | + 'named', |
|
290 | + array('id',$text) |
|
291 | + ); |
|
292 | + } |
|
293 | + if (null === $element) { |
|
294 | + throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text)); |
|
295 | + } |
|
296 | 296 | |
297 | - $element->click(); |
|
297 | + $element->click(); |
|
298 | 298 | |
299 | - } |
|
299 | + } |
|
300 | 300 | |
301 | 301 | /** |
302 | 302 | * @Then /^(?:|I )should see translated text "(?P<text>(?:[^"]|\\")*)"$/ |
303 | 303 | */ |
304 | - public function iShouldSeeText($text) |
|
304 | + public function iShouldSeeText($text) |
|
305 | 305 | { |
306 | 306 | $translator = $this->getServiceManager()->get('translator'); |
307 | 307 | $translated = $translator->translate($text); |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function setupContexts(BeforeScenarioScope $scope) |
37 | 37 | { |
38 | - if(false === static::$jobCategoryChecked){ |
|
38 | + if (false === static::$jobCategoryChecked) { |
|
39 | 39 | /* @var Categories $catRepo */ |
40 | 40 | $catRepo = $this->getRepositories()->get('Jobs/Category'); |
41 | 41 | $all = $catRepo->findAll(); |
42 | - if(count($all) <= 1){ |
|
42 | + if (count($all) <= 1) { |
|
43 | 43 | $catRepo->createDefaultCategory('professions'); |
44 | 44 | $catRepo->createDefaultCategory('industries'); |
45 | 45 | $catRepo->createDefaultCategory('employmentTypes'); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getApplication() |
55 | 55 | { |
56 | - if(!is_object(static::$application)){ |
|
56 | + if (!is_object(static::$application)) { |
|
57 | 57 | $configFile = realpath(__DIR__.'/../../../config/config.php'); |
58 | 58 | $config = include($configFile); |
59 | 59 | static::$application = Application::init($config); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | public function iSubmitTheFormWithId($arg) |
138 | 138 | { |
139 | 139 | $node = $this->minkContext->getSession()->getPage()->find('css', $arg); |
140 | - if($node) { |
|
140 | + if ($node) { |
|
141 | 141 | $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();"); |
142 | 142 | } else { |
143 | 143 | throw new \Exception('Element not found'); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | public function iSetMainWindowName() |
162 | 162 | { |
163 | 163 | $window_name = 'main_window'; |
164 | - $script = 'window.name = "' . $window_name . '"'; |
|
164 | + $script = 'window.name = "'.$window_name.'"'; |
|
165 | 165 | $this->getSession()->executeScript($script); |
166 | 166 | } |
167 | 167 | |
@@ -220,14 +220,14 @@ discard block |
||
220 | 220 | break; |
221 | 221 | |
222 | 222 | default: |
223 | - throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath'); |
|
223 | + throw new \Exception(__METHOD__.' Couldn\'t find selector: '.$selector.' - Allowed selectors: #id, .className, //xpath'); |
|
224 | 224 | break; |
225 | 225 | } |
226 | 226 | |
227 | 227 | try { |
228 | 228 | $this->getSession()->executeScript($function); |
229 | 229 | } catch (\Exception $e) { |
230 | - throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"'); |
|
230 | + throw new \Exception(__METHOD__.' failed'.' Message: for this locator:"'.$selector.'"'); |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return \Behat\Mink\Element\NodeElement|mixed|null |
249 | 249 | */ |
250 | - public function getElement($locator,$selector='css') |
|
250 | + public function getElement($locator, $selector = 'css') |
|
251 | 251 | { |
252 | 252 | $page = $this->minkContext->getSession()->getPage(); |
253 | - $element = $page->find('css',$locator); |
|
253 | + $element = $page->find('css', $locator); |
|
254 | 254 | return $element; |
255 | 255 | } |
256 | 256 | |
@@ -282,12 +282,12 @@ discard block |
||
282 | 282 | $session = $this->getSession(); |
283 | 283 | $element = $session->getPage()->find( |
284 | 284 | 'xpath', |
285 | - $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]') |
|
285 | + $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'.$text.'"]') |
|
286 | 286 | ); |
287 | - if(null === $element){ |
|
287 | + if (null === $element) { |
|
288 | 288 | $element = $session->getPage()->find( |
289 | 289 | 'named', |
290 | - array('id',$text) |
|
290 | + array('id', $text) |
|
291 | 291 | ); |
292 | 292 | } |
293 | 293 | if (null === $element) { |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | |
32 | 32 | public function __construct() |
33 | 33 | { |
34 | - static::$configFile = getcwd() . '/config/autoload/install.module.php'; |
|
35 | - static::$yawikGlobalConfig = getcwd() . '/config/autoload/yawik.config.global.php'; |
|
34 | + static::$configFile = getcwd().'/config/autoload/install.module.php'; |
|
35 | + static::$yawikGlobalConfig = getcwd().'/config/autoload/yawik.config.global.php'; |
|
36 | 36 | static::$yawikBackupConfig = str_replace('yawik.config.global.php', 'yawik.backup', static::$yawikGlobalConfig); |
37 | 37 | } |
38 | 38 | |
@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | public function iHaveInstallModuleActivated() |
43 | 43 | { |
44 | 44 | $target = static::$configFile; |
45 | - if(!file_exists($target)){ |
|
45 | + if (!file_exists($target)) { |
|
46 | 46 | $source = __DIR__.'/../resources/install.module.php'; |
47 | - copy($source,$target); |
|
48 | - chmod($target,0777); |
|
47 | + copy($source, $target); |
|
48 | + chmod($target, 0777); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // backup existing file |
52 | 52 | $yawikBackupConfig = static::$yawikBackupConfig; |
53 | 53 | $yawikGlobalConfig = static::$yawikGlobalConfig; |
54 | 54 | |
55 | - if(is_file($yawikGlobalConfig)){ |
|
56 | - rename($yawikGlobalConfig,$yawikBackupConfig); |
|
55 | + if (is_file($yawikGlobalConfig)) { |
|
56 | + rename($yawikGlobalConfig, $yawikBackupConfig); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | static public function restoreConfig() |
94 | 94 | { |
95 | - if(is_file($file = static::$configFile)){ |
|
95 | + if (is_file($file = static::$configFile)) { |
|
96 | 96 | unlink($file); |
97 | 97 | } |
98 | 98 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | $yawikBackupConfig = static::$yawikBackupConfig; |
101 | 101 | $yawikGlobalConfig = static::$yawikGlobalConfig; |
102 | 102 | |
103 | - if(is_file($yawikBackupConfig)){ |
|
104 | - rename($yawikBackupConfig,$yawikGlobalConfig); |
|
103 | + if (is_file($yawikBackupConfig)) { |
|
104 | + rename($yawikBackupConfig, $yawikGlobalConfig); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
@@ -112,6 +112,6 @@ discard block |
||
112 | 112 | { |
113 | 113 | $config = $this->getService('config'); |
114 | 114 | $connection = $config['doctrine']['connection']['odm_default']['connectionString']; |
115 | - $this->minkContext->fillField('db_conn',$connection); |
|
115 | + $this->minkContext->fillField('db_conn', $connection); |
|
116 | 116 | } |
117 | 117 | } |
@@ -31,17 +31,17 @@ |
||
31 | 31 | * @param array|null $options |
32 | 32 | * @return Notification |
33 | 33 | */ |
34 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
35 | - { |
|
36 | - $pluginManager = $container->get('ControllerPluginManager'); |
|
37 | - $flashMessenger = $pluginManager->get('FlashMessenger'); |
|
38 | - $translator = $container->get('translator'); |
|
34 | + public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
35 | + { |
|
36 | + $pluginManager = $container->get('ControllerPluginManager'); |
|
37 | + $flashMessenger = $pluginManager->get('FlashMessenger'); |
|
38 | + $translator = $container->get('translator'); |
|
39 | 39 | |
40 | - $notificationListener = $container->get('Core/Listener/Notification'); |
|
41 | - $notification = new Notification($flashMessenger); |
|
42 | - $notification->setListener($notificationListener); |
|
43 | - $notification->setTranslator($translator); |
|
40 | + $notificationListener = $container->get('Core/Listener/Notification'); |
|
41 | + $notification = new Notification($flashMessenger); |
|
42 | + $notification->setListener($notificationListener); |
|
43 | + $notification->setTranslator($translator); |
|
44 | 44 | |
45 | - return $notification; |
|
46 | - } |
|
45 | + return $notification; |
|
46 | + } |
|
47 | 47 | } |
@@ -31,14 +31,14 @@ |
||
31 | 31 | * @param array|null $options |
32 | 32 | * @return Notification |
33 | 33 | */ |
34 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
34 | + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
35 | 35 | { |
36 | 36 | $pluginManager = $container->get('ControllerPluginManager'); |
37 | 37 | $flashMessenger = $pluginManager->get('FlashMessenger'); |
38 | 38 | $translator = $container->get('translator'); |
39 | 39 | |
40 | 40 | $notificationListener = $container->get('Core/Listener/Notification'); |
41 | - $notification = new Notification($flashMessenger); |
|
41 | + $notification = new Notification($flashMessenger); |
|
42 | 42 | $notification->setListener($notificationListener); |
43 | 43 | $notification->setTranslator($translator); |
44 | 44 |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function trigger($event, $target = null) |
75 | 75 | { |
76 | 76 | if (empty($this->_template) || !is_string($this->_template)) { |
77 | - throw new \InvalidArgumentException('ContentCollector must have a template-name'); |
|
77 | + throw new \InvalidArgumentException('ContentCollector must have a template-name'); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $responseCollection = $this->getController()->getEventManager()->trigger($event, $target); |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | $viewModel->setTemplate($this->_template); |
83 | 83 | foreach ($responseCollection as $i => $response) { |
84 | 84 | if (is_string($response)) { |
85 | - $template = $response; |
|
86 | - $response = new ViewModel(array('target' => $target)); |
|
87 | - $response->setTemplate($template); |
|
85 | + $template = $response; |
|
86 | + $response = new ViewModel(array('target' => $target)); |
|
87 | + $response->setTemplate($template); |
|
88 | 88 | } |
89 | 89 | $viewModel->addChild($response, $this->_captureTo . $i); |
90 | 90 | } |
@@ -86,7 +86,7 @@ |
||
86 | 86 | $response = new ViewModel(array('target' => $target)); |
87 | 87 | $response->setTemplate($template); |
88 | 88 | } |
89 | - $viewModel->addChild($response, $this->_captureTo . $i); |
|
89 | + $viewModel->addChild($response, $this->_captureTo.$i); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | return $viewModel; |
@@ -13,11 +13,11 @@ |
||
13 | 13 | */ |
14 | 14 | class ConfigFactory implements FactoryInterface |
15 | 15 | { |
16 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
17 | - { |
|
18 | - $config = $container->get('Config'); |
|
19 | - $plugin = new Config($config); |
|
16 | + public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
17 | + { |
|
18 | + $config = $container->get('Config'); |
|
19 | + $plugin = new Config($config); |
|
20 | 20 | |
21 | - return $plugin; |
|
22 | - } |
|
21 | + return $plugin; |
|
22 | + } |
|
23 | 23 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | class ConfigFactory implements FactoryInterface |
15 | 15 | { |
16 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
16 | + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
17 | 17 | { |
18 | 18 | $config = $container->get('Config'); |
19 | 19 | $plugin = new Config($config); |
@@ -87,11 +87,11 @@ |
||
87 | 87 | return $sendMail ? $this->send($mail) : $mail; |
88 | 88 | } |
89 | 89 | |
90 | - /** |
|
91 | - * @param ContainerInterface $container |
|
92 | - * |
|
93 | - * @return Mailer |
|
94 | - */ |
|
90 | + /** |
|
91 | + * @param ContainerInterface $container |
|
92 | + * |
|
93 | + * @return Mailer |
|
94 | + */ |
|
95 | 95 | public static function factory(ContainerInterface $container) |
96 | 96 | { |
97 | 97 | return new static($container->get('Core/MailService')); |
@@ -17,7 +17,7 @@ |
||
17 | 17 | * |
18 | 18 | * @author Anthonius Munthi <[email protected]> |
19 | 19 | * @ODM\MappedSuperclass |
20 | - */ |
|
20 | + */ |
|
21 | 21 | abstract class AbstractIdentifiableEntity extends AbstractEntity implements IdentifiableEntityInterface |
22 | 22 | { |
23 | 23 | use IdentifiableEntityTrait; |
@@ -150,6 +150,9 @@ |
||
150 | 150 | ); |
151 | 151 | } |
152 | 152 | |
153 | + /** |
|
154 | + * @param string $contents |
|
155 | + */ |
|
153 | 156 | private function parseEmail($contents) |
154 | 157 | { |
155 | 158 | $addresses = $this->parseEmailAddress($contents); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $core = $scope->getEnvironment()->getContext(CoreContext::class); |
50 | 50 | /* @var FileTransport $transport */ |
51 | 51 | $transport = $core->getServiceManager()->get('Core/MailService')->getTransport(); |
52 | - $path = $transport->getOptions()->getPath() . '/*.eml'; |
|
52 | + $path = $transport->getOptions()->getPath().'/*.eml'; |
|
53 | 53 | foreach (glob($path) as $filename) { |
54 | 54 | unlink($filename); |
55 | 55 | } |
@@ -105,25 +105,25 @@ discard block |
||
105 | 105 | $regex = '/.*('.preg_quote($text).').*/im'; |
106 | 106 | $matches = []; |
107 | 107 | $multiMessages = false; |
108 | - if(count($this->messages) > 1){ |
|
108 | + if (count($this->messages) > 1) { |
|
109 | 109 | $multiMessages = true; |
110 | 110 | } |
111 | 111 | $content = ""; |
112 | - foreach($this->messages as $key=>$definition){ |
|
112 | + foreach ($this->messages as $key=>$definition) { |
|
113 | 113 | $content = $definition['contents']; |
114 | - if(preg_match($regex,$content,$match)){ |
|
114 | + if (preg_match($regex, $content, $match)) { |
|
115 | 115 | $matches[] = $match; |
116 | 116 | } |
117 | 117 | } |
118 | - $failMessage = sprintf('Can not find text "%s" in any email sent',$text); |
|
119 | - if(!$multiMessages){ |
|
118 | + $failMessage = sprintf('Can not find text "%s" in any email sent', $text); |
|
119 | + if (!$multiMessages) { |
|
120 | 120 | $failMessage = sprintf( |
121 | 121 | 'Can not find text "%s" in sent email. Here\'s the email content: %s', |
122 | 122 | $text, |
123 | 123 | PHP_EOL.PHP_EOL.$content |
124 | 124 | ); |
125 | 125 | } |
126 | - Assert::true(count($matches)>0,$failMessage); |
|
126 | + Assert::true(count($matches) > 0, $failMessage); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -136,16 +136,16 @@ discard block |
||
136 | 136 | |
137 | 137 | $path = $transport->getOptions()->getPath().'/*.eml'; |
138 | 138 | |
139 | - foreach(glob($path) as $filename){ |
|
139 | + foreach (glob($path) as $filename) { |
|
140 | 140 | $id = md5($filename); |
141 | - if(!isset($this->messages[$id])){ |
|
141 | + if (!isset($this->messages[$id])) { |
|
142 | 142 | $contents = file_get_contents($filename); |
143 | - $this->messages[$id] = $this->parseEmail($contents); |
|
143 | + $this->messages[$id] = $this->parseEmail($contents); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | 147 | Assert::true( |
148 | - count($this->messages)>0, |
|
148 | + count($this->messages) > 0, |
|
149 | 149 | 'No email have been sent' |
150 | 150 | ); |
151 | 151 | } |
@@ -153,33 +153,33 @@ discard block |
||
153 | 153 | private function parseEmail($contents) |
154 | 154 | { |
155 | 155 | $addresses = $this->parseEmailAddress($contents); |
156 | - $subject =$this->parseSubject($contents); |
|
156 | + $subject = $this->parseSubject($contents); |
|
157 | 157 | |
158 | 158 | $contents = strip_tags($contents); |
159 | 159 | $contents = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $contents); |
160 | 160 | |
161 | - return array_merge($addresses,$subject,['contents' => $contents]); |
|
161 | + return array_merge($addresses, $subject, ['contents' => $contents]); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | private function parseEmailAddress($contents) |
165 | 165 | { |
166 | 166 | // pattern to get email address |
167 | - $radd = '(\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\b)'; |
|
167 | + $radd = '(\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\b)'; |
|
168 | 168 | |
169 | 169 | // get email from address |
170 | - $regex = sprintf('/^From\:.*%s/im',$radd); |
|
171 | - $hasMatch = preg_match($regex,$contents,$matches); |
|
172 | - $fromAddress = $hasMatch ? $matches[1]:null; |
|
170 | + $regex = sprintf('/^From\:.*%s/im', $radd); |
|
171 | + $hasMatch = preg_match($regex, $contents, $matches); |
|
172 | + $fromAddress = $hasMatch ? $matches[1] : null; |
|
173 | 173 | |
174 | 174 | // get email to address |
175 | - $regex = sprintf('/^To\:\s+%s/im',$radd); |
|
176 | - $hasMatch = preg_match($regex,$contents,$matches); |
|
177 | - $toAddress1 = $hasMatch ? $matches[1]:null; |
|
175 | + $regex = sprintf('/^To\:\s+%s/im', $radd); |
|
176 | + $hasMatch = preg_match($regex, $contents, $matches); |
|
177 | + $toAddress1 = $hasMatch ? $matches[1] : null; |
|
178 | 178 | |
179 | 179 | // get email to address |
180 | - $regex = sprintf('/^To\:.*%s/im',$radd); |
|
181 | - $hasMatch = preg_match($regex,$contents,$matches); |
|
182 | - $toAddress2 = $hasMatch ? $matches[1]:null; |
|
180 | + $regex = sprintf('/^To\:.*%s/im', $radd); |
|
181 | + $hasMatch = preg_match($regex, $contents, $matches); |
|
182 | + $toAddress2 = $hasMatch ? $matches[1] : null; |
|
183 | 183 | |
184 | 184 | $this->fromMails[] = $fromAddress; |
185 | 185 | $this->toMails[] = $toAddress1; |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | |
188 | 188 | return [ |
189 | 189 | 'from' => $fromAddress, |
190 | - 'to' => [$toAddress1,$toAddress2], |
|
190 | + 'to' => [$toAddress1, $toAddress2], |
|
191 | 191 | ]; |
192 | 192 | } |
193 | 193 | |
194 | 194 | private function parseSubject($contents) |
195 | 195 | { |
196 | 196 | $pattern = '/Subject\:(.*)/i'; |
197 | - preg_match($pattern,$contents,$matches); |
|
198 | - $subject = isset($matches[1]) ? $matches[1]:null; |
|
197 | + preg_match($pattern, $contents, $matches); |
|
198 | + $subject = isset($matches[1]) ? $matches[1] : null; |
|
199 | 199 | $this->subjects[] = $subject; |
200 | 200 | return [ |
201 | 201 | 'subject' => trim($subject) |
@@ -32,7 +32,7 @@ |
||
32 | 32 | { |
33 | 33 | $options = $this->options; |
34 | 34 | $filename = call_user_func($options->getCallback(), $this); |
35 | - $file = $options->getPath() . DIRECTORY_SEPARATOR . $filename; |
|
35 | + $file = $options->getPath().DIRECTORY_SEPARATOR.$filename; |
|
36 | 36 | |
37 | 37 | |
38 | 38 | $contents = $message->toString(); |