@@ -23,290 +23,290 @@ |
||
23 | 23 | */ |
24 | 24 | class CoreContext extends RawMinkContext |
25 | 25 | { |
26 | - static protected $application; |
|
26 | + static protected $application; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var MinkContext |
|
30 | - */ |
|
31 | - protected $minkContext; |
|
28 | + /** |
|
29 | + * @var MinkContext |
|
30 | + */ |
|
31 | + protected $minkContext; |
|
32 | 32 | |
33 | - static private $jobCategoryChecked = false; |
|
33 | + static private $jobCategoryChecked = false; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @BeforeScenario |
|
37 | - * @param BeforeScenarioScope $scope |
|
38 | - */ |
|
39 | - public function gatherContexts(BeforeScenarioScope $scope) |
|
40 | - { |
|
41 | - $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
42 | - if(false === static::$jobCategoryChecked){ |
|
43 | - /* @var Categories $catRepo */ |
|
44 | - $catRepo = $this->getRepositories()->get('Jobs/Category'); |
|
45 | - $all = $catRepo->findAll(); |
|
46 | - if(count($all) <= 1){ |
|
47 | - $catRepo->createDefaultCategory('professions'); |
|
48 | - $catRepo->createDefaultCategory('industries'); |
|
49 | - $catRepo->createDefaultCategory('employmentTypes'); |
|
50 | - } |
|
51 | - static::$jobCategoryChecked = true; |
|
52 | - } |
|
53 | - } |
|
35 | + /** |
|
36 | + * @BeforeScenario |
|
37 | + * @param BeforeScenarioScope $scope |
|
38 | + */ |
|
39 | + public function gatherContexts(BeforeScenarioScope $scope) |
|
40 | + { |
|
41 | + $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
42 | + if(false === static::$jobCategoryChecked){ |
|
43 | + /* @var Categories $catRepo */ |
|
44 | + $catRepo = $this->getRepositories()->get('Jobs/Category'); |
|
45 | + $all = $catRepo->findAll(); |
|
46 | + if(count($all) <= 1){ |
|
47 | + $catRepo->createDefaultCategory('professions'); |
|
48 | + $catRepo->createDefaultCategory('industries'); |
|
49 | + $catRepo->createDefaultCategory('employmentTypes'); |
|
50 | + } |
|
51 | + static::$jobCategoryChecked = true; |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return Application |
|
57 | - */ |
|
58 | - public function getApplication() |
|
59 | - { |
|
60 | - if(!is_object(static::$application)){ |
|
61 | - $configFile = realpath(__DIR__.'/../../../config/config.php'); |
|
62 | - $config = include($configFile); |
|
63 | - static::$application = Application::init($config); |
|
64 | - } |
|
65 | - return static::$application; |
|
66 | - } |
|
55 | + /** |
|
56 | + * @return Application |
|
57 | + */ |
|
58 | + public function getApplication() |
|
59 | + { |
|
60 | + if(!is_object(static::$application)){ |
|
61 | + $configFile = realpath(__DIR__.'/../../../config/config.php'); |
|
62 | + $config = include($configFile); |
|
63 | + static::$application = Application::init($config); |
|
64 | + } |
|
65 | + return static::$application; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return \Zend\ServiceManager\ServiceManager |
|
70 | - */ |
|
71 | - public function getServiceManager() |
|
72 | - { |
|
73 | - return $this->getApplication()->getServiceManager(); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @return \Zend\ServiceManager\ServiceManager |
|
70 | + */ |
|
71 | + public function getServiceManager() |
|
72 | + { |
|
73 | + return $this->getApplication()->getServiceManager(); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @return \Zend\EventManager\EventManagerInterface |
|
78 | - */ |
|
79 | - public function getEventManager() |
|
80 | - { |
|
81 | - return $this->getApplication()->getEventManager(); |
|
82 | - } |
|
76 | + /** |
|
77 | + * @return \Zend\EventManager\EventManagerInterface |
|
78 | + */ |
|
79 | + public function getEventManager() |
|
80 | + { |
|
81 | + return $this->getApplication()->getEventManager(); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return RepositoryService |
|
86 | - */ |
|
87 | - public function getRepositories() |
|
88 | - { |
|
89 | - return $this->getServiceManager()->get('repositories'); |
|
90 | - } |
|
84 | + /** |
|
85 | + * @return RepositoryService |
|
86 | + */ |
|
87 | + public function getRepositories() |
|
88 | + { |
|
89 | + return $this->getServiceManager()->get('repositories'); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * @param $name |
|
94 | - * @param array $params |
|
95 | - * |
|
96 | - * @return string |
|
97 | - */ |
|
98 | - public function generateUrl($name) |
|
99 | - { |
|
100 | - return $this->minkContext->locatePath($name); |
|
101 | - } |
|
92 | + /** |
|
93 | + * @param $name |
|
94 | + * @param array $params |
|
95 | + * |
|
96 | + * @return string |
|
97 | + */ |
|
98 | + public function generateUrl($name) |
|
99 | + { |
|
100 | + return $this->minkContext->locatePath($name); |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * @When /^I hover over the element "([^"]*)"$/ |
|
105 | - */ |
|
106 | - public function iHoverOverTheElement($locator) |
|
107 | - { |
|
108 | - $session = $this->minkContext->getSession(); // get the mink session |
|
109 | - $element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element |
|
103 | + /** |
|
104 | + * @When /^I hover over the element "([^"]*)"$/ |
|
105 | + */ |
|
106 | + public function iHoverOverTheElement($locator) |
|
107 | + { |
|
108 | + $session = $this->minkContext->getSession(); // get the mink session |
|
109 | + $element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element |
|
110 | 110 | |
111 | - // errors must not pass silently |
|
112 | - if (null === $element) { |
|
113 | - throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator)); |
|
114 | - } |
|
111 | + // errors must not pass silently |
|
112 | + if (null === $element) { |
|
113 | + throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator)); |
|
114 | + } |
|
115 | 115 | |
116 | - // ok, let's hover it |
|
117 | - $element->mouseOver(); |
|
118 | - } |
|
116 | + // ok, let's hover it |
|
117 | + $element->mouseOver(); |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * @Given /^I wait for (\d+) seconds$/ |
|
122 | - */ |
|
123 | - public function iWaitForSecond($second) |
|
124 | - { |
|
125 | - sleep($second); |
|
126 | - } |
|
120 | + /** |
|
121 | + * @Given /^I wait for (\d+) seconds$/ |
|
122 | + */ |
|
123 | + public function iWaitForSecond($second) |
|
124 | + { |
|
125 | + sleep($second); |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * @Then /^I wait for the ajax response$/ |
|
130 | - */ |
|
131 | - public function iWaitForTheAjaxResponse() |
|
132 | - { |
|
133 | - $this->getSession()->wait(5000, '(0 === jQuery.active)'); |
|
134 | - } |
|
128 | + /** |
|
129 | + * @Then /^I wait for the ajax response$/ |
|
130 | + */ |
|
131 | + public function iWaitForTheAjaxResponse() |
|
132 | + { |
|
133 | + $this->getSession()->wait(5000, '(0 === jQuery.active)'); |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * Some forms do not have a Submit button just pass the ID |
|
138 | - * |
|
139 | - * @Given /^I submit the form with id "([^"]*)"$/ |
|
140 | - */ |
|
141 | - public function iSubmitTheFormWithId($arg) |
|
142 | - { |
|
143 | - $node = $this->minkContext->getSession()->getPage()->find('css', $arg); |
|
144 | - if($node) { |
|
145 | - $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();"); |
|
146 | - } else { |
|
147 | - throw new \Exception('Element not found'); |
|
148 | - } |
|
149 | - } |
|
136 | + /** |
|
137 | + * Some forms do not have a Submit button just pass the ID |
|
138 | + * |
|
139 | + * @Given /^I submit the form with id "([^"]*)"$/ |
|
140 | + */ |
|
141 | + public function iSubmitTheFormWithId($arg) |
|
142 | + { |
|
143 | + $node = $this->minkContext->getSession()->getPage()->find('css', $arg); |
|
144 | + if($node) { |
|
145 | + $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();"); |
|
146 | + } else { |
|
147 | + throw new \Exception('Element not found'); |
|
148 | + } |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * @Then I switch to popup :name |
|
153 | - * |
|
154 | - * @param $name |
|
155 | - */ |
|
156 | - public function iSwitchToPopup($name) |
|
157 | - { |
|
158 | - $this->iSetMainWindowName(); |
|
159 | - $this->getSession()->switchToWindow($name); |
|
160 | - } |
|
151 | + /** |
|
152 | + * @Then I switch to popup :name |
|
153 | + * |
|
154 | + * @param $name |
|
155 | + */ |
|
156 | + public function iSwitchToPopup($name) |
|
157 | + { |
|
158 | + $this->iSetMainWindowName(); |
|
159 | + $this->getSession()->switchToWindow($name); |
|
160 | + } |
|
161 | 161 | |
162 | - /** |
|
163 | - * @Then I set main window name |
|
164 | - */ |
|
165 | - public function iSetMainWindowName() |
|
166 | - { |
|
167 | - $window_name = 'main_window'; |
|
168 | - $script = 'window.name = "' . $window_name . '"'; |
|
169 | - $this->getSession()->executeScript($script); |
|
170 | - } |
|
162 | + /** |
|
163 | + * @Then I set main window name |
|
164 | + */ |
|
165 | + public function iSetMainWindowName() |
|
166 | + { |
|
167 | + $window_name = 'main_window'; |
|
168 | + $script = 'window.name = "' . $window_name . '"'; |
|
169 | + $this->getSession()->executeScript($script); |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * @Then I switch back to main window |
|
174 | - */ |
|
175 | - public function iSwitchBackToMainWindow() |
|
176 | - { |
|
177 | - $this->getSession()->switchToWindow('main_window'); |
|
178 | - } |
|
172 | + /** |
|
173 | + * @Then I switch back to main window |
|
174 | + */ |
|
175 | + public function iSwitchBackToMainWindow() |
|
176 | + { |
|
177 | + $this->getSession()->switchToWindow('main_window'); |
|
178 | + } |
|
179 | 179 | |
180 | - public function iVisit($url) |
|
181 | - { |
|
182 | - $this->minkContext->getSession()->visit($url); |
|
183 | - } |
|
180 | + public function iVisit($url) |
|
181 | + { |
|
182 | + $this->minkContext->getSession()->visit($url); |
|
183 | + } |
|
184 | 184 | |
185 | - /** |
|
186 | - * @When I scroll :selector into view |
|
187 | - * |
|
188 | - * @param string $selector Allowed selectors: #id, .className, //xpath |
|
189 | - * |
|
190 | - * @throws \Exception |
|
191 | - */ |
|
192 | - public function scrollIntoView($selector) |
|
193 | - { |
|
194 | - $locator = substr($selector, 0, 1); |
|
185 | + /** |
|
186 | + * @When I scroll :selector into view |
|
187 | + * |
|
188 | + * @param string $selector Allowed selectors: #id, .className, //xpath |
|
189 | + * |
|
190 | + * @throws \Exception |
|
191 | + */ |
|
192 | + public function scrollIntoView($selector) |
|
193 | + { |
|
194 | + $locator = substr($selector, 0, 1); |
|
195 | 195 | |
196 | - switch ($locator) { |
|
197 | - case '/' : // XPath selector |
|
198 | - $function = <<<JS |
|
196 | + switch ($locator) { |
|
197 | + case '/' : // XPath selector |
|
198 | + $function = <<<JS |
|
199 | 199 | (function(){ |
200 | 200 | var elem = document.evaluate($selector, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; |
201 | 201 | elem.scrollIntoView(false); |
202 | 202 | })() |
203 | 203 | JS; |
204 | - break; |
|
204 | + break; |
|
205 | 205 | |
206 | - case '#' : // ID selector |
|
207 | - $selector = substr($selector, 1); |
|
208 | - $function = <<<JS |
|
206 | + case '#' : // ID selector |
|
207 | + $selector = substr($selector, 1); |
|
208 | + $function = <<<JS |
|
209 | 209 | (function(){ |
210 | 210 | var elem = document.getElementById("$selector"); |
211 | 211 | elem.scrollIntoView(false); |
212 | 212 | })() |
213 | 213 | JS; |
214 | - break; |
|
214 | + break; |
|
215 | 215 | |
216 | - case '.' : // Class selector |
|
217 | - $selector = substr($selector, 1); |
|
218 | - $function = <<<JS |
|
216 | + case '.' : // Class selector |
|
217 | + $selector = substr($selector, 1); |
|
218 | + $function = <<<JS |
|
219 | 219 | (function(){ |
220 | 220 | var elem = document.getElementsByClassName("$selector"); |
221 | 221 | elem[0].scrollIntoView(false); |
222 | 222 | })() |
223 | 223 | JS; |
224 | - break; |
|
224 | + break; |
|
225 | 225 | |
226 | - default: |
|
227 | - throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath'); |
|
228 | - break; |
|
229 | - } |
|
226 | + default: |
|
227 | + throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath'); |
|
228 | + break; |
|
229 | + } |
|
230 | 230 | |
231 | - try { |
|
232 | - $this->getSession()->executeScript($function); |
|
233 | - } catch (\Exception $e) { |
|
234 | - throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"'); |
|
235 | - } |
|
236 | - } |
|
231 | + try { |
|
232 | + $this->getSession()->executeScript($function); |
|
233 | + } catch (\Exception $e) { |
|
234 | + throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"'); |
|
235 | + } |
|
236 | + } |
|
237 | 237 | |
238 | 238 | |
239 | - /** |
|
240 | - * @When I click location selector |
|
241 | - */ |
|
242 | - public function iClickLocationSelector() |
|
243 | - { |
|
244 | - $locator = '#jobBase-geoLocation-span .select2'; |
|
245 | - $element = $this->getElement($locator); |
|
246 | - $element->click(); |
|
247 | - } |
|
239 | + /** |
|
240 | + * @When I click location selector |
|
241 | + */ |
|
242 | + public function iClickLocationSelector() |
|
243 | + { |
|
244 | + $locator = '#jobBase-geoLocation-span .select2'; |
|
245 | + $element = $this->getElement($locator); |
|
246 | + $element->click(); |
|
247 | + } |
|
248 | 248 | |
249 | - /** |
|
250 | - * @param $locator |
|
251 | - * @param string $selector |
|
252 | - * |
|
253 | - * @return \Behat\Mink\Element\NodeElement|mixed|null |
|
254 | - */ |
|
255 | - public function getElement($locator,$selector='css') |
|
256 | - { |
|
257 | - $page = $this->minkContext->getSession()->getPage(); |
|
258 | - $element = $page->find('css',$locator); |
|
259 | - return $element; |
|
260 | - } |
|
249 | + /** |
|
250 | + * @param $locator |
|
251 | + * @param string $selector |
|
252 | + * |
|
253 | + * @return \Behat\Mink\Element\NodeElement|mixed|null |
|
254 | + */ |
|
255 | + public function getElement($locator,$selector='css') |
|
256 | + { |
|
257 | + $page = $this->minkContext->getSession()->getPage(); |
|
258 | + $element = $page->find('css',$locator); |
|
259 | + return $element; |
|
260 | + } |
|
261 | 261 | |
262 | - /** |
|
263 | - * @When I fill in location search with :term |
|
264 | - * @param $term |
|
265 | - */ |
|
266 | - public function iFillInLocationSearch($term) |
|
267 | - { |
|
268 | - $locator = '.select2-container--open .select2-search__field'; |
|
269 | - $element = $this->getElement($locator); |
|
270 | - $element->focus(); |
|
271 | - $element->setValue($term); |
|
272 | - $this->iWaitForTheAjaxResponse(); |
|
273 | - } |
|
262 | + /** |
|
263 | + * @When I fill in location search with :term |
|
264 | + * @param $term |
|
265 | + */ |
|
266 | + public function iFillInLocationSearch($term) |
|
267 | + { |
|
268 | + $locator = '.select2-container--open .select2-search__field'; |
|
269 | + $element = $this->getElement($locator); |
|
270 | + $element->focus(); |
|
271 | + $element->setValue($term); |
|
272 | + $this->iWaitForTheAjaxResponse(); |
|
273 | + } |
|
274 | 274 | |
275 | - public function iClickOn() |
|
276 | - { |
|
275 | + public function iClickOn() |
|
276 | + { |
|
277 | 277 | |
278 | - } |
|
278 | + } |
|
279 | 279 | |
280 | - /** |
|
281 | - * Click some text |
|
282 | - * |
|
283 | - * @When /^I click on the text "([^"]*)"$/ |
|
284 | - */ |
|
285 | - public function iClickOnTheText($text) |
|
286 | - { |
|
287 | - $session = $this->getSession(); |
|
288 | - $element = $session->getPage()->find( |
|
289 | - 'xpath', |
|
290 | - $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]') |
|
291 | - ); |
|
292 | - if(null === $element){ |
|
293 | - $element = $session->getPage()->find( |
|
294 | - 'named', |
|
295 | - array('id',$text) |
|
296 | - ); |
|
297 | - } |
|
298 | - if (null === $element) { |
|
299 | - throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text)); |
|
300 | - } |
|
280 | + /** |
|
281 | + * Click some text |
|
282 | + * |
|
283 | + * @When /^I click on the text "([^"]*)"$/ |
|
284 | + */ |
|
285 | + public function iClickOnTheText($text) |
|
286 | + { |
|
287 | + $session = $this->getSession(); |
|
288 | + $element = $session->getPage()->find( |
|
289 | + 'xpath', |
|
290 | + $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]') |
|
291 | + ); |
|
292 | + if(null === $element){ |
|
293 | + $element = $session->getPage()->find( |
|
294 | + 'named', |
|
295 | + array('id',$text) |
|
296 | + ); |
|
297 | + } |
|
298 | + if (null === $element) { |
|
299 | + throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text)); |
|
300 | + } |
|
301 | 301 | |
302 | - $element->click(); |
|
302 | + $element->click(); |
|
303 | 303 | |
304 | - } |
|
304 | + } |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * @Then /^(?:|I )should see translated text "(?P<text>(?:[^"]|\\")*)"$/ |
308 | 308 | */ |
309 | - public function iShouldSeeText($text) |
|
309 | + public function iShouldSeeText($text) |
|
310 | 310 | { |
311 | 311 | $translator = $this->getServiceManager()->get('translator'); |
312 | 312 | $translated = $translator->translate($text); |
@@ -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 | { |
@@ -11,23 +11,23 @@ discard block |
||
11 | 11 | |
12 | 12 | date_default_timezone_set('Europe/Berlin'); |
13 | 13 | |
14 | -if(!version_compare(PHP_VERSION, '5.6.0', 'ge')){ |
|
15 | - echo sprintf('<p>Sorry, YAWIK requires at least PHP 5.6.0 to run, but this server currently provides PHP %s</p>',PHP_VERSION); |
|
14 | +if (!version_compare(PHP_VERSION, '5.6.0', 'ge')) { |
|
15 | + echo sprintf('<p>Sorry, YAWIK requires at least PHP 5.6.0 to run, but this server currently provides PHP %s</p>', PHP_VERSION); |
|
16 | 16 | echo '<p>Please ask your servers\' administrator to install the proper PHP version.</p>'; |
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
20 | 20 | if (php_sapi_name() == 'cli-server') { |
21 | 21 | $parseUrl = parse_url(substr($_SERVER["REQUEST_URI"], 1)); |
22 | - $route = isset($parseUrl['path']) ? $parseUrl['path']:null; |
|
23 | - if (is_file(__DIR__ . '/' . $route)) { |
|
24 | - if(substr($route, -4) == ".php"){ |
|
25 | - require __DIR__ . '/' . $route; // Include requested script files |
|
22 | + $route = isset($parseUrl['path']) ? $parseUrl['path'] : null; |
|
23 | + if (is_file(__DIR__.'/'.$route)) { |
|
24 | + if (substr($route, -4) == ".php") { |
|
25 | + require __DIR__.'/'.$route; // Include requested script files |
|
26 | 26 | exit; |
27 | 27 | } |
28 | - return false; // Serve file as is |
|
28 | + return false; // Serve file as is |
|
29 | 29 | } else { // Fallback to index.php |
30 | - $_GET["q"] = $route; // Try to emulate the behaviour of a .htaccess here. |
|
30 | + $_GET["q"] = $route; // Try to emulate the behaviour of a .htaccess here. |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | } else { |
48 | 48 | echo '<p>Could not initialize autoloading. This happens, if the dependencies are not installed yet.</p>'; |
49 | 49 | echo '<p>Please try to install the dependencies via: </p>'; |
50 | - echo '<code>cd '. realpath('.') .'<br>./install.sh</code>'; |
|
51 | - echo '<p>exit at ' . __FILE__ . ' in line ' . __LINE__ .'</p>'; |
|
50 | + echo '<code>cd '.realpath('.').'<br>./install.sh</code>'; |
|
51 | + echo '<p>exit at '.__FILE__.' in line '.__LINE__.'</p>'; |
|
52 | 52 | exit; |
53 | 53 | } |
54 | 54 |
@@ -51,6 +51,9 @@ discard block |
||
51 | 51 | $this->summaryFormContext = $scope->getEnvironment()->getContext(SummaryFormContext::class); |
52 | 52 | } |
53 | 53 | |
54 | + /** |
|
55 | + * @param string $name |
|
56 | + */ |
|
54 | 57 | public function generateUrl($name,array $params=array(),array $options=array()) |
55 | 58 | { |
56 | 59 | $defaults = ['lang'=>'en']; |
@@ -71,7 +74,7 @@ discard block |
||
71 | 74 | } |
72 | 75 | |
73 | 76 | /** |
74 | - * @param $id |
|
77 | + * @param string $id |
|
75 | 78 | * @return mixed|object |
76 | 79 | */ |
77 | 80 | public function getService($id) |
@@ -80,7 +83,7 @@ discard block |
||
80 | 83 | } |
81 | 84 | |
82 | 85 | /** |
83 | - * @param $id |
|
86 | + * @param string $id |
|
84 | 87 | * |
85 | 88 | * @return RepositoryInterface |
86 | 89 | */ |
@@ -18,43 +18,43 @@ discard block |
||
18 | 18 | |
19 | 19 | trait CommonContextTrait |
20 | 20 | { |
21 | - /** |
|
22 | - * @var MinkContext |
|
23 | - */ |
|
24 | - protected $minkContext; |
|
21 | + /** |
|
22 | + * @var MinkContext |
|
23 | + */ |
|
24 | + protected $minkContext; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var CoreContext |
|
28 | - */ |
|
29 | - protected $coreContext; |
|
26 | + /** |
|
27 | + * @var CoreContext |
|
28 | + */ |
|
29 | + protected $coreContext; |
|
30 | 30 | |
31 | - /** |
|
32 | - * @var UserContext |
|
33 | - */ |
|
34 | - protected $userContext; |
|
31 | + /** |
|
32 | + * @var UserContext |
|
33 | + */ |
|
34 | + protected $userContext; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var SummaryFormContext |
|
38 | - */ |
|
39 | - protected $summaryFormContext; |
|
36 | + /** |
|
37 | + * @var SummaryFormContext |
|
38 | + */ |
|
39 | + protected $summaryFormContext; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @BeforeScenario |
|
43 | - * |
|
44 | - * @param BeforeScenarioScope $scope |
|
45 | - */ |
|
46 | - public function gatherContexts(BeforeScenarioScope $scope) |
|
47 | - { |
|
48 | - $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
49 | - $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
50 | - $this->userContext = $scope->getEnvironment()->getContext(UserContext::class); |
|
51 | - $this->summaryFormContext = $scope->getEnvironment()->getContext(SummaryFormContext::class); |
|
52 | - } |
|
41 | + /** |
|
42 | + * @BeforeScenario |
|
43 | + * |
|
44 | + * @param BeforeScenarioScope $scope |
|
45 | + */ |
|
46 | + public function gatherContexts(BeforeScenarioScope $scope) |
|
47 | + { |
|
48 | + $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
49 | + $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
50 | + $this->userContext = $scope->getEnvironment()->getContext(UserContext::class); |
|
51 | + $this->summaryFormContext = $scope->getEnvironment()->getContext(SummaryFormContext::class); |
|
52 | + } |
|
53 | 53 | |
54 | - public function generateUrl($name,array $params=array(),array $options=array()) |
|
55 | - { |
|
56 | - $defaults = ['lang'=>'en']; |
|
57 | - $params = array_merge($defaults,$params); |
|
54 | + public function generateUrl($name,array $params=array(),array $options=array()) |
|
55 | + { |
|
56 | + $defaults = ['lang'=>'en']; |
|
57 | + $params = array_merge($defaults,$params); |
|
58 | 58 | /* @var Url $urlHelper */ |
59 | 59 | $urlHelper = $this |
60 | 60 | ->getService('ViewHelperManager') |
@@ -63,36 +63,36 @@ discard block |
||
63 | 63 | $url = $urlHelper($name,$params,$options); |
64 | 64 | |
65 | 65 | return $this->coreContext->generateUrl($url); |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | - public function visit($url) |
|
69 | - { |
|
70 | - $this->coreContext->iVisit($url); |
|
71 | - } |
|
68 | + public function visit($url) |
|
69 | + { |
|
70 | + $this->coreContext->iVisit($url); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param $id |
|
75 | - * @return mixed|object |
|
76 | - */ |
|
77 | - public function getService($id) |
|
78 | - { |
|
79 | - return $this->coreContext->getServiceManager()->get($id); |
|
80 | - } |
|
73 | + /** |
|
74 | + * @param $id |
|
75 | + * @return mixed|object |
|
76 | + */ |
|
77 | + public function getService($id) |
|
78 | + { |
|
79 | + return $this->coreContext->getServiceManager()->get($id); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @param $id |
|
84 | - * |
|
85 | - * @return RepositoryInterface |
|
86 | - */ |
|
87 | - public function getRepository($id) |
|
88 | - { |
|
89 | - return $this->coreContext->getRepositories()->get($id); |
|
90 | - } |
|
82 | + /** |
|
83 | + * @param $id |
|
84 | + * |
|
85 | + * @return RepositoryInterface |
|
86 | + */ |
|
87 | + public function getRepository($id) |
|
88 | + { |
|
89 | + return $this->coreContext->getRepositories()->get($id); |
|
90 | + } |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @return UserContext |
94 | 94 | */ |
95 | - public function getUserContext() |
|
95 | + public function getUserContext() |
|
96 | 96 | { |
97 | 97 | return $this->userContext; |
98 | 98 | } |
@@ -51,16 +51,16 @@ |
||
51 | 51 | $this->summaryFormContext = $scope->getEnvironment()->getContext(SummaryFormContext::class); |
52 | 52 | } |
53 | 53 | |
54 | - public function generateUrl($name,array $params=array(),array $options=array()) |
|
54 | + public function generateUrl($name, array $params = array(), array $options = array()) |
|
55 | 55 | { |
56 | 56 | $defaults = ['lang'=>'en']; |
57 | - $params = array_merge($defaults,$params); |
|
57 | + $params = array_merge($defaults, $params); |
|
58 | 58 | /* @var Url $urlHelper */ |
59 | 59 | $urlHelper = $this |
60 | 60 | ->getService('ViewHelperManager') |
61 | 61 | ->get('url') |
62 | 62 | ; |
63 | - $url = $urlHelper($name,$params,$options); |
|
63 | + $url = $urlHelper($name, $params, $options); |
|
64 | 64 | |
65 | 65 | return $this->coreContext->generateUrl($url); |
66 | 66 | } |
@@ -22,37 +22,37 @@ |
||
22 | 22 | */ |
23 | 23 | class ApplicationContext implements Context |
24 | 24 | { |
25 | - use CommonContextTrait; |
|
25 | + use CommonContextTrait; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @Given I apply for :title job |
|
29 | - * |
|
30 | - * @param string $title |
|
31 | - * @throws \Exception when the titled job not exists |
|
32 | - */ |
|
33 | - public function iApplyAJob($title) |
|
34 | - { |
|
35 | - /* @var $repo JobRepository */ |
|
36 | - $repo = $this->getRepository('Jobs/Job'); |
|
37 | - $job = $repo->findOneBy(['title' => $title]); |
|
38 | - if(!$job instanceof Job){ |
|
39 | - throw new \Exception('There is no job titled: "'.$title.'"'); |
|
40 | - } |
|
41 | - $job->setApplyId($job->getId()); |
|
42 | - $repo->store($job); |
|
27 | + /** |
|
28 | + * @Given I apply for :title job |
|
29 | + * |
|
30 | + * @param string $title |
|
31 | + * @throws \Exception when the titled job not exists |
|
32 | + */ |
|
33 | + public function iApplyAJob($title) |
|
34 | + { |
|
35 | + /* @var $repo JobRepository */ |
|
36 | + $repo = $this->getRepository('Jobs/Job'); |
|
37 | + $job = $repo->findOneBy(['title' => $title]); |
|
38 | + if(!$job instanceof Job){ |
|
39 | + throw new \Exception('There is no job titled: "'.$title.'"'); |
|
40 | + } |
|
41 | + $job->setApplyId($job->getId()); |
|
42 | + $repo->store($job); |
|
43 | 43 | |
44 | - $url = $this->generateUrl('lang/apply',[ |
|
45 | - 'applyId' => $job->getApplyId() |
|
44 | + $url = $this->generateUrl('lang/apply',[ |
|
45 | + 'applyId' => $job->getApplyId() |
|
46 | 46 | ]); |
47 | - $this->visit($url); |
|
48 | - } |
|
47 | + $this->visit($url); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @Given I visit job categories |
|
52 | - */ |
|
53 | - public function visitJobsCategories() |
|
54 | - { |
|
55 | - $url = '/admin/jobs/categories'; |
|
56 | - $this->visit($url); |
|
57 | - } |
|
50 | + /** |
|
51 | + * @Given I visit job categories |
|
52 | + */ |
|
53 | + public function visitJobsCategories() |
|
54 | + { |
|
55 | + $url = '/admin/jobs/categories'; |
|
56 | + $this->visit($url); |
|
57 | + } |
|
58 | 58 | } |
@@ -35,13 +35,13 @@ |
||
35 | 35 | /* @var $repo JobRepository */ |
36 | 36 | $repo = $this->getRepository('Jobs/Job'); |
37 | 37 | $job = $repo->findOneBy(['title' => $title]); |
38 | - if(!$job instanceof Job){ |
|
38 | + if (!$job instanceof Job) { |
|
39 | 39 | throw new \Exception('There is no job titled: "'.$title.'"'); |
40 | 40 | } |
41 | 41 | $job->setApplyId($job->getId()); |
42 | 42 | $repo->store($job); |
43 | 43 | |
44 | - $url = $this->generateUrl('lang/apply',[ |
|
44 | + $url = $this->generateUrl('lang/apply', [ |
|
45 | 45 | 'applyId' => $job->getApplyId() |
46 | 46 | ]); |
47 | 47 | $this->visit($url); |
@@ -23,43 +23,43 @@ |
||
23 | 23 | */ |
24 | 24 | class OrganizationContext implements Context |
25 | 25 | { |
26 | - use CommonContextTrait; |
|
26 | + use CommonContextTrait; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @Given I go to my organization page |
|
30 | - */ |
|
31 | - public function iGoToMyOrganizationPage() |
|
32 | - { |
|
28 | + /** |
|
29 | + * @Given I go to my organization page |
|
30 | + */ |
|
31 | + public function iGoToMyOrganizationPage() |
|
32 | + { |
|
33 | 33 | $url = $this->generateUrl('lang/my-organization'); |
34 | - $this->visit($url); |
|
35 | - } |
|
34 | + $this->visit($url); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @When I hover over name form |
|
39 | - */ |
|
40 | - public function iMouseOverOrganizationNameForm() |
|
41 | - { |
|
42 | - $locator = '#sf-nameForm .sf-summary'; |
|
43 | - $this->coreContext->iHoverOverTheElement($locator); |
|
44 | - } |
|
37 | + /** |
|
38 | + * @When I hover over name form |
|
39 | + */ |
|
40 | + public function iMouseOverOrganizationNameForm() |
|
41 | + { |
|
42 | + $locator = '#sf-nameForm .sf-summary'; |
|
43 | + $this->coreContext->iHoverOverTheElement($locator); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @Given I go to create new organization page |
|
48 | - */ |
|
49 | - public function iGoToCreateNewOrganizationPage() |
|
50 | - { |
|
51 | - //$this->visit('/organizations/edit'); |
|
46 | + /** |
|
47 | + * @Given I go to create new organization page |
|
48 | + */ |
|
49 | + public function iGoToCreateNewOrganizationPage() |
|
50 | + { |
|
51 | + //$this->visit('/organizations/edit'); |
|
52 | 52 | $url = $this->generateUrl('lang/organizations/edit'); |
53 | 53 | $this->visit($url); |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @Given I go to organization overview page |
|
58 | - */ |
|
59 | - public function iGoToOrganizationOverviewPage() |
|
60 | - { |
|
61 | - //$this->visit('/organizations'); |
|
62 | - $url = $this->generateUrl('lang/organizations'); |
|
63 | - $this->visit($url); |
|
64 | - } |
|
56 | + /** |
|
57 | + * @Given I go to organization overview page |
|
58 | + */ |
|
59 | + public function iGoToOrganizationOverviewPage() |
|
60 | + { |
|
61 | + //$this->visit('/organizations'); |
|
62 | + $url = $this->generateUrl('lang/organizations'); |
|
63 | + $this->visit($url); |
|
64 | + } |
|
65 | 65 | } |
@@ -22,23 +22,23 @@ |
||
22 | 22 | */ |
23 | 23 | class CvContext implements Context |
24 | 24 | { |
25 | - use CommonContextTrait; |
|
25 | + use CommonContextTrait; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * @Given I go to manage my resume page |
|
30 | - */ |
|
31 | - public function iGoToManageResumePage() |
|
32 | - { |
|
33 | - $url = $this->generateUrl('lang/my-cv'); |
|
34 | - $this->visit($url); |
|
35 | - } |
|
28 | + /** |
|
29 | + * @Given I go to manage my resume page |
|
30 | + */ |
|
31 | + public function iGoToManageResumePage() |
|
32 | + { |
|
33 | + $url = $this->generateUrl('lang/my-cv'); |
|
34 | + $this->visit($url); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @When I click edit on my personal information |
|
39 | - */ |
|
40 | - public function iClickEditOnPersonalInformations() |
|
41 | - { |
|
42 | - $this->summaryFormContext->iClickEditOnForm('resumePersonalInformations'); |
|
43 | - } |
|
37 | + /** |
|
38 | + * @When I click edit on my personal information |
|
39 | + */ |
|
40 | + public function iClickEditOnPersonalInformations() |
|
41 | + { |
|
42 | + $this->summaryFormContext->iClickEditOnForm('resumePersonalInformations'); |
|
43 | + } |
|
44 | 44 | } |
@@ -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 | } |
@@ -37,384 +37,384 @@ |
||
37 | 37 | { |
38 | 38 | use CommonContextTrait; |
39 | 39 | |
40 | - /** |
|
41 | - * @var User[] |
|
42 | - */ |
|
43 | - static private $users = []; |
|
40 | + /** |
|
41 | + * @var User[] |
|
42 | + */ |
|
43 | + static private $users = []; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @var UserRepository |
|
47 | - */ |
|
48 | - static private $userRepo; |
|
45 | + /** |
|
46 | + * @var UserRepository |
|
47 | + */ |
|
48 | + static private $userRepo; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @var string |
|
52 | - */ |
|
53 | - static private $currentSession; |
|
50 | + /** |
|
51 | + * @var string |
|
52 | + */ |
|
53 | + static private $currentSession; |
|
54 | 54 | |
55 | - private $socialLoginInfo = []; |
|
55 | + private $socialLoginInfo = []; |
|
56 | 56 | |
57 | - /** |
|
58 | - * @var UserInterface |
|
59 | - */ |
|
60 | - private $loggedInUser; |
|
57 | + /** |
|
58 | + * @var UserInterface |
|
59 | + */ |
|
60 | + private $loggedInUser; |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @var User |
64 | 64 | */ |
65 | 65 | protected $currentUser; |
66 | 66 | |
67 | - public function __construct($parameters=[]) |
|
68 | - { |
|
69 | - $defaultLoginInfo = [ |
|
70 | - 'facebook' => [ |
|
71 | - 'email' => getenv('FACEBOOK_USER_EMAIL'), |
|
72 | - 'pass' => getenv('FACEBOOK_USER_PASSWORD') |
|
73 | - ], |
|
74 | - 'linkedin' => [ |
|
75 | - 'session_key-login' => getenv('LINKEDIN_USER_EMAIL'), |
|
76 | - 'session_password-login' => getenv('LINKEDIN_USER_PASSWORD') |
|
77 | - ], |
|
78 | - ]; |
|
79 | - $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[]; |
|
80 | - $this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig); |
|
81 | - } |
|
67 | + public function __construct($parameters=[]) |
|
68 | + { |
|
69 | + $defaultLoginInfo = [ |
|
70 | + 'facebook' => [ |
|
71 | + 'email' => getenv('FACEBOOK_USER_EMAIL'), |
|
72 | + 'pass' => getenv('FACEBOOK_USER_PASSWORD') |
|
73 | + ], |
|
74 | + 'linkedin' => [ |
|
75 | + 'session_key-login' => getenv('LINKEDIN_USER_EMAIL'), |
|
76 | + 'session_password-login' => getenv('LINKEDIN_USER_PASSWORD') |
|
77 | + ], |
|
78 | + ]; |
|
79 | + $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[]; |
|
80 | + $this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @AfterSuite |
|
85 | - * @param AfterSuiteScope $scope |
|
86 | - */ |
|
87 | - static public function afterSuite(AfterSuiteScope $scope) |
|
88 | - { |
|
89 | - $repo = static::$userRepo; |
|
90 | - foreach(static::$users as $user){ |
|
91 | - if($repo->findByLogin($user->getLogin())){ |
|
92 | - try{ |
|
93 | - JobContext::removeJobByUser($user); |
|
94 | - $repo->remove($user,true); |
|
95 | - }catch (\Exception $e){ |
|
83 | + /** |
|
84 | + * @AfterSuite |
|
85 | + * @param AfterSuiteScope $scope |
|
86 | + */ |
|
87 | + static public function afterSuite(AfterSuiteScope $scope) |
|
88 | + { |
|
89 | + $repo = static::$userRepo; |
|
90 | + foreach(static::$users as $user){ |
|
91 | + if($repo->findByLogin($user->getLogin())){ |
|
92 | + try{ |
|
93 | + JobContext::removeJobByUser($user); |
|
94 | + $repo->remove($user,true); |
|
95 | + }catch (\Exception $e){ |
|
96 | 96 | |
97 | - } |
|
98 | - } |
|
99 | - } |
|
100 | - } |
|
97 | + } |
|
98 | + } |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * @BeforeScenario |
|
104 | - * @param BeforeScenarioScope $scope |
|
105 | - */ |
|
106 | - public function beforeScenario(BeforeScenarioScope $scope) |
|
107 | - { |
|
108 | - $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
109 | - $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
110 | - static::$userRepo = $this->getUserRepository(); |
|
111 | - } |
|
102 | + /** |
|
103 | + * @BeforeScenario |
|
104 | + * @param BeforeScenarioScope $scope |
|
105 | + */ |
|
106 | + public function beforeScenario(BeforeScenarioScope $scope) |
|
107 | + { |
|
108 | + $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
109 | + $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
110 | + static::$userRepo = $this->getUserRepository(); |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * @When I fill in login form with :provider user |
|
115 | - */ |
|
116 | - public function iSignInWithSocialUser($provider) |
|
117 | - { |
|
118 | - $provider = strtolower($provider); |
|
119 | - $mink = $this->minkContext; |
|
120 | - foreach($this->socialLoginInfo[$provider] as $field=>$value){ |
|
121 | - $mink->fillField($field,$value); |
|
122 | - } |
|
123 | - } |
|
113 | + /** |
|
114 | + * @When I fill in login form with :provider user |
|
115 | + */ |
|
116 | + public function iSignInWithSocialUser($provider) |
|
117 | + { |
|
118 | + $provider = strtolower($provider); |
|
119 | + $mink = $this->minkContext; |
|
120 | + foreach($this->socialLoginInfo[$provider] as $field=>$value){ |
|
121 | + $mink->fillField($field,$value); |
|
122 | + } |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * @Given I am logged in as a recruiter |
|
127 | - * @Given I am logged in as a recruiter with :organization as organization |
|
128 | - */ |
|
129 | - public function iAmLoggedInAsARecruiter($organization=null) |
|
130 | - { |
|
131 | - $user = $this->thereIsAUserIdentifiedBy( |
|
132 | - '[email protected]', |
|
133 | - 'test',User::ROLE_RECRUITER, |
|
134 | - 'Test Recruiter', |
|
135 | - $organization |
|
136 | - ); |
|
137 | - $this->startLogin($user,'test'); |
|
138 | - } |
|
125 | + /** |
|
126 | + * @Given I am logged in as a recruiter |
|
127 | + * @Given I am logged in as a recruiter with :organization as organization |
|
128 | + */ |
|
129 | + public function iAmLoggedInAsARecruiter($organization=null) |
|
130 | + { |
|
131 | + $user = $this->thereIsAUserIdentifiedBy( |
|
132 | + '[email protected]', |
|
133 | + 'test',User::ROLE_RECRUITER, |
|
134 | + 'Test Recruiter', |
|
135 | + $organization |
|
136 | + ); |
|
137 | + $this->startLogin($user,'test'); |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * @Given I don't have :login user |
|
142 | - * @param string $login |
|
143 | - */ |
|
144 | - public function iDonTHaveUser($login) |
|
145 | - { |
|
146 | - $repo = $this->getUserRepository(); |
|
147 | - $user=$repo->findByLogin($login); |
|
148 | - if($user instanceof UserInterface){ |
|
149 | - $repo->remove($user,true); |
|
150 | - } |
|
151 | - } |
|
140 | + /** |
|
141 | + * @Given I don't have :login user |
|
142 | + * @param string $login |
|
143 | + */ |
|
144 | + public function iDonTHaveUser($login) |
|
145 | + { |
|
146 | + $repo = $this->getUserRepository(); |
|
147 | + $user=$repo->findByLogin($login); |
|
148 | + if($user instanceof UserInterface){ |
|
149 | + $repo->remove($user,true); |
|
150 | + } |
|
151 | + } |
|
152 | 152 | |
153 | - /** |
|
154 | - * @Given I have a :role with the following: |
|
155 | - * @param $role |
|
156 | - * @param TableNode $fields |
|
157 | - */ |
|
158 | - public function iHaveUserWithTheFollowing($role,TableNode $fields) |
|
159 | - { |
|
160 | - $normalizedFields = [ |
|
161 | - 'login' => '[email protected]', |
|
162 | - 'fullname' => 'Test Login', |
|
163 | - 'role' => User::ROLE_USER, |
|
164 | - 'password' => 'test', |
|
165 | - 'organization' => 'Cross Solution' |
|
166 | - ]; |
|
167 | - foreach($fields->getRowsHash() as $field=>$value){ |
|
168 | - $field = Inflector::camelize($field); |
|
169 | - $normalizedFields[$field] = $value; |
|
170 | - } |
|
153 | + /** |
|
154 | + * @Given I have a :role with the following: |
|
155 | + * @param $role |
|
156 | + * @param TableNode $fields |
|
157 | + */ |
|
158 | + public function iHaveUserWithTheFollowing($role,TableNode $fields) |
|
159 | + { |
|
160 | + $normalizedFields = [ |
|
161 | + 'login' => '[email protected]', |
|
162 | + 'fullname' => 'Test Login', |
|
163 | + 'role' => User::ROLE_USER, |
|
164 | + 'password' => 'test', |
|
165 | + 'organization' => 'Cross Solution' |
|
166 | + ]; |
|
167 | + foreach($fields->getRowsHash() as $field=>$value){ |
|
168 | + $field = Inflector::camelize($field); |
|
169 | + $normalizedFields[$field] = $value; |
|
170 | + } |
|
171 | 171 | |
172 | - $this->thereIsAUserIdentifiedBy( |
|
173 | - $normalizedFields['login'], |
|
174 | - $normalizedFields['password'], |
|
175 | - $role, |
|
176 | - $normalizedFields['fullname'], |
|
177 | - $normalizedFields['organization'] |
|
178 | - ); |
|
172 | + $this->thereIsAUserIdentifiedBy( |
|
173 | + $normalizedFields['login'], |
|
174 | + $normalizedFields['password'], |
|
175 | + $role, |
|
176 | + $normalizedFields['fullname'], |
|
177 | + $normalizedFields['organization'] |
|
178 | + ); |
|
179 | 179 | |
180 | - } |
|
180 | + } |
|
181 | 181 | |
182 | - /** |
|
183 | - * @Given I am logged in as an administrator |
|
184 | - */ |
|
185 | - public function iAmLoggedInAsAnAdmin() |
|
186 | - { |
|
187 | - $user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN); |
|
188 | - $this->startLogin($user,'test'); |
|
189 | - } |
|
182 | + /** |
|
183 | + * @Given I am logged in as an administrator |
|
184 | + */ |
|
185 | + public function iAmLoggedInAsAnAdmin() |
|
186 | + { |
|
187 | + $user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN); |
|
188 | + $this->startLogin($user,'test'); |
|
189 | + } |
|
190 | 190 | |
191 | - private function startLogin(UserInterface $user, $password) |
|
192 | - { |
|
193 | - $currentUser = $this->currentUser; |
|
194 | - if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){ |
|
195 | - $this->iWantToLogIn(); |
|
196 | - $this->iSpecifyTheUsernameAs($user->getLogin()); |
|
197 | - $this->iSpecifyThePasswordAs($password); |
|
198 | - $this->iLogIn(); |
|
199 | - $this->currentUser = $user; |
|
200 | - } |
|
201 | - } |
|
191 | + private function startLogin(UserInterface $user, $password) |
|
192 | + { |
|
193 | + $currentUser = $this->currentUser; |
|
194 | + if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){ |
|
195 | + $this->iWantToLogIn(); |
|
196 | + $this->iSpecifyTheUsernameAs($user->getLogin()); |
|
197 | + $this->iSpecifyThePasswordAs($password); |
|
198 | + $this->iLogIn(); |
|
199 | + $this->currentUser = $user; |
|
200 | + } |
|
201 | + } |
|
202 | 202 | |
203 | - /** |
|
204 | - * @return UserRepository |
|
205 | - */ |
|
206 | - public function getUserRepository() |
|
207 | - { |
|
208 | - return $this->coreContext->getRepositories()->get('Auth\Entity\User'); |
|
209 | - } |
|
203 | + /** |
|
204 | + * @return UserRepository |
|
205 | + */ |
|
206 | + public function getUserRepository() |
|
207 | + { |
|
208 | + return $this->coreContext->getRepositories()->get('Auth\Entity\User'); |
|
209 | + } |
|
210 | 210 | |
211 | - /** |
|
212 | - * @Given there is a user :email identified by :password |
|
213 | - */ |
|
214 | - public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null) |
|
215 | - { |
|
216 | - $repo = $this->getUserRepository(); |
|
217 | - if(!is_object($user=$repo->findByEmail($email))){ |
|
218 | - $user = $this->createUser($email,$password,$role,$fullname,$organization); |
|
219 | - } |
|
211 | + /** |
|
212 | + * @Given there is a user :email identified by :password |
|
213 | + */ |
|
214 | + public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null) |
|
215 | + { |
|
216 | + $repo = $this->getUserRepository(); |
|
217 | + if(!is_object($user=$repo->findByEmail($email))){ |
|
218 | + $user = $this->createUser($email,$password,$role,$fullname,$organization); |
|
219 | + } |
|
220 | 220 | |
221 | - if(!is_null($organization)){ |
|
222 | - $this->iHaveMainOrganization($user,$organization); |
|
223 | - } |
|
224 | - $this->addCreatedUser($user); |
|
225 | - return $user; |
|
226 | - } |
|
221 | + if(!is_null($organization)){ |
|
222 | + $this->iHaveMainOrganization($user,$organization); |
|
223 | + } |
|
224 | + $this->addCreatedUser($user); |
|
225 | + return $user; |
|
226 | + } |
|
227 | 227 | |
228 | - /** |
|
229 | - * @param $email |
|
230 | - * @param $password |
|
231 | - * @param $username |
|
232 | - * @param string $fullname |
|
233 | - * @param string $role |
|
234 | - * |
|
235 | - * @return \Auth\Entity\UserInterface |
|
236 | - */ |
|
237 | - public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter") |
|
238 | - { |
|
239 | - /* @var Register $service */ |
|
240 | - /* @var User $user */ |
|
241 | - $repo = $this->getUserRepository(); |
|
242 | - $user = $repo->create([]); |
|
243 | - $user->setLogin($email); |
|
244 | - $user->setPassword($password); |
|
245 | - $user->setRole($role); |
|
246 | - $settings = $user->getSettings('Applications'); |
|
228 | + /** |
|
229 | + * @param $email |
|
230 | + * @param $password |
|
231 | + * @param $username |
|
232 | + * @param string $fullname |
|
233 | + * @param string $role |
|
234 | + * |
|
235 | + * @return \Auth\Entity\UserInterface |
|
236 | + */ |
|
237 | + public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter") |
|
238 | + { |
|
239 | + /* @var Register $service */ |
|
240 | + /* @var User $user */ |
|
241 | + $repo = $this->getUserRepository(); |
|
242 | + $user = $repo->create([]); |
|
243 | + $user->setLogin($email); |
|
244 | + $user->setPassword($password); |
|
245 | + $user->setRole($role); |
|
246 | + $settings = $user->getSettings('Applications'); |
|
247 | 247 | |
248 | - $expFullName = explode(' ',$fullname); |
|
249 | - $info = $user->getInfo(); |
|
250 | - $info->setFirstName(array_shift($expFullName)); |
|
251 | - $info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):''); |
|
252 | - $info->setEmail($email); |
|
253 | - $info->setEmailVerified(true); |
|
254 | - $repo->store($user); |
|
255 | - $repo->getDocumentManager()->refresh($user); |
|
248 | + $expFullName = explode(' ',$fullname); |
|
249 | + $info = $user->getInfo(); |
|
250 | + $info->setFirstName(array_shift($expFullName)); |
|
251 | + $info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):''); |
|
252 | + $info->setEmail($email); |
|
253 | + $info->setEmailVerified(true); |
|
254 | + $repo->store($user); |
|
255 | + $repo->getDocumentManager()->refresh($user); |
|
256 | 256 | |
257 | - $eventArgs = new LifecycleEventArgs($user, $repo->getDocumentManager()); |
|
258 | - $repo->getDocumentManager()->getEventManager()->dispatchEvent( |
|
259 | - Events::postLoad, |
|
260 | - $eventArgs |
|
261 | - ); |
|
262 | - /* @var \Core\EventManager\EventManager $events */ |
|
263 | - /* @var \Auth\Listener\Events\AuthEvent $event */ |
|
264 | - //@TODO: [Behat] event not working in travis |
|
265 | - //$events = $this->coreContext->getEventManager(); |
|
266 | - //$event = $events->getEvent(AuthEvent::EVENT_USER_REGISTERED, $this); |
|
267 | - //$event->setUser($user); |
|
268 | - //$events->triggerEvent($event); |
|
269 | - return $user; |
|
270 | - } |
|
257 | + $eventArgs = new LifecycleEventArgs($user, $repo->getDocumentManager()); |
|
258 | + $repo->getDocumentManager()->getEventManager()->dispatchEvent( |
|
259 | + Events::postLoad, |
|
260 | + $eventArgs |
|
261 | + ); |
|
262 | + /* @var \Core\EventManager\EventManager $events */ |
|
263 | + /* @var \Auth\Listener\Events\AuthEvent $event */ |
|
264 | + //@TODO: [Behat] event not working in travis |
|
265 | + //$events = $this->coreContext->getEventManager(); |
|
266 | + //$event = $events->getEvent(AuthEvent::EVENT_USER_REGISTERED, $this); |
|
267 | + //$event->setUser($user); |
|
268 | + //$events->triggerEvent($event); |
|
269 | + return $user; |
|
270 | + } |
|
271 | 271 | |
272 | - /** |
|
273 | - * @When I have :organization as my main organization |
|
274 | - * @param $orgName |
|
275 | - */ |
|
276 | - public function iHaveMainOrganization(UserInterface $user,$orgName) |
|
277 | - { |
|
278 | - /* @var $repoOrganization OrganizationRepository */ |
|
279 | - $repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization'); |
|
280 | - $organization=$repoOrganization->findByName($orgName); |
|
281 | - if(!$organization instanceof Organization){ |
|
282 | - $organization = new Organization(); |
|
283 | - $organizationName = new OrganizationName($orgName); |
|
284 | - $organization->setOrganizationName($organizationName); |
|
285 | - $permissions = $organization->getPermissions(); |
|
286 | - $permissions->grant($user,Permissions::PERMISSION_ALL); |
|
287 | - }else { |
|
288 | - $organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL); |
|
289 | - } |
|
290 | - $organization->setUser($user); |
|
291 | - $repoOrganization->store($organization); |
|
292 | - $repoOrganization->getDocumentManager()->refresh($organization); |
|
293 | - } |
|
272 | + /** |
|
273 | + * @When I have :organization as my main organization |
|
274 | + * @param $orgName |
|
275 | + */ |
|
276 | + public function iHaveMainOrganization(UserInterface $user,$orgName) |
|
277 | + { |
|
278 | + /* @var $repoOrganization OrganizationRepository */ |
|
279 | + $repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization'); |
|
280 | + $organization=$repoOrganization->findByName($orgName); |
|
281 | + if(!$organization instanceof Organization){ |
|
282 | + $organization = new Organization(); |
|
283 | + $organizationName = new OrganizationName($orgName); |
|
284 | + $organization->setOrganizationName($organizationName); |
|
285 | + $permissions = $organization->getPermissions(); |
|
286 | + $permissions->grant($user,Permissions::PERMISSION_ALL); |
|
287 | + }else { |
|
288 | + $organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL); |
|
289 | + } |
|
290 | + $organization->setUser($user); |
|
291 | + $repoOrganization->store($organization); |
|
292 | + $repoOrganization->getDocumentManager()->refresh($organization); |
|
293 | + } |
|
294 | 294 | |
295 | - /** |
|
296 | - * @When I want to log in |
|
297 | - */ |
|
298 | - public function iWantToLogIn() |
|
299 | - { |
|
300 | - $session = $this->minkContext->getSession(); |
|
301 | - $url = $this->generateUrl('lang/auth'); |
|
302 | - $session->visit($url); |
|
303 | - } |
|
295 | + /** |
|
296 | + * @When I want to log in |
|
297 | + */ |
|
298 | + public function iWantToLogIn() |
|
299 | + { |
|
300 | + $session = $this->minkContext->getSession(); |
|
301 | + $url = $this->generateUrl('lang/auth'); |
|
302 | + $session->visit($url); |
|
303 | + } |
|
304 | 304 | |
305 | - /** |
|
306 | - * @When I specify the username as :username |
|
307 | - */ |
|
308 | - public function iSpecifyTheUsernameAs($username) |
|
309 | - { |
|
310 | - $this->minkContext->fillField('Login name',$username); |
|
311 | - } |
|
305 | + /** |
|
306 | + * @When I specify the username as :username |
|
307 | + */ |
|
308 | + public function iSpecifyTheUsernameAs($username) |
|
309 | + { |
|
310 | + $this->minkContext->fillField('Login name',$username); |
|
311 | + } |
|
312 | 312 | |
313 | - /** |
|
314 | - * @When I specify the password as :password |
|
315 | - */ |
|
316 | - public function iSpecifyThePasswordAs($password) |
|
317 | - { |
|
318 | - $this->minkContext->fillField('Password',$password); |
|
319 | - } |
|
313 | + /** |
|
314 | + * @When I specify the password as :password |
|
315 | + */ |
|
316 | + public function iSpecifyThePasswordAs($password) |
|
317 | + { |
|
318 | + $this->minkContext->fillField('Password',$password); |
|
319 | + } |
|
320 | 320 | |
321 | - /** |
|
322 | - * @Given I am logged in as :username identified by :password |
|
323 | - */ |
|
324 | - public function iAmLoggedInAsIdentifiedBy($username, $password) |
|
325 | - { |
|
326 | - $repo = $this->getUserRepository(); |
|
327 | - $user = $repo->findByLogin($username); |
|
321 | + /** |
|
322 | + * @Given I am logged in as :username identified by :password |
|
323 | + */ |
|
324 | + public function iAmLoggedInAsIdentifiedBy($username, $password) |
|
325 | + { |
|
326 | + $repo = $this->getUserRepository(); |
|
327 | + $user = $repo->findByLogin($username); |
|
328 | 328 | |
329 | - if(!$user instanceof User){ |
|
330 | - throw new \Exception(sprintf('There is no user with this login: "%s"',$username)); |
|
331 | - } |
|
332 | - $this->iWantToLogIn(); |
|
333 | - $this->iSpecifyTheUsernameAs($username); |
|
334 | - $this->iSpecifyThePasswordAs($password); |
|
335 | - $this->iLogIn(); |
|
329 | + if(!$user instanceof User){ |
|
330 | + throw new \Exception(sprintf('There is no user with this login: "%s"',$username)); |
|
331 | + } |
|
332 | + $this->iWantToLogIn(); |
|
333 | + $this->iSpecifyTheUsernameAs($username); |
|
334 | + $this->iSpecifyThePasswordAs($password); |
|
335 | + $this->iLogIn(); |
|
336 | 336 | $this->currentUser = $user; |
337 | - } |
|
337 | + } |
|
338 | 338 | |
339 | - /** |
|
340 | - * @When I log in |
|
341 | - */ |
|
342 | - public function iLogIn() |
|
343 | - { |
|
344 | - $this->minkContext->pressButton('login'); |
|
345 | - } |
|
339 | + /** |
|
340 | + * @When I log in |
|
341 | + */ |
|
342 | + public function iLogIn() |
|
343 | + { |
|
344 | + $this->minkContext->pressButton('login'); |
|
345 | + } |
|
346 | 346 | |
347 | - /** |
|
348 | - * @When I press logout link |
|
349 | - */ |
|
350 | - public function iPressLogoutLink() |
|
351 | - { |
|
352 | - $url = $this->generateUrl('auth-logout'); |
|
353 | - $this->visit($url); |
|
354 | - } |
|
347 | + /** |
|
348 | + * @When I press logout link |
|
349 | + */ |
|
350 | + public function iPressLogoutLink() |
|
351 | + { |
|
352 | + $url = $this->generateUrl('auth-logout'); |
|
353 | + $this->visit($url); |
|
354 | + } |
|
355 | 355 | |
356 | - /** |
|
357 | - * @Given I log in with username :username and password :password |
|
358 | - */ |
|
359 | - public function iLogInWith($username, $password) |
|
360 | - { |
|
361 | - $repo = $this->getUserRepository(); |
|
362 | - $user = $repo->findByLogin($username); |
|
363 | - $this->iWantToLogIn(); |
|
364 | - $this->iSpecifyTheUsernameAs($username); |
|
365 | - $this->iSpecifyThePasswordAs($password); |
|
366 | - $this->iLogIn(); |
|
367 | - $this->loggedInUser = $user; |
|
368 | - } |
|
356 | + /** |
|
357 | + * @Given I log in with username :username and password :password |
|
358 | + */ |
|
359 | + public function iLogInWith($username, $password) |
|
360 | + { |
|
361 | + $repo = $this->getUserRepository(); |
|
362 | + $user = $repo->findByLogin($username); |
|
363 | + $this->iWantToLogIn(); |
|
364 | + $this->iSpecifyTheUsernameAs($username); |
|
365 | + $this->iSpecifyThePasswordAs($password); |
|
366 | + $this->iLogIn(); |
|
367 | + $this->loggedInUser = $user; |
|
368 | + } |
|
369 | 369 | |
370 | - /** |
|
371 | - * @When I go to profile page |
|
372 | - */ |
|
373 | - public function iGoToProfilePage() |
|
374 | - { |
|
375 | - $url = $this->generateUrl('lang/my'); |
|
376 | - $this->visit($url); |
|
377 | - } |
|
370 | + /** |
|
371 | + * @When I go to profile page |
|
372 | + */ |
|
373 | + public function iGoToProfilePage() |
|
374 | + { |
|
375 | + $url = $this->generateUrl('lang/my'); |
|
376 | + $this->visit($url); |
|
377 | + } |
|
378 | 378 | |
379 | - /** |
|
380 | - * @Given there is a user with the following: |
|
381 | - */ |
|
382 | - public function thereIsAUserWithTheFollowing(TableNode $table) |
|
383 | - { |
|
384 | - $repo = $this->getUserRepository(); |
|
385 | - $data = $table->getRowsHash(); |
|
386 | - $email = isset($data['email']) ? $data['email']:'[email protected]'; |
|
387 | - $password = isset($data['password']) ? $data['password']:'test'; |
|
388 | - $fullname = isset($data['fullname']) ? $data['fullname']:'Test User'; |
|
389 | - $role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER; |
|
379 | + /** |
|
380 | + * @Given there is a user with the following: |
|
381 | + */ |
|
382 | + public function thereIsAUserWithTheFollowing(TableNode $table) |
|
383 | + { |
|
384 | + $repo = $this->getUserRepository(); |
|
385 | + $data = $table->getRowsHash(); |
|
386 | + $email = isset($data['email']) ? $data['email']:'[email protected]'; |
|
387 | + $password = isset($data['password']) ? $data['password']:'test'; |
|
388 | + $fullname = isset($data['fullname']) ? $data['fullname']:'Test User'; |
|
389 | + $role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER; |
|
390 | 390 | |
391 | - if(!is_object($user=$repo->findByLogin($email))){ |
|
392 | - $user = $this->createUser($email,$password,$role,$fullname); |
|
393 | - } |
|
394 | - $this->currentUser = $user; |
|
395 | - $this->addCreatedUser($user); |
|
396 | - } |
|
391 | + if(!is_object($user=$repo->findByLogin($email))){ |
|
392 | + $user = $this->createUser($email,$password,$role,$fullname); |
|
393 | + } |
|
394 | + $this->currentUser = $user; |
|
395 | + $this->addCreatedUser($user); |
|
396 | + } |
|
397 | 397 | |
398 | - private function addCreatedUser(UserInterface $user) |
|
399 | - { |
|
400 | - if(!in_array($user,static::$users)){ |
|
401 | - static::$users[] = $user; |
|
402 | - } |
|
403 | - } |
|
398 | + private function addCreatedUser(UserInterface $user) |
|
399 | + { |
|
400 | + if(!in_array($user,static::$users)){ |
|
401 | + static::$users[] = $user; |
|
402 | + } |
|
403 | + } |
|
404 | 404 | |
405 | - /** |
|
406 | - * @When I want to change my password |
|
407 | - */ |
|
408 | - public function iWantToChangeMyPassword() |
|
409 | - { |
|
410 | - $url = $this->generateUrl('lang/my-password'); |
|
411 | - $this->visit($url); |
|
412 | - } |
|
405 | + /** |
|
406 | + * @When I want to change my password |
|
407 | + */ |
|
408 | + public function iWantToChangeMyPassword() |
|
409 | + { |
|
410 | + $url = $this->generateUrl('lang/my-password'); |
|
411 | + $this->visit($url); |
|
412 | + } |
|
413 | 413 | |
414 | 414 | /** |
415 | 415 | * @return User |
416 | 416 | */ |
417 | - public function getCurrentUser() |
|
417 | + public function getCurrentUser() |
|
418 | 418 | { |
419 | 419 | return $this->currentUser; |
420 | 420 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | protected $currentUser; |
66 | 66 | |
67 | - public function __construct($parameters=[]) |
|
67 | + public function __construct($parameters = []) |
|
68 | 68 | { |
69 | 69 | $defaultLoginInfo = [ |
70 | 70 | 'facebook' => [ |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | 'session_password-login' => getenv('LINKEDIN_USER_PASSWORD') |
77 | 77 | ], |
78 | 78 | ]; |
79 | - $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[]; |
|
80 | - $this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig); |
|
79 | + $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info'] : []; |
|
80 | + $this->socialLoginInfo = array_merge($defaultLoginInfo, $socialLoginConfig); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | static public function afterSuite(AfterSuiteScope $scope) |
88 | 88 | { |
89 | 89 | $repo = static::$userRepo; |
90 | - foreach(static::$users as $user){ |
|
91 | - if($repo->findByLogin($user->getLogin())){ |
|
92 | - try{ |
|
90 | + foreach (static::$users as $user) { |
|
91 | + if ($repo->findByLogin($user->getLogin())) { |
|
92 | + try { |
|
93 | 93 | JobContext::removeJobByUser($user); |
94 | - $repo->remove($user,true); |
|
95 | - }catch (\Exception $e){ |
|
94 | + $repo->remove($user, true); |
|
95 | + } catch (\Exception $e) { |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | } |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | { |
118 | 118 | $provider = strtolower($provider); |
119 | 119 | $mink = $this->minkContext; |
120 | - foreach($this->socialLoginInfo[$provider] as $field=>$value){ |
|
121 | - $mink->fillField($field,$value); |
|
120 | + foreach ($this->socialLoginInfo[$provider] as $field=>$value) { |
|
121 | + $mink->fillField($field, $value); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | * @Given I am logged in as a recruiter |
127 | 127 | * @Given I am logged in as a recruiter with :organization as organization |
128 | 128 | */ |
129 | - public function iAmLoggedInAsARecruiter($organization=null) |
|
129 | + public function iAmLoggedInAsARecruiter($organization = null) |
|
130 | 130 | { |
131 | 131 | $user = $this->thereIsAUserIdentifiedBy( |
132 | 132 | '[email protected]', |
133 | - 'test',User::ROLE_RECRUITER, |
|
133 | + 'test', User::ROLE_RECRUITER, |
|
134 | 134 | 'Test Recruiter', |
135 | 135 | $organization |
136 | 136 | ); |
137 | - $this->startLogin($user,'test'); |
|
137 | + $this->startLogin($user, 'test'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | public function iDonTHaveUser($login) |
145 | 145 | { |
146 | 146 | $repo = $this->getUserRepository(); |
147 | - $user=$repo->findByLogin($login); |
|
148 | - if($user instanceof UserInterface){ |
|
149 | - $repo->remove($user,true); |
|
147 | + $user = $repo->findByLogin($login); |
|
148 | + if ($user instanceof UserInterface) { |
|
149 | + $repo->remove($user, true); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param $role |
156 | 156 | * @param TableNode $fields |
157 | 157 | */ |
158 | - public function iHaveUserWithTheFollowing($role,TableNode $fields) |
|
158 | + public function iHaveUserWithTheFollowing($role, TableNode $fields) |
|
159 | 159 | { |
160 | 160 | $normalizedFields = [ |
161 | 161 | 'login' => '[email protected]', |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | 'password' => 'test', |
165 | 165 | 'organization' => 'Cross Solution' |
166 | 166 | ]; |
167 | - foreach($fields->getRowsHash() as $field=>$value){ |
|
167 | + foreach ($fields->getRowsHash() as $field=>$value) { |
|
168 | 168 | $field = Inflector::camelize($field); |
169 | 169 | $normalizedFields[$field] = $value; |
170 | 170 | } |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function iAmLoggedInAsAnAdmin() |
186 | 186 | { |
187 | - $user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN); |
|
188 | - $this->startLogin($user,'test'); |
|
187 | + $user = $this->thereIsAUserIdentifiedBy('[email protected]', 'test', User::ROLE_ADMIN); |
|
188 | + $this->startLogin($user, 'test'); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | private function startLogin(UserInterface $user, $password) |
192 | 192 | { |
193 | 193 | $currentUser = $this->currentUser; |
194 | - if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){ |
|
194 | + if (!is_object($currentUser) || $user->getId() != $currentUser->getId()) { |
|
195 | 195 | $this->iWantToLogIn(); |
196 | 196 | $this->iSpecifyTheUsernameAs($user->getLogin()); |
197 | 197 | $this->iSpecifyThePasswordAs($password); |
@@ -211,15 +211,15 @@ discard block |
||
211 | 211 | /** |
212 | 212 | * @Given there is a user :email identified by :password |
213 | 213 | */ |
214 | - public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null) |
|
214 | + public function thereIsAUserIdentifiedBy($email, $password, $role = User::ROLE_RECRUITER, $fullname = "Test Recruiter", $organization = null) |
|
215 | 215 | { |
216 | 216 | $repo = $this->getUserRepository(); |
217 | - if(!is_object($user=$repo->findByEmail($email))){ |
|
218 | - $user = $this->createUser($email,$password,$role,$fullname,$organization); |
|
217 | + if (!is_object($user = $repo->findByEmail($email))) { |
|
218 | + $user = $this->createUser($email, $password, $role, $fullname, $organization); |
|
219 | 219 | } |
220 | 220 | |
221 | - if(!is_null($organization)){ |
|
222 | - $this->iHaveMainOrganization($user,$organization); |
|
221 | + if (!is_null($organization)) { |
|
222 | + $this->iHaveMainOrganization($user, $organization); |
|
223 | 223 | } |
224 | 224 | $this->addCreatedUser($user); |
225 | 225 | return $user; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return \Auth\Entity\UserInterface |
236 | 236 | */ |
237 | - public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter") |
|
237 | + public function createUser($email, $password, $role = User::ROLE_RECRUITER, $fullname = "Test Recruiter") |
|
238 | 238 | { |
239 | 239 | /* @var Register $service */ |
240 | 240 | /* @var User $user */ |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | $user->setRole($role); |
246 | 246 | $settings = $user->getSettings('Applications'); |
247 | 247 | |
248 | - $expFullName = explode(' ',$fullname); |
|
248 | + $expFullName = explode(' ', $fullname); |
|
249 | 249 | $info = $user->getInfo(); |
250 | 250 | $info->setFirstName(array_shift($expFullName)); |
251 | - $info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):''); |
|
251 | + $info->setLastName(count($expFullName) > 0 ? implode(' ', $expFullName) : ''); |
|
252 | 252 | $info->setEmail($email); |
253 | 253 | $info->setEmailVerified(true); |
254 | 254 | $repo->store($user); |
@@ -273,19 +273,19 @@ discard block |
||
273 | 273 | * @When I have :organization as my main organization |
274 | 274 | * @param $orgName |
275 | 275 | */ |
276 | - public function iHaveMainOrganization(UserInterface $user,$orgName) |
|
276 | + public function iHaveMainOrganization(UserInterface $user, $orgName) |
|
277 | 277 | { |
278 | 278 | /* @var $repoOrganization OrganizationRepository */ |
279 | 279 | $repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization'); |
280 | - $organization=$repoOrganization->findByName($orgName); |
|
281 | - if(!$organization instanceof Organization){ |
|
280 | + $organization = $repoOrganization->findByName($orgName); |
|
281 | + if (!$organization instanceof Organization) { |
|
282 | 282 | $organization = new Organization(); |
283 | 283 | $organizationName = new OrganizationName($orgName); |
284 | 284 | $organization->setOrganizationName($organizationName); |
285 | 285 | $permissions = $organization->getPermissions(); |
286 | - $permissions->grant($user,Permissions::PERMISSION_ALL); |
|
287 | - }else { |
|
288 | - $organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL); |
|
286 | + $permissions->grant($user, Permissions::PERMISSION_ALL); |
|
287 | + } else { |
|
288 | + $organization->getPermissions()->grant($user, Permissions::PERMISSION_ALL); |
|
289 | 289 | } |
290 | 290 | $organization->setUser($user); |
291 | 291 | $repoOrganization->store($organization); |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | */ |
308 | 308 | public function iSpecifyTheUsernameAs($username) |
309 | 309 | { |
310 | - $this->minkContext->fillField('Login name',$username); |
|
310 | + $this->minkContext->fillField('Login name', $username); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function iSpecifyThePasswordAs($password) |
317 | 317 | { |
318 | - $this->minkContext->fillField('Password',$password); |
|
318 | + $this->minkContext->fillField('Password', $password); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -326,8 +326,8 @@ discard block |
||
326 | 326 | $repo = $this->getUserRepository(); |
327 | 327 | $user = $repo->findByLogin($username); |
328 | 328 | |
329 | - if(!$user instanceof User){ |
|
330 | - throw new \Exception(sprintf('There is no user with this login: "%s"',$username)); |
|
329 | + if (!$user instanceof User) { |
|
330 | + throw new \Exception(sprintf('There is no user with this login: "%s"', $username)); |
|
331 | 331 | } |
332 | 332 | $this->iWantToLogIn(); |
333 | 333 | $this->iSpecifyTheUsernameAs($username); |
@@ -383,13 +383,13 @@ discard block |
||
383 | 383 | { |
384 | 384 | $repo = $this->getUserRepository(); |
385 | 385 | $data = $table->getRowsHash(); |
386 | - $email = isset($data['email']) ? $data['email']:'[email protected]'; |
|
387 | - $password = isset($data['password']) ? $data['password']:'test'; |
|
388 | - $fullname = isset($data['fullname']) ? $data['fullname']:'Test User'; |
|
389 | - $role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER; |
|
386 | + $email = isset($data['email']) ? $data['email'] : '[email protected]'; |
|
387 | + $password = isset($data['password']) ? $data['password'] : 'test'; |
|
388 | + $fullname = isset($data['fullname']) ? $data['fullname'] : 'Test User'; |
|
389 | + $role = isset($data['role']) ? $data['role'] : User::ROLE_RECRUITER; |
|
390 | 390 | |
391 | - if(!is_object($user=$repo->findByLogin($email))){ |
|
392 | - $user = $this->createUser($email,$password,$role,$fullname); |
|
391 | + if (!is_object($user = $repo->findByLogin($email))) { |
|
392 | + $user = $this->createUser($email, $password, $role, $fullname); |
|
393 | 393 | } |
394 | 394 | $this->currentUser = $user; |
395 | 395 | $this->addCreatedUser($user); |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | |
398 | 398 | private function addCreatedUser(UserInterface $user) |
399 | 399 | { |
400 | - if(!in_array($user,static::$users)){ |
|
400 | + if (!in_array($user, static::$users)) { |
|
401 | 401 | static::$users[] = $user; |
402 | 402 | } |
403 | 403 | } |
@@ -14,26 +14,26 @@ |
||
14 | 14 | |
15 | 15 | class SettingsContext implements Context |
16 | 16 | { |
17 | - use CommonContextTrait; |
|
17 | + use CommonContextTrait; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @Given I go to settings page |
|
21 | - */ |
|
22 | - public function iGoToSettingsPage() |
|
23 | - { |
|
24 | - //$this->visit('/settings'); |
|
19 | + /** |
|
20 | + * @Given I go to settings page |
|
21 | + */ |
|
22 | + public function iGoToSettingsPage() |
|
23 | + { |
|
24 | + //$this->visit('/settings'); |
|
25 | 25 | $url = $this->generateUrl('lang/settings'); |
26 | 26 | $this->visit($url); |
27 | - } |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * @Given I go to email template settings page |
|
31 | - */ |
|
32 | - public function iGoToEmailTemplatePage() |
|
33 | - { |
|
34 | - $url = $this->generateUrl('lang/settings',[ |
|
35 | - 'module' => 'Applications' |
|
29 | + /** |
|
30 | + * @Given I go to email template settings page |
|
31 | + */ |
|
32 | + public function iGoToEmailTemplatePage() |
|
33 | + { |
|
34 | + $url = $this->generateUrl('lang/settings',[ |
|
35 | + 'module' => 'Applications' |
|
36 | 36 | ]); |
37 | - $this->visit($url); |
|
38 | - } |
|
37 | + $this->visit($url); |
|
38 | + } |
|
39 | 39 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | public function iGoToEmailTemplatePage() |
33 | 33 | { |
34 | - $url = $this->generateUrl('lang/settings',[ |
|
34 | + $url = $this->generateUrl('lang/settings', [ |
|
35 | 35 | 'module' => 'Applications' |
36 | 36 | ]); |
37 | 37 | $this->visit($url); |