@@ -76,8 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | - * @param $name |
|
80 | - * @param array $params |
|
79 | + * @param string $name |
|
81 | 80 | * |
82 | 81 | * @return string |
83 | 82 | */ |
@@ -88,6 +87,7 @@ discard block |
||
88 | 87 | |
89 | 88 | /** |
90 | 89 | * @When /^I hover over the element "([^"]*)"$/ |
90 | + * @param string $locator |
|
91 | 91 | */ |
92 | 92 | public function iHoverOverTheElement($locator) |
93 | 93 | { |
@@ -163,6 +163,9 @@ discard block |
||
163 | 163 | $this->getSession()->switchToWindow('main_window'); |
164 | 164 | } |
165 | 165 | |
166 | + /** |
|
167 | + * @param string $url |
|
168 | + */ |
|
166 | 169 | public function iVisit($url) |
167 | 170 | { |
168 | 171 | $this->minkContext->getSession()->visit($url); |
@@ -233,10 +236,10 @@ discard block |
||
233 | 236 | } |
234 | 237 | |
235 | 238 | /** |
236 | - * @param $locator |
|
239 | + * @param string $locator |
|
237 | 240 | * @param string $selector |
238 | 241 | * |
239 | - * @return \Behat\Mink\Element\NodeElement|mixed|null |
|
242 | + * @return \Behat\Mink\Element\NodeElement|null |
|
240 | 243 | */ |
241 | 244 | public function getElement($locator,$selector='css') |
242 | 245 | { |
@@ -23,284 +23,284 @@ |
||
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 | \ No newline at end of file |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | public function gatherContexts(BeforeScenarioScope $scope) |
40 | 40 | { |
41 | 41 | $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
42 | - if(false === static::$jobCategoryChecked){ |
|
42 | + if (false === static::$jobCategoryChecked) { |
|
43 | 43 | /* @var Categories $catRepo */ |
44 | 44 | $catRepo = $this->getRepositories()->get('Jobs/Category'); |
45 | 45 | $all = $catRepo->findAll(); |
46 | - if(count($all) <= 1){ |
|
46 | + if (count($all) <= 1) { |
|
47 | 47 | $catRepo->createDefaultCategory('professions'); |
48 | 48 | $catRepo->createDefaultCategory('industries'); |
49 | 49 | $catRepo->createDefaultCategory('employmentTypes'); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function getApplication() |
59 | 59 | { |
60 | - if(!is_object(static::$application)){ |
|
60 | + if (!is_object(static::$application)) { |
|
61 | 61 | $configFile = realpath(__DIR__.'/../../../config/config.php'); |
62 | 62 | $config = include($configFile); |
63 | 63 | static::$application = Application::init($config); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public function iSubmitTheFormWithId($arg) |
142 | 142 | { |
143 | 143 | $node = $this->minkContext->getSession()->getPage()->find('css', $arg); |
144 | - if($node) { |
|
144 | + if ($node) { |
|
145 | 145 | $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();"); |
146 | 146 | } else { |
147 | 147 | throw new \Exception('Element not found'); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | public function iSetMainWindowName() |
166 | 166 | { |
167 | 167 | $window_name = 'main_window'; |
168 | - $script = 'window.name = "' . $window_name . '"'; |
|
168 | + $script = 'window.name = "'.$window_name.'"'; |
|
169 | 169 | $this->getSession()->executeScript($script); |
170 | 170 | } |
171 | 171 | |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | break; |
225 | 225 | |
226 | 226 | default: |
227 | - throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath'); |
|
227 | + throw new \Exception(__METHOD__.' Couldn\'t find selector: '.$selector.' - Allowed selectors: #id, .className, //xpath'); |
|
228 | 228 | break; |
229 | 229 | } |
230 | 230 | |
231 | 231 | try { |
232 | 232 | $this->getSession()->executeScript($function); |
233 | 233 | } catch (\Exception $e) { |
234 | - throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"'); |
|
234 | + throw new \Exception(__METHOD__.' failed'.' Message: for this locator:"'.$selector.'"'); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return \Behat\Mink\Element\NodeElement|mixed|null |
254 | 254 | */ |
255 | - public function getElement($locator,$selector='css') |
|
255 | + public function getElement($locator, $selector = 'css') |
|
256 | 256 | { |
257 | 257 | $page = $this->minkContext->getSession()->getPage(); |
258 | - $element = $page->find('css',$locator); |
|
258 | + $element = $page->find('css', $locator); |
|
259 | 259 | return $element; |
260 | 260 | } |
261 | 261 | |
@@ -287,12 +287,12 @@ discard block |
||
287 | 287 | $session = $this->getSession(); |
288 | 288 | $element = $session->getPage()->find( |
289 | 289 | 'xpath', |
290 | - $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]') |
|
290 | + $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'.$text.'"]') |
|
291 | 291 | ); |
292 | - if(null === $element){ |
|
292 | + if (null === $element) { |
|
293 | 293 | $element = $session->getPage()->find( |
294 | 294 | 'named', |
295 | - array('id',$text) |
|
295 | + array('id', $text) |
|
296 | 296 | ); |
297 | 297 | } |
298 | 298 | if (null === $element) { |
@@ -31,6 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @When /^(?:|I )fill in select2 "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/ |
33 | 33 | * @When /^(?:|I )fill in select2 "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)"$/ |
34 | + * @param string $field |
|
34 | 35 | */ |
35 | 36 | public function iFillInSelect2Field($field, $value) |
36 | 37 | { |
@@ -42,7 +43,7 @@ discard block |
||
42 | 43 | |
43 | 44 | /** |
44 | 45 | * @When I fill in select2 search :field with :search and I choose :choice |
45 | - * @param $field |
|
46 | + * @param string $field |
|
46 | 47 | * @param $value |
47 | 48 | */ |
48 | 49 | public function iFillInSelect2FieldWith($field,$search,$choice=null) |
@@ -24,130 +24,130 @@ |
||
24 | 24 | */ |
25 | 25 | class Select2Context extends RawMinkContext implements Context |
26 | 26 | { |
27 | - protected $timeout = 5; |
|
27 | + protected $timeout = 5; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Fills in Select2 field with specified |
|
31 | - * |
|
32 | - * @When /^(?:|I )fill in select2 "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/ |
|
33 | - * @When /^(?:|I )fill in select2 "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)"$/ |
|
34 | - */ |
|
35 | - public function iFillInSelect2Field($field, $value) |
|
36 | - { |
|
37 | - $page = $this->getSession()->getPage(); |
|
29 | + /** |
|
30 | + * Fills in Select2 field with specified |
|
31 | + * |
|
32 | + * @When /^(?:|I )fill in select2 "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/ |
|
33 | + * @When /^(?:|I )fill in select2 "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)"$/ |
|
34 | + */ |
|
35 | + public function iFillInSelect2Field($field, $value) |
|
36 | + { |
|
37 | + $page = $this->getSession()->getPage(); |
|
38 | 38 | |
39 | - $this->openField($page, $field); |
|
40 | - $this->selectValue($page, $field, $value, $this->timeout); |
|
41 | - } |
|
39 | + $this->openField($page, $field); |
|
40 | + $this->selectValue($page, $field, $value, $this->timeout); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @When I fill in select2 search :field with :search and I choose :choice |
|
45 | - * @param $field |
|
46 | - * @param $value |
|
47 | - */ |
|
48 | - public function iFillInSelect2FieldWith($field,$search,$choice=null) |
|
49 | - { |
|
50 | - $page = $this->getSession()->getPage(); |
|
51 | - $this->openField($page, $field); |
|
52 | - $this->fillSearchField($page,$field,$search); |
|
53 | - $this->selectValue($page, $field, $choice); |
|
54 | - } |
|
43 | + /** |
|
44 | + * @When I fill in select2 search :field with :search and I choose :choice |
|
45 | + * @param $field |
|
46 | + * @param $value |
|
47 | + */ |
|
48 | + public function iFillInSelect2FieldWith($field,$search,$choice=null) |
|
49 | + { |
|
50 | + $page = $this->getSession()->getPage(); |
|
51 | + $this->openField($page, $field); |
|
52 | + $this->fillSearchField($page,$field,$search); |
|
53 | + $this->selectValue($page, $field, $choice); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Fill Select2 search field |
|
58 | - * |
|
59 | - * @param DocumentElement $page |
|
60 | - * @param string $field |
|
61 | - * @param string $value |
|
62 | - * @throws \Exception |
|
63 | - */ |
|
64 | - private function fillSearchField(DocumentElement $page, $field, $value) |
|
65 | - { |
|
66 | - $driver = $this->getSession()->getDriver(); |
|
67 | - if ('Behat\Mink\Driver\Selenium2Driver' === get_class($driver)) { |
|
68 | - // Can't use `$this->getSession()->getPage()->find()` because of https://github.com/minkphp/MinkSelenium2Driver/issues/188 |
|
56 | + /** |
|
57 | + * Fill Select2 search field |
|
58 | + * |
|
59 | + * @param DocumentElement $page |
|
60 | + * @param string $field |
|
61 | + * @param string $value |
|
62 | + * @throws \Exception |
|
63 | + */ |
|
64 | + private function fillSearchField(DocumentElement $page, $field, $value) |
|
65 | + { |
|
66 | + $driver = $this->getSession()->getDriver(); |
|
67 | + if ('Behat\Mink\Driver\Selenium2Driver' === get_class($driver)) { |
|
68 | + // Can't use `$this->getSession()->getPage()->find()` because of https://github.com/minkphp/MinkSelenium2Driver/issues/188 |
|
69 | 69 | |
70 | - $element = $page->find('css','.select2-container--open .select2-search__field'); |
|
71 | - $xpath = $element->getXpath(); |
|
72 | - $select2Input = $this->getSession() |
|
73 | - ->getDriver() |
|
74 | - ->getWebDriverSession() |
|
75 | - ->element('xpath',$xpath) |
|
76 | - //->element('xpath', "//html/descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), ' select2-search__field ')]") |
|
77 | - ; |
|
78 | - if (!$select2Input) { |
|
79 | - throw new \Exception(sprintf('No field "%s" found', $field)); |
|
80 | - } |
|
70 | + $element = $page->find('css','.select2-container--open .select2-search__field'); |
|
71 | + $xpath = $element->getXpath(); |
|
72 | + $select2Input = $this->getSession() |
|
73 | + ->getDriver() |
|
74 | + ->getWebDriverSession() |
|
75 | + ->element('xpath',$xpath) |
|
76 | + //->element('xpath', "//html/descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), ' select2-search__field ')]") |
|
77 | + ; |
|
78 | + if (!$select2Input) { |
|
79 | + throw new \Exception(sprintf('No field "%s" found', $field)); |
|
80 | + } |
|
81 | 81 | |
82 | - $select2Input->postValue(['value' => [$value]]); |
|
83 | - } else { |
|
84 | - $select2Input = $page->find('css', '.select2-search__field'); |
|
85 | - if (!$select2Input) { |
|
86 | - throw new \Exception(sprintf('No input found for "%s"', $field)); |
|
87 | - } |
|
88 | - $select2Input->setValue($value); |
|
89 | - } |
|
82 | + $select2Input->postValue(['value' => [$value]]); |
|
83 | + } else { |
|
84 | + $select2Input = $page->find('css', '.select2-search__field'); |
|
85 | + if (!$select2Input) { |
|
86 | + throw new \Exception(sprintf('No input found for "%s"', $field)); |
|
87 | + } |
|
88 | + $select2Input->setValue($value); |
|
89 | + } |
|
90 | 90 | |
91 | - $this->waitForLoadingResults($this->timeout); |
|
92 | - } |
|
91 | + $this->waitForLoadingResults($this->timeout); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Select value in choice list |
|
96 | - * |
|
97 | - * @param DocumentElement $page |
|
98 | - * @param string $field |
|
99 | - * @param string $value |
|
100 | - * @param int $time |
|
101 | - * @throws \Exception |
|
102 | - */ |
|
103 | - private function selectValue(DocumentElement $page, $field, $value, $time=5) |
|
104 | - { |
|
105 | - $this->waitForLoadingResults($time); |
|
94 | + /** |
|
95 | + * Select value in choice list |
|
96 | + * |
|
97 | + * @param DocumentElement $page |
|
98 | + * @param string $field |
|
99 | + * @param string $value |
|
100 | + * @param int $time |
|
101 | + * @throws \Exception |
|
102 | + */ |
|
103 | + private function selectValue(DocumentElement $page, $field, $value, $time=5) |
|
104 | + { |
|
105 | + $this->waitForLoadingResults($time); |
|
106 | 106 | |
107 | - $chosenResults = $page->findAll('css', '.select2-results li'); |
|
108 | - foreach ($chosenResults as $result) { |
|
109 | - $text = $result->getText(); |
|
110 | - if (false!==strpos($text,$value)) { |
|
111 | - $result->click(); |
|
112 | - return; |
|
113 | - } |
|
114 | - } |
|
107 | + $chosenResults = $page->findAll('css', '.select2-results li'); |
|
108 | + foreach ($chosenResults as $result) { |
|
109 | + $text = $result->getText(); |
|
110 | + if (false!==strpos($text,$value)) { |
|
111 | + $result->click(); |
|
112 | + return; |
|
113 | + } |
|
114 | + } |
|
115 | 115 | |
116 | - throw new \Exception(sprintf('Value "%s" not found for "%s"', $value, $field)); |
|
117 | - } |
|
116 | + throw new \Exception(sprintf('Value "%s" not found for "%s"', $value, $field)); |
|
117 | + } |
|
118 | 118 | |
119 | - private function openField(DocumentElement $page, $field) |
|
120 | - { |
|
121 | - $inputField = $page->find('css',$field); |
|
122 | - if(!$inputField){ |
|
123 | - $fieldName = sprintf('select[name="%s"] + .select2-container', $field); |
|
124 | - $inputField = $page->find('css', $fieldName); |
|
125 | - } |
|
126 | - if (!$inputField) { |
|
127 | - throw new \Exception(sprintf('No field "%s" found', $field)); |
|
128 | - } |
|
119 | + private function openField(DocumentElement $page, $field) |
|
120 | + { |
|
121 | + $inputField = $page->find('css',$field); |
|
122 | + if(!$inputField){ |
|
123 | + $fieldName = sprintf('select[name="%s"] + .select2-container', $field); |
|
124 | + $inputField = $page->find('css', $fieldName); |
|
125 | + } |
|
126 | + if (!$inputField) { |
|
127 | + throw new \Exception(sprintf('No field "%s" found', $field)); |
|
128 | + } |
|
129 | 129 | |
130 | - $choice = $inputField->find('css', '.select2-selection'); |
|
131 | - if (!$choice) { |
|
132 | - throw new \Exception(sprintf('No select2 choice found for "%s"', $field)); |
|
133 | - } |
|
134 | - $choice->press(); |
|
135 | - } |
|
130 | + $choice = $inputField->find('css', '.select2-selection'); |
|
131 | + if (!$choice) { |
|
132 | + throw new \Exception(sprintf('No select2 choice found for "%s"', $field)); |
|
133 | + } |
|
134 | + $choice->press(); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Wait the end of fetching Select2 results |
|
139 | - * |
|
140 | - * @param int $time Time to wait in seconds |
|
141 | - */ |
|
142 | - private function waitForLoadingResults($time) |
|
143 | - { |
|
144 | - for ($i = 0; $i < $time; $i++) { |
|
145 | - if (!$this->getSession()->getPage()->find('css', '.select2-results__option.loading-results')) { |
|
146 | - return; |
|
147 | - } |
|
137 | + /** |
|
138 | + * Wait the end of fetching Select2 results |
|
139 | + * |
|
140 | + * @param int $time Time to wait in seconds |
|
141 | + */ |
|
142 | + private function waitForLoadingResults($time) |
|
143 | + { |
|
144 | + for ($i = 0; $i < $time; $i++) { |
|
145 | + if (!$this->getSession()->getPage()->find('css', '.select2-results__option.loading-results')) { |
|
146 | + return; |
|
147 | + } |
|
148 | 148 | |
149 | - sleep(1); |
|
150 | - } |
|
151 | - } |
|
149 | + sleep(1); |
|
150 | + } |
|
151 | + } |
|
152 | 152 | |
153 | 153 | } |
154 | 154 | \ No newline at end of file |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | * @param $field |
46 | 46 | * @param $value |
47 | 47 | */ |
48 | - public function iFillInSelect2FieldWith($field,$search,$choice=null) |
|
48 | + public function iFillInSelect2FieldWith($field, $search, $choice = null) |
|
49 | 49 | { |
50 | 50 | $page = $this->getSession()->getPage(); |
51 | 51 | $this->openField($page, $field); |
52 | - $this->fillSearchField($page,$field,$search); |
|
52 | + $this->fillSearchField($page, $field, $search); |
|
53 | 53 | $this->selectValue($page, $field, $choice); |
54 | 54 | } |
55 | 55 | |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | if ('Behat\Mink\Driver\Selenium2Driver' === get_class($driver)) { |
68 | 68 | // Can't use `$this->getSession()->getPage()->find()` because of https://github.com/minkphp/MinkSelenium2Driver/issues/188 |
69 | 69 | |
70 | - $element = $page->find('css','.select2-container--open .select2-search__field'); |
|
70 | + $element = $page->find('css', '.select2-container--open .select2-search__field'); |
|
71 | 71 | $xpath = $element->getXpath(); |
72 | 72 | $select2Input = $this->getSession() |
73 | 73 | ->getDriver() |
74 | 74 | ->getWebDriverSession() |
75 | - ->element('xpath',$xpath) |
|
75 | + ->element('xpath', $xpath) |
|
76 | 76 | //->element('xpath', "//html/descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), ' select2-search__field ')]") |
77 | 77 | ; |
78 | 78 | if (!$select2Input) { |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | * @param int $time |
101 | 101 | * @throws \Exception |
102 | 102 | */ |
103 | - private function selectValue(DocumentElement $page, $field, $value, $time=5) |
|
103 | + private function selectValue(DocumentElement $page, $field, $value, $time = 5) |
|
104 | 104 | { |
105 | 105 | $this->waitForLoadingResults($time); |
106 | 106 | |
107 | 107 | $chosenResults = $page->findAll('css', '.select2-results li'); |
108 | 108 | foreach ($chosenResults as $result) { |
109 | 109 | $text = $result->getText(); |
110 | - if (false!==strpos($text,$value)) { |
|
110 | + if (false !== strpos($text, $value)) { |
|
111 | 111 | $result->click(); |
112 | 112 | return; |
113 | 113 | } |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | |
119 | 119 | private function openField(DocumentElement $page, $field) |
120 | 120 | { |
121 | - $inputField = $page->find('css',$field); |
|
122 | - if(!$inputField){ |
|
121 | + $inputField = $page->find('css', $field); |
|
122 | + if (!$inputField) { |
|
123 | 123 | $fieldName = sprintf('select[name="%s"] + .select2-container', $field); |
124 | 124 | $inputField = $page->find('css', $fieldName); |
125 | 125 | } |
@@ -198,6 +198,9 @@ discard block |
||
198 | 198 | $this->startLogin($user,'test'); |
199 | 199 | } |
200 | 200 | |
201 | + /** |
|
202 | + * @param string $password |
|
203 | + */ |
|
201 | 204 | private function startLogin(UserInterface $user, $password) |
202 | 205 | { |
203 | 206 | $currentUser = $this->currentUser; |
@@ -242,7 +245,7 @@ discard block |
||
242 | 245 | * @param string $fullname |
243 | 246 | * @param string $role |
244 | 247 | * |
245 | - * @return \Auth\Entity\UserInterface |
|
248 | + * @return \Core\Entity\EntityInterface |
|
246 | 249 | */ |
247 | 250 | public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter") |
248 | 251 | { |
@@ -32,398 +32,398 @@ |
||
32 | 32 | |
33 | 33 | class UserContext implements Context |
34 | 34 | { |
35 | - /** |
|
36 | - * @var CoreContext |
|
37 | - */ |
|
38 | - private $coreContext; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var MinkContext |
|
42 | - */ |
|
43 | - private $minkContext; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var User |
|
47 | - */ |
|
48 | - private $currentUser; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var User[] |
|
52 | - */ |
|
53 | - static private $users = []; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var UserRepository |
|
57 | - */ |
|
58 | - static private $userRepo; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var string |
|
62 | - */ |
|
63 | - static private $currentSession; |
|
64 | - |
|
65 | - private $socialLoginInfo = []; |
|
66 | - |
|
67 | - /** |
|
68 | - * @var UserInterface |
|
69 | - */ |
|
70 | - private $loggedInUser; |
|
71 | - |
|
72 | - public function __construct($parameters=[]) |
|
73 | - { |
|
74 | - $defaultLoginInfo = [ |
|
75 | - 'facebook' => [ |
|
76 | - 'email' => getenv('FACEBOOK_USER_EMAIL'), |
|
77 | - 'pass' => getenv('FACEBOOK_USER_PASSWORD') |
|
78 | - ], |
|
79 | - 'linkedin' => [ |
|
80 | - 'session_key-login' => getenv('LINKEDIN_USER_EMAIL'), |
|
81 | - 'session_password-login' => getenv('LINKEDIN_USER_PASSWORD') |
|
82 | - ], |
|
83 | - ]; |
|
84 | - $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[]; |
|
85 | - $this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @AfterSuite |
|
90 | - * @param AfterSuiteScope $scope |
|
91 | - */ |
|
92 | - static public function afterSuite(AfterSuiteScope $scope) |
|
93 | - { |
|
94 | - $repo = static::$userRepo; |
|
95 | - foreach(static::$users as $user){ |
|
96 | - if($repo->findByLogin($user->getLogin())){ |
|
97 | - try{ |
|
98 | - JobContext::removeJobByUser($user); |
|
99 | - $repo->remove($user,true); |
|
100 | - }catch (\Exception $e){ |
|
35 | + /** |
|
36 | + * @var CoreContext |
|
37 | + */ |
|
38 | + private $coreContext; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var MinkContext |
|
42 | + */ |
|
43 | + private $minkContext; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var User |
|
47 | + */ |
|
48 | + private $currentUser; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var User[] |
|
52 | + */ |
|
53 | + static private $users = []; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var UserRepository |
|
57 | + */ |
|
58 | + static private $userRepo; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var string |
|
62 | + */ |
|
63 | + static private $currentSession; |
|
64 | + |
|
65 | + private $socialLoginInfo = []; |
|
66 | + |
|
67 | + /** |
|
68 | + * @var UserInterface |
|
69 | + */ |
|
70 | + private $loggedInUser; |
|
71 | + |
|
72 | + public function __construct($parameters=[]) |
|
73 | + { |
|
74 | + $defaultLoginInfo = [ |
|
75 | + 'facebook' => [ |
|
76 | + 'email' => getenv('FACEBOOK_USER_EMAIL'), |
|
77 | + 'pass' => getenv('FACEBOOK_USER_PASSWORD') |
|
78 | + ], |
|
79 | + 'linkedin' => [ |
|
80 | + 'session_key-login' => getenv('LINKEDIN_USER_EMAIL'), |
|
81 | + 'session_password-login' => getenv('LINKEDIN_USER_PASSWORD') |
|
82 | + ], |
|
83 | + ]; |
|
84 | + $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[]; |
|
85 | + $this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @AfterSuite |
|
90 | + * @param AfterSuiteScope $scope |
|
91 | + */ |
|
92 | + static public function afterSuite(AfterSuiteScope $scope) |
|
93 | + { |
|
94 | + $repo = static::$userRepo; |
|
95 | + foreach(static::$users as $user){ |
|
96 | + if($repo->findByLogin($user->getLogin())){ |
|
97 | + try{ |
|
98 | + JobContext::removeJobByUser($user); |
|
99 | + $repo->remove($user,true); |
|
100 | + }catch (\Exception $e){ |
|
101 | 101 | |
102 | - } |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @BeforeScenario |
|
109 | - * @param BeforeScenarioScope $scope |
|
110 | - */ |
|
111 | - public function beforeScenario(BeforeScenarioScope $scope) |
|
112 | - { |
|
113 | - $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
114 | - $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
115 | - static::$userRepo = $this->getUserRepository(); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @return User |
|
120 | - */ |
|
121 | - public function getCurrentUser() |
|
122 | - { |
|
123 | - return $this->currentUser; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * @When I fill in login form with :provider user |
|
128 | - */ |
|
129 | - public function iSignInWithSocialUser($provider) |
|
130 | - { |
|
131 | - $provider = strtolower($provider); |
|
132 | - $mink = $this->minkContext; |
|
133 | - foreach($this->socialLoginInfo[$provider] as $field=>$value){ |
|
134 | - $mink->fillField($field,$value); |
|
135 | - } |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @Given I am logged in as a recruiter |
|
140 | - * @Given I am logged in as a recruiter with :organization as organization |
|
141 | - */ |
|
142 | - public function iAmLoggedInAsARecruiter($organization=null) |
|
143 | - { |
|
144 | - $user = $this->thereIsAUserIdentifiedBy( |
|
145 | - '[email protected]', |
|
146 | - 'test',User::ROLE_RECRUITER, |
|
147 | - 'Test Recruiter', |
|
148 | - $organization |
|
149 | - ); |
|
150 | - $this->startLogin($user,'test'); |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * @Given I don't have :login user |
|
155 | - * @param string $login |
|
156 | - */ |
|
157 | - public function iDonTHaveUser($login) |
|
158 | - { |
|
159 | - $repo = $this->getUserRepository(); |
|
160 | - $user=$repo->findByLogin($login); |
|
161 | - if($user instanceof UserInterface){ |
|
162 | - $repo->remove($user,true); |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * @Given I have a :role with the following: |
|
168 | - * @param $role |
|
169 | - * @param TableNode $fields |
|
170 | - */ |
|
171 | - public function iHaveUserWithTheFollowing($role,TableNode $fields) |
|
172 | - { |
|
173 | - $normalizedFields = [ |
|
174 | - 'login' => '[email protected]', |
|
175 | - 'fullname' => 'Test Login', |
|
176 | - 'role' => User::ROLE_USER, |
|
177 | - 'password' => 'test', |
|
178 | - 'organization' => 'Cross Solution' |
|
179 | - ]; |
|
180 | - foreach($fields->getRowsHash() as $field=>$value){ |
|
181 | - $field = Inflector::camelize($field); |
|
182 | - $normalizedFields[$field] = $value; |
|
183 | - } |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @BeforeScenario |
|
109 | + * @param BeforeScenarioScope $scope |
|
110 | + */ |
|
111 | + public function beforeScenario(BeforeScenarioScope $scope) |
|
112 | + { |
|
113 | + $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
114 | + $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
115 | + static::$userRepo = $this->getUserRepository(); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @return User |
|
120 | + */ |
|
121 | + public function getCurrentUser() |
|
122 | + { |
|
123 | + return $this->currentUser; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * @When I fill in login form with :provider user |
|
128 | + */ |
|
129 | + public function iSignInWithSocialUser($provider) |
|
130 | + { |
|
131 | + $provider = strtolower($provider); |
|
132 | + $mink = $this->minkContext; |
|
133 | + foreach($this->socialLoginInfo[$provider] as $field=>$value){ |
|
134 | + $mink->fillField($field,$value); |
|
135 | + } |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @Given I am logged in as a recruiter |
|
140 | + * @Given I am logged in as a recruiter with :organization as organization |
|
141 | + */ |
|
142 | + public function iAmLoggedInAsARecruiter($organization=null) |
|
143 | + { |
|
144 | + $user = $this->thereIsAUserIdentifiedBy( |
|
145 | + '[email protected]', |
|
146 | + 'test',User::ROLE_RECRUITER, |
|
147 | + 'Test Recruiter', |
|
148 | + $organization |
|
149 | + ); |
|
150 | + $this->startLogin($user,'test'); |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * @Given I don't have :login user |
|
155 | + * @param string $login |
|
156 | + */ |
|
157 | + public function iDonTHaveUser($login) |
|
158 | + { |
|
159 | + $repo = $this->getUserRepository(); |
|
160 | + $user=$repo->findByLogin($login); |
|
161 | + if($user instanceof UserInterface){ |
|
162 | + $repo->remove($user,true); |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * @Given I have a :role with the following: |
|
168 | + * @param $role |
|
169 | + * @param TableNode $fields |
|
170 | + */ |
|
171 | + public function iHaveUserWithTheFollowing($role,TableNode $fields) |
|
172 | + { |
|
173 | + $normalizedFields = [ |
|
174 | + 'login' => '[email protected]', |
|
175 | + 'fullname' => 'Test Login', |
|
176 | + 'role' => User::ROLE_USER, |
|
177 | + 'password' => 'test', |
|
178 | + 'organization' => 'Cross Solution' |
|
179 | + ]; |
|
180 | + foreach($fields->getRowsHash() as $field=>$value){ |
|
181 | + $field = Inflector::camelize($field); |
|
182 | + $normalizedFields[$field] = $value; |
|
183 | + } |
|
184 | 184 | |
185 | - $this->thereIsAUserIdentifiedBy( |
|
186 | - $normalizedFields['login'], |
|
187 | - $normalizedFields['password'], |
|
188 | - $role, |
|
189 | - $normalizedFields['fullname'], |
|
190 | - $normalizedFields['organization'] |
|
191 | - ); |
|
185 | + $this->thereIsAUserIdentifiedBy( |
|
186 | + $normalizedFields['login'], |
|
187 | + $normalizedFields['password'], |
|
188 | + $role, |
|
189 | + $normalizedFields['fullname'], |
|
190 | + $normalizedFields['organization'] |
|
191 | + ); |
|
192 | 192 | |
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * @Given I am logged in as an administrator |
|
197 | - */ |
|
198 | - public function iAmLoggedInAsAnAdmin() |
|
199 | - { |
|
200 | - $user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN); |
|
201 | - $this->startLogin($user,'test'); |
|
202 | - } |
|
203 | - |
|
204 | - private function startLogin(UserInterface $user, $password) |
|
205 | - { |
|
206 | - $currentUser = $this->currentUser; |
|
207 | - if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){ |
|
208 | - $this->iWantToLogIn(); |
|
209 | - $this->iSpecifyTheUsernameAs($user->getLogin()); |
|
210 | - $this->iSpecifyThePasswordAs($password); |
|
211 | - $this->iLogIn(); |
|
212 | - $this->currentUser = $user; |
|
213 | - } |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * @return UserRepository |
|
218 | - */ |
|
219 | - public function getUserRepository() |
|
220 | - { |
|
221 | - return $this->coreContext->getRepositories()->get('Auth\Entity\User'); |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * @Given there is a user :email identified by :password |
|
226 | - */ |
|
227 | - public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null) |
|
228 | - { |
|
229 | - $repo = $this->getUserRepository(); |
|
230 | - if(!is_object($user=$repo->findByEmail($email))){ |
|
231 | - $user = $this->createUser($email,$password,$role,$fullname,$organization); |
|
232 | - } |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * @Given I am logged in as an administrator |
|
197 | + */ |
|
198 | + public function iAmLoggedInAsAnAdmin() |
|
199 | + { |
|
200 | + $user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN); |
|
201 | + $this->startLogin($user,'test'); |
|
202 | + } |
|
203 | + |
|
204 | + private function startLogin(UserInterface $user, $password) |
|
205 | + { |
|
206 | + $currentUser = $this->currentUser; |
|
207 | + if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){ |
|
208 | + $this->iWantToLogIn(); |
|
209 | + $this->iSpecifyTheUsernameAs($user->getLogin()); |
|
210 | + $this->iSpecifyThePasswordAs($password); |
|
211 | + $this->iLogIn(); |
|
212 | + $this->currentUser = $user; |
|
213 | + } |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * @return UserRepository |
|
218 | + */ |
|
219 | + public function getUserRepository() |
|
220 | + { |
|
221 | + return $this->coreContext->getRepositories()->get('Auth\Entity\User'); |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * @Given there is a user :email identified by :password |
|
226 | + */ |
|
227 | + public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null) |
|
228 | + { |
|
229 | + $repo = $this->getUserRepository(); |
|
230 | + if(!is_object($user=$repo->findByEmail($email))){ |
|
231 | + $user = $this->createUser($email,$password,$role,$fullname,$organization); |
|
232 | + } |
|
233 | 233 | |
234 | - if(!is_null($organization)){ |
|
235 | - $this->iHaveMainOrganization($user,$organization); |
|
236 | - } |
|
237 | - $this->addCreatedUser($user); |
|
238 | - return $user; |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * @param $email |
|
243 | - * @param $password |
|
244 | - * @param $username |
|
245 | - * @param string $fullname |
|
246 | - * @param string $role |
|
247 | - * |
|
248 | - * @return \Auth\Entity\UserInterface |
|
249 | - */ |
|
250 | - public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter") |
|
251 | - { |
|
252 | - /* @var Register $service */ |
|
253 | - /* @var User $user */ |
|
254 | - $repo = $this->getUserRepository(); |
|
255 | - $user = $repo->create([]); |
|
256 | - $user->setLogin($email); |
|
257 | - $user->setPassword($password); |
|
258 | - $user->setRole($role); |
|
259 | - $settings = $user->getSettings('Applications'); |
|
234 | + if(!is_null($organization)){ |
|
235 | + $this->iHaveMainOrganization($user,$organization); |
|
236 | + } |
|
237 | + $this->addCreatedUser($user); |
|
238 | + return $user; |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * @param $email |
|
243 | + * @param $password |
|
244 | + * @param $username |
|
245 | + * @param string $fullname |
|
246 | + * @param string $role |
|
247 | + * |
|
248 | + * @return \Auth\Entity\UserInterface |
|
249 | + */ |
|
250 | + public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter") |
|
251 | + { |
|
252 | + /* @var Register $service */ |
|
253 | + /* @var User $user */ |
|
254 | + $repo = $this->getUserRepository(); |
|
255 | + $user = $repo->create([]); |
|
256 | + $user->setLogin($email); |
|
257 | + $user->setPassword($password); |
|
258 | + $user->setRole($role); |
|
259 | + $settings = $user->getSettings('Applications'); |
|
260 | 260 | |
261 | - $expFullName = explode(' ',$fullname); |
|
262 | - $info = $user->getInfo(); |
|
263 | - $info->setFirstName(array_shift($expFullName)); |
|
264 | - $info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):''); |
|
265 | - $info->setEmail($email); |
|
266 | - $info->setEmailVerified(true); |
|
267 | - $repo->store($user); |
|
268 | - $repo->getDocumentManager()->refresh($user); |
|
261 | + $expFullName = explode(' ',$fullname); |
|
262 | + $info = $user->getInfo(); |
|
263 | + $info->setFirstName(array_shift($expFullName)); |
|
264 | + $info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):''); |
|
265 | + $info->setEmail($email); |
|
266 | + $info->setEmailVerified(true); |
|
267 | + $repo->store($user); |
|
268 | + $repo->getDocumentManager()->refresh($user); |
|
269 | 269 | |
270 | - $eventArgs = new LifecycleEventArgs($user, $repo->getDocumentManager()); |
|
271 | - $repo->getDocumentManager()->getEventManager()->dispatchEvent( |
|
272 | - Events::postLoad, |
|
273 | - $eventArgs |
|
274 | - ); |
|
275 | - /* @var \Core\EventManager\EventManager $events */ |
|
276 | - /* @var \Auth\Listener\Events\AuthEvent $event */ |
|
277 | - //@TODO: [Behat] event not working in travis |
|
278 | - //$events = $this->coreContext->getEventManager(); |
|
279 | - //$event = $events->getEvent(AuthEvent::EVENT_USER_REGISTERED, $this); |
|
280 | - //$event->setUser($user); |
|
281 | - //$events->triggerEvent($event); |
|
282 | - return $user; |
|
283 | - } |
|
284 | - |
|
285 | - /** |
|
286 | - * @When I have :organization as my main organization |
|
287 | - * @param $orgName |
|
288 | - */ |
|
289 | - public function iHaveMainOrganization(UserInterface $user,$orgName) |
|
290 | - { |
|
291 | - /* @var $repoOrganization OrganizationRepository */ |
|
292 | - $repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization'); |
|
293 | - $organization=$repoOrganization->findByName($orgName); |
|
294 | - if(!$organization instanceof Organization){ |
|
295 | - $organization = new Organization(); |
|
296 | - $organizationName = new OrganizationName($orgName); |
|
297 | - $organization->setOrganizationName($organizationName); |
|
298 | - $permissions = $organization->getPermissions(); |
|
299 | - $permissions->grant($user,Permissions::PERMISSION_ALL); |
|
300 | - }else { |
|
301 | - $organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL); |
|
302 | - } |
|
303 | - $organization->setUser($user); |
|
304 | - $repoOrganization->store($organization); |
|
305 | - $repoOrganization->getDocumentManager()->refresh($organization); |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * @When I want to log in |
|
310 | - */ |
|
311 | - public function iWantToLogIn() |
|
312 | - { |
|
313 | - $session = $this->minkContext->getSession(); |
|
314 | - $url = $this->minkContext->locatePath('/en/login'); |
|
315 | - $session->visit($url); |
|
316 | - } |
|
317 | - |
|
318 | - /** |
|
319 | - * @When I specify the username as :username |
|
320 | - */ |
|
321 | - public function iSpecifyTheUsernameAs($username) |
|
322 | - { |
|
323 | - $this->minkContext->fillField('Login name',$username); |
|
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * @When I specify the password as :password |
|
328 | - */ |
|
329 | - public function iSpecifyThePasswordAs($password) |
|
330 | - { |
|
331 | - $this->minkContext->fillField('Password',$password); |
|
332 | - } |
|
333 | - |
|
334 | - /** |
|
335 | - * @Given I am logged in as :username identified by :password |
|
336 | - */ |
|
337 | - public function iAmLoggedInAsIdentifiedBy($username, $password) |
|
338 | - { |
|
339 | - $repo = $this->getUserRepository(); |
|
340 | - $user = $repo->findByLogin($username); |
|
270 | + $eventArgs = new LifecycleEventArgs($user, $repo->getDocumentManager()); |
|
271 | + $repo->getDocumentManager()->getEventManager()->dispatchEvent( |
|
272 | + Events::postLoad, |
|
273 | + $eventArgs |
|
274 | + ); |
|
275 | + /* @var \Core\EventManager\EventManager $events */ |
|
276 | + /* @var \Auth\Listener\Events\AuthEvent $event */ |
|
277 | + //@TODO: [Behat] event not working in travis |
|
278 | + //$events = $this->coreContext->getEventManager(); |
|
279 | + //$event = $events->getEvent(AuthEvent::EVENT_USER_REGISTERED, $this); |
|
280 | + //$event->setUser($user); |
|
281 | + //$events->triggerEvent($event); |
|
282 | + return $user; |
|
283 | + } |
|
284 | + |
|
285 | + /** |
|
286 | + * @When I have :organization as my main organization |
|
287 | + * @param $orgName |
|
288 | + */ |
|
289 | + public function iHaveMainOrganization(UserInterface $user,$orgName) |
|
290 | + { |
|
291 | + /* @var $repoOrganization OrganizationRepository */ |
|
292 | + $repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization'); |
|
293 | + $organization=$repoOrganization->findByName($orgName); |
|
294 | + if(!$organization instanceof Organization){ |
|
295 | + $organization = new Organization(); |
|
296 | + $organizationName = new OrganizationName($orgName); |
|
297 | + $organization->setOrganizationName($organizationName); |
|
298 | + $permissions = $organization->getPermissions(); |
|
299 | + $permissions->grant($user,Permissions::PERMISSION_ALL); |
|
300 | + }else { |
|
301 | + $organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL); |
|
302 | + } |
|
303 | + $organization->setUser($user); |
|
304 | + $repoOrganization->store($organization); |
|
305 | + $repoOrganization->getDocumentManager()->refresh($organization); |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * @When I want to log in |
|
310 | + */ |
|
311 | + public function iWantToLogIn() |
|
312 | + { |
|
313 | + $session = $this->minkContext->getSession(); |
|
314 | + $url = $this->minkContext->locatePath('/en/login'); |
|
315 | + $session->visit($url); |
|
316 | + } |
|
317 | + |
|
318 | + /** |
|
319 | + * @When I specify the username as :username |
|
320 | + */ |
|
321 | + public function iSpecifyTheUsernameAs($username) |
|
322 | + { |
|
323 | + $this->minkContext->fillField('Login name',$username); |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * @When I specify the password as :password |
|
328 | + */ |
|
329 | + public function iSpecifyThePasswordAs($password) |
|
330 | + { |
|
331 | + $this->minkContext->fillField('Password',$password); |
|
332 | + } |
|
333 | + |
|
334 | + /** |
|
335 | + * @Given I am logged in as :username identified by :password |
|
336 | + */ |
|
337 | + public function iAmLoggedInAsIdentifiedBy($username, $password) |
|
338 | + { |
|
339 | + $repo = $this->getUserRepository(); |
|
340 | + $user = $repo->findByLogin($username); |
|
341 | 341 | |
342 | - if(!$user instanceof User){ |
|
343 | - throw new \Exception(sprintf('There is no user with this login: "%s"',$username)); |
|
344 | - } |
|
345 | - $this->currentUser = $user; |
|
346 | - $this->iWantToLogIn(); |
|
347 | - $this->iSpecifyTheUsernameAs($username); |
|
348 | - $this->iSpecifyThePasswordAs($password); |
|
349 | - $this->iLogIn(); |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * @When I log in |
|
354 | - */ |
|
355 | - public function iLogIn() |
|
356 | - { |
|
357 | - $this->minkContext->pressButton('login'); |
|
358 | - } |
|
359 | - |
|
360 | - /** |
|
361 | - * @When I press logout link |
|
362 | - */ |
|
363 | - public function iPressLogoutLink() |
|
364 | - { |
|
365 | - //@TODO: [ZF3] replace this with click method |
|
366 | - $url = $this->coreContext->generateUrl('/logout'); |
|
367 | - $this->minkContext->visit($url); |
|
368 | - } |
|
369 | - |
|
370 | - /** |
|
371 | - * @Given I log in with username :username and password :password |
|
372 | - */ |
|
373 | - public function iLogInWith($username, $password) |
|
374 | - { |
|
375 | - $repo = $this->getUserRepository(); |
|
376 | - $user = $repo->findByLogin($username); |
|
377 | - $this->iWantToLogIn(); |
|
378 | - $this->iSpecifyTheUsernameAs($username); |
|
379 | - $this->iSpecifyThePasswordAs($password); |
|
380 | - $this->iLogIn(); |
|
381 | - $this->loggedInUser = $user; |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * @When I go to profile page |
|
386 | - */ |
|
387 | - public function iGoToProfilePage() |
|
388 | - { |
|
389 | - $url = $this->coreContext->generateUrl('/en/my/profile'); |
|
390 | - $this->minkContext->visit($url); |
|
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * @Given there is a user with the following: |
|
395 | - */ |
|
396 | - public function thereIsAUserWithTheFollowing(TableNode $table) |
|
397 | - { |
|
398 | - $repo = $this->getUserRepository(); |
|
399 | - $data = $table->getRowsHash(); |
|
400 | - $email = isset($data['email']) ? $data['email']:'[email protected]'; |
|
401 | - $password = isset($data['password']) ? $data['password']:'test'; |
|
402 | - $fullname = isset($data['fullname']) ? $data['fullname']:'Test User'; |
|
403 | - $role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER; |
|
342 | + if(!$user instanceof User){ |
|
343 | + throw new \Exception(sprintf('There is no user with this login: "%s"',$username)); |
|
344 | + } |
|
345 | + $this->currentUser = $user; |
|
346 | + $this->iWantToLogIn(); |
|
347 | + $this->iSpecifyTheUsernameAs($username); |
|
348 | + $this->iSpecifyThePasswordAs($password); |
|
349 | + $this->iLogIn(); |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * @When I log in |
|
354 | + */ |
|
355 | + public function iLogIn() |
|
356 | + { |
|
357 | + $this->minkContext->pressButton('login'); |
|
358 | + } |
|
359 | + |
|
360 | + /** |
|
361 | + * @When I press logout link |
|
362 | + */ |
|
363 | + public function iPressLogoutLink() |
|
364 | + { |
|
365 | + //@TODO: [ZF3] replace this with click method |
|
366 | + $url = $this->coreContext->generateUrl('/logout'); |
|
367 | + $this->minkContext->visit($url); |
|
368 | + } |
|
369 | + |
|
370 | + /** |
|
371 | + * @Given I log in with username :username and password :password |
|
372 | + */ |
|
373 | + public function iLogInWith($username, $password) |
|
374 | + { |
|
375 | + $repo = $this->getUserRepository(); |
|
376 | + $user = $repo->findByLogin($username); |
|
377 | + $this->iWantToLogIn(); |
|
378 | + $this->iSpecifyTheUsernameAs($username); |
|
379 | + $this->iSpecifyThePasswordAs($password); |
|
380 | + $this->iLogIn(); |
|
381 | + $this->loggedInUser = $user; |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * @When I go to profile page |
|
386 | + */ |
|
387 | + public function iGoToProfilePage() |
|
388 | + { |
|
389 | + $url = $this->coreContext->generateUrl('/en/my/profile'); |
|
390 | + $this->minkContext->visit($url); |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * @Given there is a user with the following: |
|
395 | + */ |
|
396 | + public function thereIsAUserWithTheFollowing(TableNode $table) |
|
397 | + { |
|
398 | + $repo = $this->getUserRepository(); |
|
399 | + $data = $table->getRowsHash(); |
|
400 | + $email = isset($data['email']) ? $data['email']:'[email protected]'; |
|
401 | + $password = isset($data['password']) ? $data['password']:'test'; |
|
402 | + $fullname = isset($data['fullname']) ? $data['fullname']:'Test User'; |
|
403 | + $role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER; |
|
404 | 404 | |
405 | - if(!is_object($user=$repo->findByLogin($email))){ |
|
406 | - $user = $this->createUser($email,$password,$role,$fullname); |
|
407 | - } |
|
408 | - $this->currentUser = $user; |
|
409 | - $this->addCreatedUser($user); |
|
410 | - } |
|
411 | - |
|
412 | - private function addCreatedUser(UserInterface $user) |
|
413 | - { |
|
414 | - if(!in_array($user,static::$users)){ |
|
415 | - static::$users[] = $user; |
|
416 | - } |
|
417 | - } |
|
418 | - |
|
419 | - /** |
|
420 | - * @When I want to change my password |
|
421 | - */ |
|
422 | - public function iWantToChangeMyPassword() |
|
423 | - { |
|
424 | - $mink = $this->minkContext; |
|
425 | - $url = $this->coreContext->generateUrl('/en/my/password'); |
|
426 | - $mink->getSession()->visit($url); |
|
427 | - } |
|
405 | + if(!is_object($user=$repo->findByLogin($email))){ |
|
406 | + $user = $this->createUser($email,$password,$role,$fullname); |
|
407 | + } |
|
408 | + $this->currentUser = $user; |
|
409 | + $this->addCreatedUser($user); |
|
410 | + } |
|
411 | + |
|
412 | + private function addCreatedUser(UserInterface $user) |
|
413 | + { |
|
414 | + if(!in_array($user,static::$users)){ |
|
415 | + static::$users[] = $user; |
|
416 | + } |
|
417 | + } |
|
418 | + |
|
419 | + /** |
|
420 | + * @When I want to change my password |
|
421 | + */ |
|
422 | + public function iWantToChangeMyPassword() |
|
423 | + { |
|
424 | + $mink = $this->minkContext; |
|
425 | + $url = $this->coreContext->generateUrl('/en/my/password'); |
|
426 | + $mink->getSession()->visit($url); |
|
427 | + } |
|
428 | 428 | |
429 | 429 | } |
430 | 430 | \ No newline at end of file |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | private $loggedInUser; |
71 | 71 | |
72 | - public function __construct($parameters=[]) |
|
72 | + public function __construct($parameters = []) |
|
73 | 73 | { |
74 | 74 | $defaultLoginInfo = [ |
75 | 75 | 'facebook' => [ |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | 'session_password-login' => getenv('LINKEDIN_USER_PASSWORD') |
82 | 82 | ], |
83 | 83 | ]; |
84 | - $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[]; |
|
85 | - $this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig); |
|
84 | + $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info'] : []; |
|
85 | + $this->socialLoginInfo = array_merge($defaultLoginInfo, $socialLoginConfig); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | static public function afterSuite(AfterSuiteScope $scope) |
93 | 93 | { |
94 | 94 | $repo = static::$userRepo; |
95 | - foreach(static::$users as $user){ |
|
96 | - if($repo->findByLogin($user->getLogin())){ |
|
97 | - try{ |
|
95 | + foreach (static::$users as $user) { |
|
96 | + if ($repo->findByLogin($user->getLogin())) { |
|
97 | + try { |
|
98 | 98 | JobContext::removeJobByUser($user); |
99 | - $repo->remove($user,true); |
|
100 | - }catch (\Exception $e){ |
|
99 | + $repo->remove($user, true); |
|
100 | + } catch (\Exception $e) { |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | } |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | { |
131 | 131 | $provider = strtolower($provider); |
132 | 132 | $mink = $this->minkContext; |
133 | - foreach($this->socialLoginInfo[$provider] as $field=>$value){ |
|
134 | - $mink->fillField($field,$value); |
|
133 | + foreach ($this->socialLoginInfo[$provider] as $field=>$value) { |
|
134 | + $mink->fillField($field, $value); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | * @Given I am logged in as a recruiter |
140 | 140 | * @Given I am logged in as a recruiter with :organization as organization |
141 | 141 | */ |
142 | - public function iAmLoggedInAsARecruiter($organization=null) |
|
142 | + public function iAmLoggedInAsARecruiter($organization = null) |
|
143 | 143 | { |
144 | 144 | $user = $this->thereIsAUserIdentifiedBy( |
145 | 145 | '[email protected]', |
146 | - 'test',User::ROLE_RECRUITER, |
|
146 | + 'test', User::ROLE_RECRUITER, |
|
147 | 147 | 'Test Recruiter', |
148 | 148 | $organization |
149 | 149 | ); |
150 | - $this->startLogin($user,'test'); |
|
150 | + $this->startLogin($user, 'test'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | public function iDonTHaveUser($login) |
158 | 158 | { |
159 | 159 | $repo = $this->getUserRepository(); |
160 | - $user=$repo->findByLogin($login); |
|
161 | - if($user instanceof UserInterface){ |
|
162 | - $repo->remove($user,true); |
|
160 | + $user = $repo->findByLogin($login); |
|
161 | + if ($user instanceof UserInterface) { |
|
162 | + $repo->remove($user, true); |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param $role |
169 | 169 | * @param TableNode $fields |
170 | 170 | */ |
171 | - public function iHaveUserWithTheFollowing($role,TableNode $fields) |
|
171 | + public function iHaveUserWithTheFollowing($role, TableNode $fields) |
|
172 | 172 | { |
173 | 173 | $normalizedFields = [ |
174 | 174 | 'login' => '[email protected]', |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | 'password' => 'test', |
178 | 178 | 'organization' => 'Cross Solution' |
179 | 179 | ]; |
180 | - foreach($fields->getRowsHash() as $field=>$value){ |
|
180 | + foreach ($fields->getRowsHash() as $field=>$value) { |
|
181 | 181 | $field = Inflector::camelize($field); |
182 | 182 | $normalizedFields[$field] = $value; |
183 | 183 | } |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function iAmLoggedInAsAnAdmin() |
199 | 199 | { |
200 | - $user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN); |
|
201 | - $this->startLogin($user,'test'); |
|
200 | + $user = $this->thereIsAUserIdentifiedBy('[email protected]', 'test', User::ROLE_ADMIN); |
|
201 | + $this->startLogin($user, 'test'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | private function startLogin(UserInterface $user, $password) |
205 | 205 | { |
206 | 206 | $currentUser = $this->currentUser; |
207 | - if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){ |
|
207 | + if (!is_object($currentUser) || $user->getId() != $currentUser->getId()) { |
|
208 | 208 | $this->iWantToLogIn(); |
209 | 209 | $this->iSpecifyTheUsernameAs($user->getLogin()); |
210 | 210 | $this->iSpecifyThePasswordAs($password); |
@@ -224,15 +224,15 @@ discard block |
||
224 | 224 | /** |
225 | 225 | * @Given there is a user :email identified by :password |
226 | 226 | */ |
227 | - public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null) |
|
227 | + public function thereIsAUserIdentifiedBy($email, $password, $role = User::ROLE_RECRUITER, $fullname = "Test Recruiter", $organization = null) |
|
228 | 228 | { |
229 | 229 | $repo = $this->getUserRepository(); |
230 | - if(!is_object($user=$repo->findByEmail($email))){ |
|
231 | - $user = $this->createUser($email,$password,$role,$fullname,$organization); |
|
230 | + if (!is_object($user = $repo->findByEmail($email))) { |
|
231 | + $user = $this->createUser($email, $password, $role, $fullname, $organization); |
|
232 | 232 | } |
233 | 233 | |
234 | - if(!is_null($organization)){ |
|
235 | - $this->iHaveMainOrganization($user,$organization); |
|
234 | + if (!is_null($organization)) { |
|
235 | + $this->iHaveMainOrganization($user, $organization); |
|
236 | 236 | } |
237 | 237 | $this->addCreatedUser($user); |
238 | 238 | return $user; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return \Auth\Entity\UserInterface |
249 | 249 | */ |
250 | - public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter") |
|
250 | + public function createUser($email, $password, $role = User::ROLE_RECRUITER, $fullname = "Test Recruiter") |
|
251 | 251 | { |
252 | 252 | /* @var Register $service */ |
253 | 253 | /* @var User $user */ |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | $user->setRole($role); |
259 | 259 | $settings = $user->getSettings('Applications'); |
260 | 260 | |
261 | - $expFullName = explode(' ',$fullname); |
|
261 | + $expFullName = explode(' ', $fullname); |
|
262 | 262 | $info = $user->getInfo(); |
263 | 263 | $info->setFirstName(array_shift($expFullName)); |
264 | - $info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):''); |
|
264 | + $info->setLastName(count($expFullName) > 0 ? implode(' ', $expFullName) : ''); |
|
265 | 265 | $info->setEmail($email); |
266 | 266 | $info->setEmailVerified(true); |
267 | 267 | $repo->store($user); |
@@ -286,19 +286,19 @@ discard block |
||
286 | 286 | * @When I have :organization as my main organization |
287 | 287 | * @param $orgName |
288 | 288 | */ |
289 | - public function iHaveMainOrganization(UserInterface $user,$orgName) |
|
289 | + public function iHaveMainOrganization(UserInterface $user, $orgName) |
|
290 | 290 | { |
291 | 291 | /* @var $repoOrganization OrganizationRepository */ |
292 | 292 | $repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization'); |
293 | - $organization=$repoOrganization->findByName($orgName); |
|
294 | - if(!$organization instanceof Organization){ |
|
293 | + $organization = $repoOrganization->findByName($orgName); |
|
294 | + if (!$organization instanceof Organization) { |
|
295 | 295 | $organization = new Organization(); |
296 | 296 | $organizationName = new OrganizationName($orgName); |
297 | 297 | $organization->setOrganizationName($organizationName); |
298 | 298 | $permissions = $organization->getPermissions(); |
299 | - $permissions->grant($user,Permissions::PERMISSION_ALL); |
|
300 | - }else { |
|
301 | - $organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL); |
|
299 | + $permissions->grant($user, Permissions::PERMISSION_ALL); |
|
300 | + } else { |
|
301 | + $organization->getPermissions()->grant($user, Permissions::PERMISSION_ALL); |
|
302 | 302 | } |
303 | 303 | $organization->setUser($user); |
304 | 304 | $repoOrganization->store($organization); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function iSpecifyTheUsernameAs($username) |
322 | 322 | { |
323 | - $this->minkContext->fillField('Login name',$username); |
|
323 | + $this->minkContext->fillField('Login name', $username); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | */ |
329 | 329 | public function iSpecifyThePasswordAs($password) |
330 | 330 | { |
331 | - $this->minkContext->fillField('Password',$password); |
|
331 | + $this->minkContext->fillField('Password', $password); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | $repo = $this->getUserRepository(); |
340 | 340 | $user = $repo->findByLogin($username); |
341 | 341 | |
342 | - if(!$user instanceof User){ |
|
343 | - throw new \Exception(sprintf('There is no user with this login: "%s"',$username)); |
|
342 | + if (!$user instanceof User) { |
|
343 | + throw new \Exception(sprintf('There is no user with this login: "%s"', $username)); |
|
344 | 344 | } |
345 | 345 | $this->currentUser = $user; |
346 | 346 | $this->iWantToLogIn(); |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | { |
398 | 398 | $repo = $this->getUserRepository(); |
399 | 399 | $data = $table->getRowsHash(); |
400 | - $email = isset($data['email']) ? $data['email']:'[email protected]'; |
|
401 | - $password = isset($data['password']) ? $data['password']:'test'; |
|
402 | - $fullname = isset($data['fullname']) ? $data['fullname']:'Test User'; |
|
403 | - $role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER; |
|
400 | + $email = isset($data['email']) ? $data['email'] : '[email protected]'; |
|
401 | + $password = isset($data['password']) ? $data['password'] : 'test'; |
|
402 | + $fullname = isset($data['fullname']) ? $data['fullname'] : 'Test User'; |
|
403 | + $role = isset($data['role']) ? $data['role'] : User::ROLE_RECRUITER; |
|
404 | 404 | |
405 | - if(!is_object($user=$repo->findByLogin($email))){ |
|
406 | - $user = $this->createUser($email,$password,$role,$fullname); |
|
405 | + if (!is_object($user = $repo->findByLogin($email))) { |
|
406 | + $user = $this->createUser($email, $password, $role, $fullname); |
|
407 | 407 | } |
408 | 408 | $this->currentUser = $user; |
409 | 409 | $this->addCreatedUser($user); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | |
412 | 412 | private function addCreatedUser(UserInterface $user) |
413 | 413 | { |
414 | - if(!in_array($user,static::$users)){ |
|
414 | + if (!in_array($user, static::$users)) { |
|
415 | 415 | static::$users[] = $user; |
416 | 416 | } |
417 | 417 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | try{ |
98 | 98 | JobContext::removeJobByUser($user); |
99 | 99 | $repo->remove($user,true); |
100 | - }catch (\Exception $e){ |
|
100 | + } catch (\Exception $e){ |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $organization->setOrganizationName($organizationName); |
298 | 298 | $permissions = $organization->getPermissions(); |
299 | 299 | $permissions->grant($user,Permissions::PERMISSION_ALL); |
300 | - }else { |
|
300 | + } else { |
|
301 | 301 | $organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL); |
302 | 302 | } |
303 | 303 | $organization->setUser($user); |
@@ -128,7 +128,6 @@ |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * @param ControllerManager $controllerManager |
|
132 | 131 | * @return CreatePaginator |
133 | 132 | * @codeCoverageIgnore |
134 | 133 | */ |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected $request; |
46 | 46 | |
47 | - /** |
|
48 | - * CreatePaginator constructor. |
|
49 | - * |
|
50 | - * @param ContainerInterface $container |
|
51 | - * @param HttpRequest $request |
|
52 | - */ |
|
47 | + /** |
|
48 | + * CreatePaginator constructor. |
|
49 | + * |
|
50 | + * @param ContainerInterface $container |
|
51 | + * @param HttpRequest $request |
|
52 | + */ |
|
53 | 53 | public function __construct(ContainerInterface $container, HttpRequest $request) |
54 | 54 | { |
55 | 55 | $this->serviceManager = $container->get('ServiceManager'); |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | /* @var \Core\EventManager\EventManager $events */ |
106 | 106 | /* @var \Zend\Paginator\Paginator $paginator */ |
107 | 107 | /* @var CreatePaginatorEvent $event */ |
108 | - $events = $this->serviceManager->get('Core/CreatePaginator/Events'); |
|
108 | + $events = $this->serviceManager->get('Core/CreatePaginator/Events'); |
|
109 | 109 | |
110 | - $event = $events->getEvent(CreatePaginatorEvent::EVENT_CREATE_PAGINATOR,$this,[ |
|
110 | + $event = $events->getEvent(CreatePaginatorEvent::EVENT_CREATE_PAGINATOR,$this,[ |
|
111 | 111 | 'paginatorParams' => $params, |
112 | 112 | 'paginators' => $paginators, |
113 | 113 | 'paginatorName' => $paginatorName |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | $paginator = $paginators->get($paginatorName,$params); |
122 | 122 | } |
123 | 123 | $paginator->setCurrentPageNumber(isset($params['page']) ? $params['page'] : 1) |
124 | - ->setItemCountPerPage(isset($params['count']) ? $params['count'] : 10) |
|
125 | - ->setPageRange(isset($params['range']) ? $params['range'] : 5); |
|
124 | + ->setItemCountPerPage(isset($params['count']) ? $params['count'] : 10) |
|
125 | + ->setPageRange(isset($params['range']) ? $params['range'] : 5); |
|
126 | 126 | |
127 | 127 | return $paginator; |
128 | 128 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | /* @var CreatePaginatorEvent $event */ |
108 | 108 | $events = $this->serviceManager->get('Core/CreatePaginator/Events'); |
109 | 109 | |
110 | - $event = $events->getEvent(CreatePaginatorEvent::EVENT_CREATE_PAGINATOR,$this,[ |
|
110 | + $event = $events->getEvent(CreatePaginatorEvent::EVENT_CREATE_PAGINATOR, $this, [ |
|
111 | 111 | 'paginatorParams' => $params, |
112 | 112 | 'paginators' => $paginators, |
113 | 113 | 'paginatorName' => $paginatorName |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | |
117 | 117 | $paginator = $event->getPaginator(); |
118 | 118 | |
119 | - if(!$paginator instanceof Paginator){ |
|
119 | + if (!$paginator instanceof Paginator) { |
|
120 | 120 | // no paginator created by listener, so let's create default paginator |
121 | - $paginator = $paginators->get($paginatorName,$params); |
|
121 | + $paginator = $paginators->get($paginatorName, $params); |
|
122 | 122 | } |
123 | 123 | $paginator->setCurrentPageNumber(isset($params['page']) ? $params['page'] : 1) |
124 | 124 | ->setItemCountPerPage(isset($params['count']) ? $params['count'] : 10) |
@@ -60,8 +60,8 @@ |
||
60 | 60 | * |
61 | 61 | * If no event instance is passed, it creates one prior to triggering. |
62 | 62 | * |
63 | - * @param EventInterface|string $eventName |
|
64 | - * @param object|string|null $target |
|
63 | + * @param EventInterface $eventName |
|
64 | + * @param \Core\Controller\AdminController $target |
|
65 | 65 | * @param array $argv |
66 | 66 | * |
67 | 67 | * @return \Zend\EventManager\ResponseCollection |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | return $event; |
56 | 56 | } |
57 | 57 | |
58 | - /** |
|
59 | - * Trigger an event. |
|
58 | + /** |
|
59 | + * Trigger an event. |
|
60 | 60 | * |
61 | 61 | * If no event instance is passed, it creates one prior to triggering. |
62 | 62 | * |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param array $argv |
66 | 66 | * |
67 | 67 | * @return \Zend\EventManager\ResponseCollection |
68 | - */ |
|
68 | + */ |
|
69 | 69 | public function trigger($eventName, $target = null, $argv = []) |
70 | 70 | { |
71 | 71 | $event = $eventName instanceOf EventInterface |
@@ -58,7 +58,7 @@ |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | - * @return mixed |
|
61 | + * @return null|string |
|
62 | 62 | */ |
63 | 63 | abstract protected function getUri(); |
64 | 64 |
@@ -38,15 +38,15 @@ |
||
38 | 38 | */ |
39 | 39 | protected $serviceLocator; |
40 | 40 | |
41 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
42 | - { |
|
43 | - $this->serviceLocator = $container; |
|
44 | - $service = new RestClient($this->getUri(), $this->getConfig()); |
|
45 | - return $service; |
|
46 | - } |
|
41 | + public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
42 | + { |
|
43 | + $this->serviceLocator = $container; |
|
44 | + $service = new RestClient($this->getUri(), $this->getConfig()); |
|
45 | + return $service; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
49 | + /** |
|
50 | 50 | * Create the settings service |
51 | 51 | * |
52 | 52 | * @param ServiceLocatorInterface $serviceLocator |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | protected $serviceLocator; |
40 | 40 | |
41 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
41 | + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
42 | 42 | { |
43 | 43 | $this->serviceLocator = $container; |
44 | 44 | $service = new RestClient($this->getUri(), $this->getConfig()); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function createService(ServiceLocatorInterface $serviceLocator) |
56 | 56 | { |
57 | - return $this($serviceLocator,RestClient::class); |
|
57 | + return $this($serviceLocator, RestClient::class); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -31,7 +31,7 @@ |
||
31 | 31 | * @param string $requestedName |
32 | 32 | * @param null|array $options |
33 | 33 | * |
34 | - * @return object |
|
34 | + * @return Locale |
|
35 | 35 | * @throws ServiceNotFoundException if unable to resolve the service. |
36 | 36 | * @throws ServiceNotCreatedException if an exception is raised when |
37 | 37 | * creating a service. |
@@ -41,7 +41,6 @@ |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | - * @param ContainerInterface $serviceLocator |
|
45 | 44 | * @return mixed|Paginator |
46 | 45 | */ |
47 | 46 | public function createService(ContainerInterface $container) |
@@ -28,19 +28,19 @@ |
||
28 | 28 | |
29 | 29 | public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
30 | 30 | { |
31 | - /* @var PaginatorService $paginatorService */ |
|
32 | - /* @var RepositoryService $repositories */ |
|
33 | - $repositories = $container->get('repositories'); |
|
34 | - $repository = $repositories->get($this->getRepository()); |
|
35 | - $queryBuilder = $repository->createQueryBuilder(); |
|
36 | - $filter = $container->get('FilterManager')->get($this->getFilter()); |
|
37 | - $adapter = new \Core\Paginator\Adapter\DoctrineMongoLateCursor($queryBuilder, $filter, $options); |
|
38 | - $service = new Paginator($adapter); |
|
31 | + /* @var PaginatorService $paginatorService */ |
|
32 | + /* @var RepositoryService $repositories */ |
|
33 | + $repositories = $container->get('repositories'); |
|
34 | + $repository = $repositories->get($this->getRepository()); |
|
35 | + $queryBuilder = $repository->createQueryBuilder(); |
|
36 | + $filter = $container->get('FilterManager')->get($this->getFilter()); |
|
37 | + $adapter = new \Core\Paginator\Adapter\DoctrineMongoLateCursor($queryBuilder, $filter, $options); |
|
38 | + $service = new Paginator($adapter); |
|
39 | 39 | |
40 | - return $service; |
|
40 | + return $service; |
|
41 | 41 | } |
42 | 42 | |
43 | - /** |
|
43 | + /** |
|
44 | 44 | * @param ContainerInterface $serviceLocator |
45 | 45 | * @return mixed|Paginator |
46 | 46 | */ |
@@ -26,7 +26,7 @@ |
||
26 | 26 | abstract class PaginatorFactoryAbstract implements FactoryInterface |
27 | 27 | { |
28 | 28 | |
29 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
29 | + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
30 | 30 | { |
31 | 31 | /* @var PaginatorService $paginatorService */ |
32 | 32 | /* @var RepositoryService $repositories */ |
@@ -86,7 +86,6 @@ |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * @param HelperPluginManager $helperPluginManager |
|
90 | 89 | * @return Services |
91 | 90 | */ |
92 | 91 | public static function factory($sm) |