@@ -54,6 +54,7 @@ |
||
54 | 54 | * ManageController constructor. |
55 | 55 | * |
56 | 56 | * @param RepositoryService $repositories |
57 | + * @param ContainerInterface $container |
|
57 | 58 | */ |
58 | 59 | public function __construct( |
59 | 60 | RepositoryService $repositories, |
@@ -30,70 +30,70 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class ManageController extends AbstractActionController |
32 | 32 | { |
33 | - /** |
|
34 | - * @var RepositoryService |
|
35 | - */ |
|
36 | - private $repositories; |
|
33 | + /** |
|
34 | + * @var RepositoryService |
|
35 | + */ |
|
36 | + private $repositories; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var |
|
40 | - */ |
|
41 | - private $coreNavigation; |
|
38 | + /** |
|
39 | + * @var |
|
40 | + */ |
|
41 | + private $coreNavigation; |
|
42 | 42 | |
43 | - private $forms; |
|
43 | + private $forms; |
|
44 | 44 | |
45 | - private $appOptions; |
|
45 | + private $appOptions; |
|
46 | 46 | |
47 | - private $appEvents; |
|
47 | + private $appEvents; |
|
48 | 48 | |
49 | - private $translator; |
|
49 | + private $translator; |
|
50 | 50 | |
51 | - private $container; |
|
51 | + private $container; |
|
52 | 52 | |
53 | - /** |
|
54 | - * ManageController constructor. |
|
55 | - * |
|
56 | - * @param RepositoryService $repositories |
|
57 | - */ |
|
58 | - public function __construct( |
|
59 | - RepositoryService $repositories, |
|
60 | - $coreNavigation, |
|
61 | - $forms, |
|
62 | - $appOptions, |
|
63 | - $appEvents, |
|
64 | - $translator, |
|
65 | - $container |
|
66 | - ) |
|
67 | - { |
|
68 | - $this->repositories = $repositories; |
|
69 | - $this->coreNavigation = $coreNavigation; |
|
70 | - $this->forms = $forms; |
|
71 | - $this->appOptions = $appOptions; |
|
72 | - $this->appEvents = $appEvents; |
|
73 | - $this->translator = $translator; |
|
74 | - $this->container = $container; |
|
75 | - } |
|
53 | + /** |
|
54 | + * ManageController constructor. |
|
55 | + * |
|
56 | + * @param RepositoryService $repositories |
|
57 | + */ |
|
58 | + public function __construct( |
|
59 | + RepositoryService $repositories, |
|
60 | + $coreNavigation, |
|
61 | + $forms, |
|
62 | + $appOptions, |
|
63 | + $appEvents, |
|
64 | + $translator, |
|
65 | + $container |
|
66 | + ) |
|
67 | + { |
|
68 | + $this->repositories = $repositories; |
|
69 | + $this->coreNavigation = $coreNavigation; |
|
70 | + $this->forms = $forms; |
|
71 | + $this->appOptions = $appOptions; |
|
72 | + $this->appEvents = $appEvents; |
|
73 | + $this->translator = $translator; |
|
74 | + $this->container = $container; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @param ContainerInterface $container |
|
79 | - * |
|
80 | - * @return ManageController |
|
81 | - */ |
|
82 | - static public function factory(ContainerInterface $container) |
|
83 | - { |
|
84 | - $ob = new self( |
|
85 | - $container->get('Core/RepositoryService'), |
|
86 | - $container->get('Core/Navigation'), |
|
87 | - $container->get('forms'), |
|
88 | - $container->get('Applications/Options'), |
|
89 | - $container->get('Applications/Events'), |
|
90 | - $container->get('translator'), |
|
91 | - $container |
|
92 | - ); |
|
93 | - return $ob; |
|
94 | - } |
|
77 | + /** |
|
78 | + * @param ContainerInterface $container |
|
79 | + * |
|
80 | + * @return ManageController |
|
81 | + */ |
|
82 | + static public function factory(ContainerInterface $container) |
|
83 | + { |
|
84 | + $ob = new self( |
|
85 | + $container->get('Core/RepositoryService'), |
|
86 | + $container->get('Core/Navigation'), |
|
87 | + $container->get('forms'), |
|
88 | + $container->get('Applications/Options'), |
|
89 | + $container->get('Applications/Events'), |
|
90 | + $container->get('translator'), |
|
91 | + $container |
|
92 | + ); |
|
93 | + return $ob; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
96 | + /** |
|
97 | 97 | * (non-PHPdoc) |
98 | 98 | * @see \Zend\Mvc\Controller\AbstractActionController::onDispatch() |
99 | 99 | */ |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $application->changeStatus( |
165 | 165 | $application->getStatus(), |
166 | 166 | sprintf(/*@translate*/ 'Application was read by %s', |
167 | - $this->auth()->getUser()->getInfo()->getDisplayName())); |
|
167 | + $this->auth()->getUser()->getInfo()->getDisplayName())); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | $viewModel->setVariables( |
192 | 192 | /*array( |
193 | 193 | 'application' => */$this->builders |
194 | - ->get('JsonApplication') |
|
195 | - ->unbuild($application) |
|
194 | + ->get('JsonApplication') |
|
195 | + ->unbuild($application) |
|
196 | 196 | ); |
197 | 197 | $viewModel->setVariable('isUnread', $applicationIsUnread); |
198 | 198 | $return = $viewModel; |
199 | 199 | break; |
200 | 200 | case 'pdf': |
201 | - // @TODO: [ZF3] Refactor this so we can inject Core/Html2Pdf service during controller creation |
|
202 | - $pdf = $this->container->get('Core/Html2Pdf'); |
|
201 | + // @TODO: [ZF3] Refactor this so we can inject Core/Html2Pdf service during controller creation |
|
202 | + $pdf = $this->container->get('Core/Html2Pdf'); |
|
203 | 203 | $return['format'] = $format; |
204 | 204 | break; |
205 | 205 | default: |
@@ -356,12 +356,12 @@ discard block |
||
356 | 356 | |
357 | 357 | /* @var ApplicationEvent $event */ |
358 | 358 | $event = $events->getEvent(ApplicationEvent::EVENT_APPLICATION_STATUS_CHANGE, |
359 | - $this, |
|
360 | - [ |
|
361 | - 'application' => $application, |
|
362 | - 'status' => $status, |
|
363 | - 'user' => $this->auth()->getUser(), |
|
364 | - ] |
|
359 | + $this, |
|
360 | + [ |
|
361 | + 'application' => $application, |
|
362 | + 'status' => $status, |
|
363 | + 'user' => $this->auth()->getUser(), |
|
364 | + ] |
|
365 | 365 | ); |
366 | 366 | |
367 | 367 | $event->setIsPostRequest($request->isPost()); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | $emailAddress = $this->params()->fromQuery('email'); |
412 | 412 | /* @var \Applications\Entity\Application $application */ |
413 | 413 | $application = $this->repositories->get('Applications/Application') |
414 | - ->find($this->params('id')); |
|
414 | + ->find($this->params('id')); |
|
415 | 415 | |
416 | 416 | $this->acl($application, 'forward'); |
417 | 417 |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $this->appOptions = $appOptions; |
72 | 72 | $this->appEvents = $appEvents; |
73 | 73 | $this->translator = $translator; |
74 | - $this->container = $container; |
|
74 | + $this->container = $container; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | |
171 | 171 | |
172 | - $format=$this->params()->fromQuery('format'); |
|
172 | + $format = $this->params()->fromQuery('format'); |
|
173 | 173 | |
174 | 174 | if ($application->isDraft()) { |
175 | 175 | $list = false; |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | && ($network = $this->params()->fromQuery('network')) |
298 | 298 | && ($data = $this->params()->fromPost('data')) |
299 | 299 | ) { |
300 | - $profileClass = '\\Auth\\Entity\\SocialProfiles\\' . $network; |
|
300 | + $profileClass = '\\Auth\\Entity\\SocialProfiles\\'.$network; |
|
301 | 301 | $profile = new $profileClass(); |
302 | 302 | $profile->setData(\Zend\Json\Json::decode($data, \Zend\Json\Json::TYPE_ARRAY)); |
303 | 303 | } else { |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | $event->setIsPostRequest($request->isPost()); |
368 | 368 | $event->setPostData($request->getPost()); |
369 | - $events->trigger($event->getName(),$event); |
|
369 | + $events->trigger($event->getName(), $event); |
|
370 | 370 | |
371 | 371 | $params = $event->getFormData(); |
372 | 372 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | |
416 | 416 | $this->acl($application, 'forward'); |
417 | 417 | |
418 | - $translator = $this->translator; |
|
418 | + $translator = $this->translator; |
|
419 | 419 | |
420 | 420 | if (!$emailAddress) { |
421 | 421 | throw new \InvalidArgumentException('An email address must be supplied.'); |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | public function deleteAction() |
456 | 456 | { |
457 | 457 | $id = $this->params('id'); |
458 | - $repositories= $this->repositories; |
|
458 | + $repositories = $this->repositories; |
|
459 | 459 | $repository = $repositories->get('Applications/Application'); |
460 | 460 | $application = $repository->find($id); |
461 | 461 | |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | |
466 | 466 | $this->acl($application, 'delete'); |
467 | 467 | |
468 | - $events = $this->appEvents; |
|
469 | - $events->trigger(ApplicationEvent::EVENT_APPLICATION_PRE_DELETE, $this, [ 'application' => $application ]); |
|
468 | + $events = $this->appEvents; |
|
469 | + $events->trigger(ApplicationEvent::EVENT_APPLICATION_PRE_DELETE, $this, ['application' => $application]); |
|
470 | 470 | |
471 | 471 | $repositories->remove($application); |
472 | 472 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | * @param string $requestedName |
26 | 26 | * @param null|array $options |
27 | 27 | * |
28 | - * @return object |
|
28 | + * @return RegisterConfirmation |
|
29 | 29 | * @throws ServiceNotFoundException if unable to resolve the service. |
30 | 30 | * @throws ServiceNotCreatedException if an exception is raised when |
31 | 31 | * creating a service. |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * @param string $requestedName |
25 | 25 | * @param null|array $options |
26 | 26 | * |
27 | - * @return object |
|
27 | + * @return UserUniqueTokenGenerator |
|
28 | 28 | * @throws ServiceNotFoundException if unable to resolve the service. |
29 | 29 | * @throws ServiceNotCreatedException if an exception is raised when |
30 | 30 | * creating a service. |
@@ -54,6 +54,9 @@ discard block |
||
54 | 54 | return $this->coreContext->generateUrl($url); |
55 | 55 | } |
56 | 56 | |
57 | + /** |
|
58 | + * @param string $url |
|
59 | + */ |
|
57 | 60 | public function visit($url) |
58 | 61 | { |
59 | 62 | $this->coreContext->iVisit($this->generateUrl($url)); |
@@ -69,7 +72,7 @@ discard block |
||
69 | 72 | } |
70 | 73 | |
71 | 74 | /** |
72 | - * @param $id |
|
75 | + * @param string $id |
|
73 | 76 | * |
74 | 77 | * @return RepositoryInterface |
75 | 78 | */ |
@@ -16,73 +16,73 @@ |
||
16 | 16 | |
17 | 17 | trait CommonContextTrait |
18 | 18 | { |
19 | - /** |
|
20 | - * @var MinkContext |
|
21 | - */ |
|
22 | - protected $minkContext; |
|
19 | + /** |
|
20 | + * @var MinkContext |
|
21 | + */ |
|
22 | + protected $minkContext; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var CoreContext |
|
26 | - */ |
|
27 | - protected $coreContext; |
|
24 | + /** |
|
25 | + * @var CoreContext |
|
26 | + */ |
|
27 | + protected $coreContext; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @var UserContext |
|
31 | - */ |
|
32 | - protected $userContext; |
|
29 | + /** |
|
30 | + * @var UserContext |
|
31 | + */ |
|
32 | + protected $userContext; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var SummaryFormContext |
|
36 | - */ |
|
37 | - protected $summaryFormContext; |
|
34 | + /** |
|
35 | + * @var SummaryFormContext |
|
36 | + */ |
|
37 | + protected $summaryFormContext; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @BeforeScenario |
|
41 | - * |
|
42 | - * @param BeforeScenarioScope $scope |
|
43 | - */ |
|
44 | - public function gatherContexts(BeforeScenarioScope $scope) |
|
45 | - { |
|
46 | - $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
47 | - $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
48 | - $this->userContext = $scope->getEnvironment()->getContext(UserContext::class); |
|
49 | - $this->summaryFormContext = $scope->getEnvironment()->getContext(SummaryFormContext::class); |
|
50 | - } |
|
39 | + /** |
|
40 | + * @BeforeScenario |
|
41 | + * |
|
42 | + * @param BeforeScenarioScope $scope |
|
43 | + */ |
|
44 | + public function gatherContexts(BeforeScenarioScope $scope) |
|
45 | + { |
|
46 | + $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
47 | + $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
48 | + $this->userContext = $scope->getEnvironment()->getContext(UserContext::class); |
|
49 | + $this->summaryFormContext = $scope->getEnvironment()->getContext(SummaryFormContext::class); |
|
50 | + } |
|
51 | 51 | |
52 | - public function generateUrl($url) |
|
53 | - { |
|
54 | - return $this->coreContext->generateUrl($url); |
|
55 | - } |
|
52 | + public function generateUrl($url) |
|
53 | + { |
|
54 | + return $this->coreContext->generateUrl($url); |
|
55 | + } |
|
56 | 56 | |
57 | - public function visit($url) |
|
58 | - { |
|
59 | - $this->coreContext->iVisit($this->generateUrl($url)); |
|
60 | - } |
|
57 | + public function visit($url) |
|
58 | + { |
|
59 | + $this->coreContext->iVisit($this->generateUrl($url)); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param $id |
|
64 | - * @return mixed|object |
|
65 | - */ |
|
66 | - public function getService($id) |
|
67 | - { |
|
68 | - return $this->coreContext->getServiceManager()->get($id); |
|
69 | - } |
|
62 | + /** |
|
63 | + * @param $id |
|
64 | + * @return mixed|object |
|
65 | + */ |
|
66 | + public function getService($id) |
|
67 | + { |
|
68 | + return $this->coreContext->getServiceManager()->get($id); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @param $id |
|
73 | - * |
|
74 | - * @return RepositoryInterface |
|
75 | - */ |
|
76 | - public function getRepository($id) |
|
77 | - { |
|
78 | - return $this->coreContext->getRepositories()->get($id); |
|
79 | - } |
|
71 | + /** |
|
72 | + * @param $id |
|
73 | + * |
|
74 | + * @return RepositoryInterface |
|
75 | + */ |
|
76 | + public function getRepository($id) |
|
77 | + { |
|
78 | + return $this->coreContext->getRepositories()->get($id); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return \Auth\Entity\User |
|
83 | - */ |
|
84 | - public function getCurrentUser() |
|
85 | - { |
|
86 | - return $this->userContext->getCurrentUser(); |
|
87 | - } |
|
81 | + /** |
|
82 | + * @return \Auth\Entity\User |
|
83 | + */ |
|
84 | + public function getCurrentUser() |
|
85 | + { |
|
86 | + return $this->userContext->getCurrentUser(); |
|
87 | + } |
|
88 | 88 | } |
89 | 89 | \ No newline at end of file |
@@ -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 | { |
@@ -22,244 +22,244 @@ |
||
22 | 22 | */ |
23 | 23 | class CoreContext extends RawMinkContext |
24 | 24 | { |
25 | - static protected $application; |
|
25 | + static protected $application; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var MinkContext |
|
29 | - */ |
|
30 | - protected $minkContext; |
|
27 | + /** |
|
28 | + * @var MinkContext |
|
29 | + */ |
|
30 | + protected $minkContext; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @BeforeScenario |
|
34 | - * @param BeforeScenarioScope $scope |
|
35 | - */ |
|
36 | - public function gatherContexts(BeforeScenarioScope $scope) |
|
37 | - { |
|
38 | - $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
39 | - } |
|
32 | + /** |
|
33 | + * @BeforeScenario |
|
34 | + * @param BeforeScenarioScope $scope |
|
35 | + */ |
|
36 | + public function gatherContexts(BeforeScenarioScope $scope) |
|
37 | + { |
|
38 | + $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @return Application |
|
43 | - */ |
|
44 | - public function getApplication() |
|
45 | - { |
|
46 | - if(!is_object(static::$application)){ |
|
47 | - $configFile = realpath(__DIR__.'/../../../config/config.php'); |
|
48 | - $config = include($configFile); |
|
49 | - static::$application = Application::init($config); |
|
50 | - } |
|
51 | - return static::$application; |
|
52 | - } |
|
41 | + /** |
|
42 | + * @return Application |
|
43 | + */ |
|
44 | + public function getApplication() |
|
45 | + { |
|
46 | + if(!is_object(static::$application)){ |
|
47 | + $configFile = realpath(__DIR__.'/../../../config/config.php'); |
|
48 | + $config = include($configFile); |
|
49 | + static::$application = Application::init($config); |
|
50 | + } |
|
51 | + return static::$application; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return \Zend\ServiceManager\ServiceManager |
|
56 | - */ |
|
57 | - public function getServiceManager() |
|
58 | - { |
|
59 | - return $this->getApplication()->getServiceManager(); |
|
60 | - } |
|
54 | + /** |
|
55 | + * @return \Zend\ServiceManager\ServiceManager |
|
56 | + */ |
|
57 | + public function getServiceManager() |
|
58 | + { |
|
59 | + return $this->getApplication()->getServiceManager(); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return \Zend\EventManager\EventManagerInterface |
|
64 | - */ |
|
65 | - public function getEventManager() |
|
66 | - { |
|
67 | - return $this->getApplication()->getEventManager(); |
|
68 | - } |
|
62 | + /** |
|
63 | + * @return \Zend\EventManager\EventManagerInterface |
|
64 | + */ |
|
65 | + public function getEventManager() |
|
66 | + { |
|
67 | + return $this->getApplication()->getEventManager(); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @return RepositoryService |
|
72 | - */ |
|
73 | - public function getRepositories() |
|
74 | - { |
|
75 | - return $this->getServiceManager()->get('repositories'); |
|
76 | - } |
|
70 | + /** |
|
71 | + * @return RepositoryService |
|
72 | + */ |
|
73 | + public function getRepositories() |
|
74 | + { |
|
75 | + return $this->getServiceManager()->get('repositories'); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param $name |
|
80 | - * @param array $params |
|
81 | - * |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function generateUrl($name) |
|
85 | - { |
|
86 | - return $this->minkContext->locatePath($name); |
|
87 | - } |
|
78 | + /** |
|
79 | + * @param $name |
|
80 | + * @param array $params |
|
81 | + * |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function generateUrl($name) |
|
85 | + { |
|
86 | + return $this->minkContext->locatePath($name); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @When /^I hover over the element "([^"]*)"$/ |
|
91 | - */ |
|
92 | - public function iHoverOverTheElement($locator) |
|
93 | - { |
|
94 | - $session = $this->minkContext->getSession(); // get the mink session |
|
95 | - $element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element |
|
89 | + /** |
|
90 | + * @When /^I hover over the element "([^"]*)"$/ |
|
91 | + */ |
|
92 | + public function iHoverOverTheElement($locator) |
|
93 | + { |
|
94 | + $session = $this->minkContext->getSession(); // get the mink session |
|
95 | + $element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element |
|
96 | 96 | |
97 | - // errors must not pass silently |
|
98 | - if (null === $element) { |
|
99 | - throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator)); |
|
100 | - } |
|
97 | + // errors must not pass silently |
|
98 | + if (null === $element) { |
|
99 | + throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator)); |
|
100 | + } |
|
101 | 101 | |
102 | - // ok, let's hover it |
|
103 | - $element->mouseOver(); |
|
104 | - } |
|
102 | + // ok, let's hover it |
|
103 | + $element->mouseOver(); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * @Given /^I wait for (\d+) seconds$/ |
|
108 | - */ |
|
109 | - public function iWaitForSecond($second) |
|
110 | - { |
|
111 | - sleep($second); |
|
112 | - } |
|
106 | + /** |
|
107 | + * @Given /^I wait for (\d+) seconds$/ |
|
108 | + */ |
|
109 | + public function iWaitForSecond($second) |
|
110 | + { |
|
111 | + sleep($second); |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * @Then /^I wait for the ajax response$/ |
|
116 | - */ |
|
117 | - public function iWaitForTheAjaxResponse() |
|
118 | - { |
|
119 | - $this->getSession()->wait(5000, '(0 === jQuery.active)'); |
|
120 | - } |
|
114 | + /** |
|
115 | + * @Then /^I wait for the ajax response$/ |
|
116 | + */ |
|
117 | + public function iWaitForTheAjaxResponse() |
|
118 | + { |
|
119 | + $this->getSession()->wait(5000, '(0 === jQuery.active)'); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Some forms do not have a Submit button just pass the ID |
|
124 | - * |
|
125 | - * @Given /^I submit the form with id "([^"]*)"$/ |
|
126 | - */ |
|
127 | - public function iSubmitTheFormWithId($arg) |
|
128 | - { |
|
129 | - $node = $this->minkContext->getSession()->getPage()->find('css', $arg); |
|
130 | - if($node) { |
|
131 | - $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();"); |
|
132 | - } else { |
|
133 | - throw new \Exception('Element not found'); |
|
134 | - } |
|
135 | - } |
|
122 | + /** |
|
123 | + * Some forms do not have a Submit button just pass the ID |
|
124 | + * |
|
125 | + * @Given /^I submit the form with id "([^"]*)"$/ |
|
126 | + */ |
|
127 | + public function iSubmitTheFormWithId($arg) |
|
128 | + { |
|
129 | + $node = $this->minkContext->getSession()->getPage()->find('css', $arg); |
|
130 | + if($node) { |
|
131 | + $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();"); |
|
132 | + } else { |
|
133 | + throw new \Exception('Element not found'); |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * @Then I switch to popup :name |
|
139 | - * |
|
140 | - * @param $name |
|
141 | - */ |
|
142 | - public function iSwitchToPopup($name) |
|
143 | - { |
|
144 | - $this->iSetMainWindowName(); |
|
145 | - $this->getSession()->switchToWindow($name); |
|
146 | - } |
|
137 | + /** |
|
138 | + * @Then I switch to popup :name |
|
139 | + * |
|
140 | + * @param $name |
|
141 | + */ |
|
142 | + public function iSwitchToPopup($name) |
|
143 | + { |
|
144 | + $this->iSetMainWindowName(); |
|
145 | + $this->getSession()->switchToWindow($name); |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * @Then I set main window name |
|
150 | - */ |
|
151 | - public function iSetMainWindowName() |
|
152 | - { |
|
153 | - $window_name = 'main_window'; |
|
154 | - $script = 'window.name = "' . $window_name . '"'; |
|
155 | - $this->getSession()->executeScript($script); |
|
156 | - } |
|
148 | + /** |
|
149 | + * @Then I set main window name |
|
150 | + */ |
|
151 | + public function iSetMainWindowName() |
|
152 | + { |
|
153 | + $window_name = 'main_window'; |
|
154 | + $script = 'window.name = "' . $window_name . '"'; |
|
155 | + $this->getSession()->executeScript($script); |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * @Then I switch back to main window |
|
160 | - */ |
|
161 | - public function iSwitchBackToMainWindow() |
|
162 | - { |
|
163 | - $this->getSession()->switchToWindow('main_window'); |
|
164 | - } |
|
158 | + /** |
|
159 | + * @Then I switch back to main window |
|
160 | + */ |
|
161 | + public function iSwitchBackToMainWindow() |
|
162 | + { |
|
163 | + $this->getSession()->switchToWindow('main_window'); |
|
164 | + } |
|
165 | 165 | |
166 | - public function iVisit($url) |
|
167 | - { |
|
168 | - $this->minkContext->getSession()->visit($url); |
|
169 | - } |
|
166 | + public function iVisit($url) |
|
167 | + { |
|
168 | + $this->minkContext->getSession()->visit($url); |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * @When I scroll :selector into view |
|
173 | - * |
|
174 | - * @param string $selector Allowed selectors: #id, .className, //xpath |
|
175 | - * |
|
176 | - * @throws \Exception |
|
177 | - */ |
|
178 | - public function scrollIntoView($selector) |
|
179 | - { |
|
180 | - $locator = substr($selector, 0, 1); |
|
171 | + /** |
|
172 | + * @When I scroll :selector into view |
|
173 | + * |
|
174 | + * @param string $selector Allowed selectors: #id, .className, //xpath |
|
175 | + * |
|
176 | + * @throws \Exception |
|
177 | + */ |
|
178 | + public function scrollIntoView($selector) |
|
179 | + { |
|
180 | + $locator = substr($selector, 0, 1); |
|
181 | 181 | |
182 | - switch ($locator) { |
|
183 | - case '/' : // XPath selector |
|
184 | - $function = <<<JS |
|
182 | + switch ($locator) { |
|
183 | + case '/' : // XPath selector |
|
184 | + $function = <<<JS |
|
185 | 185 | (function(){ |
186 | 186 | var elem = document.evaluate($selector, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; |
187 | 187 | elem.scrollIntoView(false); |
188 | 188 | })() |
189 | 189 | JS; |
190 | - break; |
|
190 | + break; |
|
191 | 191 | |
192 | - case '#' : // ID selector |
|
193 | - $selector = substr($selector, 1); |
|
194 | - $function = <<<JS |
|
192 | + case '#' : // ID selector |
|
193 | + $selector = substr($selector, 1); |
|
194 | + $function = <<<JS |
|
195 | 195 | (function(){ |
196 | 196 | var elem = document.getElementById("$selector"); |
197 | 197 | elem.scrollIntoView(false); |
198 | 198 | })() |
199 | 199 | JS; |
200 | - break; |
|
200 | + break; |
|
201 | 201 | |
202 | - case '.' : // Class selector |
|
203 | - $selector = substr($selector, 1); |
|
204 | - $function = <<<JS |
|
202 | + case '.' : // Class selector |
|
203 | + $selector = substr($selector, 1); |
|
204 | + $function = <<<JS |
|
205 | 205 | (function(){ |
206 | 206 | var elem = document.getElementsByClassName("$selector"); |
207 | 207 | elem[0].scrollIntoView(false); |
208 | 208 | })() |
209 | 209 | JS; |
210 | - break; |
|
210 | + break; |
|
211 | 211 | |
212 | - default: |
|
213 | - throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath'); |
|
214 | - break; |
|
215 | - } |
|
212 | + default: |
|
213 | + throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath'); |
|
214 | + break; |
|
215 | + } |
|
216 | 216 | |
217 | - try { |
|
218 | - $this->getSession()->executeScript($function); |
|
219 | - } catch (\Exception $e) { |
|
220 | - throw new \Exception(__METHOD__ . ' failed'); |
|
221 | - } |
|
222 | - } |
|
217 | + try { |
|
218 | + $this->getSession()->executeScript($function); |
|
219 | + } catch (\Exception $e) { |
|
220 | + throw new \Exception(__METHOD__ . ' failed'); |
|
221 | + } |
|
222 | + } |
|
223 | 223 | |
224 | 224 | |
225 | - /** |
|
226 | - * @When I click location selector |
|
227 | - */ |
|
228 | - public function iClickLocationSelector() |
|
229 | - { |
|
230 | - $locator = '#jobBase-geoLocation-span .select2'; |
|
231 | - $element = $this->getElement($locator); |
|
232 | - $element->click(); |
|
233 | - } |
|
225 | + /** |
|
226 | + * @When I click location selector |
|
227 | + */ |
|
228 | + public function iClickLocationSelector() |
|
229 | + { |
|
230 | + $locator = '#jobBase-geoLocation-span .select2'; |
|
231 | + $element = $this->getElement($locator); |
|
232 | + $element->click(); |
|
233 | + } |
|
234 | 234 | |
235 | - /** |
|
236 | - * @param $locator |
|
237 | - * @param string $selector |
|
238 | - * |
|
239 | - * @return \Behat\Mink\Element\NodeElement|mixed|null |
|
240 | - */ |
|
241 | - public function getElement($locator,$selector='css') |
|
242 | - { |
|
243 | - $page = $this->minkContext->getSession()->getPage(); |
|
244 | - $element = $page->find('css',$locator); |
|
245 | - return $element; |
|
246 | - } |
|
235 | + /** |
|
236 | + * @param $locator |
|
237 | + * @param string $selector |
|
238 | + * |
|
239 | + * @return \Behat\Mink\Element\NodeElement|mixed|null |
|
240 | + */ |
|
241 | + public function getElement($locator,$selector='css') |
|
242 | + { |
|
243 | + $page = $this->minkContext->getSession()->getPage(); |
|
244 | + $element = $page->find('css',$locator); |
|
245 | + return $element; |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * @When I fill in location search with :term |
|
250 | - * @param $term |
|
251 | - */ |
|
252 | - public function iFillInLocationSearch($term) |
|
253 | - { |
|
254 | - $locator = '.select2-container--open .select2-search__field'; |
|
255 | - $element = $this->getElement($locator); |
|
256 | - $element->focus(); |
|
257 | - $element->setValue($term); |
|
258 | - $this->iWaitForTheAjaxResponse(); |
|
259 | - } |
|
248 | + /** |
|
249 | + * @When I fill in location search with :term |
|
250 | + * @param $term |
|
251 | + */ |
|
252 | + public function iFillInLocationSearch($term) |
|
253 | + { |
|
254 | + $locator = '.select2-container--open .select2-search__field'; |
|
255 | + $element = $this->getElement($locator); |
|
256 | + $element->focus(); |
|
257 | + $element->setValue($term); |
|
258 | + $this->iWaitForTheAjaxResponse(); |
|
259 | + } |
|
260 | 260 | |
261 | - public function iClickOn() |
|
262 | - { |
|
261 | + public function iClickOn() |
|
262 | + { |
|
263 | 263 | |
264 | - } |
|
264 | + } |
|
265 | 265 | } |
266 | 266 | \ No newline at end of file |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function getApplication() |
45 | 45 | { |
46 | - if(!is_object(static::$application)){ |
|
46 | + if (!is_object(static::$application)) { |
|
47 | 47 | $configFile = realpath(__DIR__.'/../../../config/config.php'); |
48 | 48 | $config = include($configFile); |
49 | 49 | static::$application = Application::init($config); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | public function iSubmitTheFormWithId($arg) |
128 | 128 | { |
129 | 129 | $node = $this->minkContext->getSession()->getPage()->find('css', $arg); |
130 | - if($node) { |
|
130 | + if ($node) { |
|
131 | 131 | $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();"); |
132 | 132 | } else { |
133 | 133 | throw new \Exception('Element not found'); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | public function iSetMainWindowName() |
152 | 152 | { |
153 | 153 | $window_name = 'main_window'; |
154 | - $script = 'window.name = "' . $window_name . '"'; |
|
154 | + $script = 'window.name = "'.$window_name.'"'; |
|
155 | 155 | $this->getSession()->executeScript($script); |
156 | 156 | } |
157 | 157 | |
@@ -210,14 +210,14 @@ discard block |
||
210 | 210 | break; |
211 | 211 | |
212 | 212 | default: |
213 | - throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath'); |
|
213 | + throw new \Exception(__METHOD__.' Couldn\'t find selector: '.$selector.' - Allowed selectors: #id, .className, //xpath'); |
|
214 | 214 | break; |
215 | 215 | } |
216 | 216 | |
217 | 217 | try { |
218 | 218 | $this->getSession()->executeScript($function); |
219 | 219 | } catch (\Exception $e) { |
220 | - throw new \Exception(__METHOD__ . ' failed'); |
|
220 | + throw new \Exception(__METHOD__.' failed'); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return \Behat\Mink\Element\NodeElement|mixed|null |
240 | 240 | */ |
241 | - public function getElement($locator,$selector='css') |
|
241 | + public function getElement($locator, $selector = 'css') |
|
242 | 242 | { |
243 | 243 | $page = $this->minkContext->getSession()->getPage(); |
244 | - $element = $page->find('css',$locator); |
|
244 | + $element = $page->find('css', $locator); |
|
245 | 245 | return $element; |
246 | 246 | } |
247 | 247 |
@@ -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 | { |
@@ -29,384 +29,384 @@ |
||
29 | 29 | |
30 | 30 | class UserContext implements Context |
31 | 31 | { |
32 | - /** |
|
33 | - * @var CoreContext |
|
34 | - */ |
|
35 | - private $coreContext; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var MinkContext |
|
39 | - */ |
|
40 | - private $minkContext; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var User |
|
44 | - */ |
|
45 | - private $currentUser; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var User[] |
|
49 | - */ |
|
50 | - static private $users = []; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var UserRepository |
|
54 | - */ |
|
55 | - static private $userRepo; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - static private $currentSession; |
|
61 | - |
|
62 | - private $socialLoginInfo = []; |
|
63 | - |
|
64 | - /** |
|
65 | - * @var UserInterface |
|
66 | - */ |
|
67 | - private $loggedInUser; |
|
68 | - |
|
69 | - public function __construct($parameters=[]) |
|
70 | - { |
|
71 | - $defaultLoginInfo = [ |
|
72 | - 'facebook' => [ |
|
73 | - 'email' => getenv('FACEBOOK_USER_EMAIL'), |
|
74 | - 'pass' => getenv('FACEBOOK_USER_PASSWORD') |
|
75 | - ], |
|
76 | - 'linkedin' => [ |
|
77 | - 'session_key-login' => getenv('LINKEDIN_USER_EMAIL'), |
|
78 | - 'session_password-login' => getenv('LINKEDIN_USER_PASSWORD') |
|
79 | - ], |
|
80 | - ]; |
|
81 | - $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[]; |
|
82 | - $this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @AfterSuite |
|
87 | - * @param AfterSuiteScope $scope |
|
88 | - */ |
|
89 | - static public function afterSuite(AfterSuiteScope $scope) |
|
90 | - { |
|
91 | - $repo = static::$userRepo; |
|
92 | - foreach(static::$users as $user){ |
|
93 | - if($repo->findByLogin($user->getLogin())){ |
|
94 | - try{ |
|
95 | - JobContext::removeJobByUser($user); |
|
96 | - $repo->remove($user,true); |
|
97 | - }catch (\Exception $e){ |
|
32 | + /** |
|
33 | + * @var CoreContext |
|
34 | + */ |
|
35 | + private $coreContext; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var MinkContext |
|
39 | + */ |
|
40 | + private $minkContext; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var User |
|
44 | + */ |
|
45 | + private $currentUser; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var User[] |
|
49 | + */ |
|
50 | + static private $users = []; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var UserRepository |
|
54 | + */ |
|
55 | + static private $userRepo; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + static private $currentSession; |
|
61 | + |
|
62 | + private $socialLoginInfo = []; |
|
63 | + |
|
64 | + /** |
|
65 | + * @var UserInterface |
|
66 | + */ |
|
67 | + private $loggedInUser; |
|
68 | + |
|
69 | + public function __construct($parameters=[]) |
|
70 | + { |
|
71 | + $defaultLoginInfo = [ |
|
72 | + 'facebook' => [ |
|
73 | + 'email' => getenv('FACEBOOK_USER_EMAIL'), |
|
74 | + 'pass' => getenv('FACEBOOK_USER_PASSWORD') |
|
75 | + ], |
|
76 | + 'linkedin' => [ |
|
77 | + 'session_key-login' => getenv('LINKEDIN_USER_EMAIL'), |
|
78 | + 'session_password-login' => getenv('LINKEDIN_USER_PASSWORD') |
|
79 | + ], |
|
80 | + ]; |
|
81 | + $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[]; |
|
82 | + $this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig); |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * @AfterSuite |
|
87 | + * @param AfterSuiteScope $scope |
|
88 | + */ |
|
89 | + static public function afterSuite(AfterSuiteScope $scope) |
|
90 | + { |
|
91 | + $repo = static::$userRepo; |
|
92 | + foreach(static::$users as $user){ |
|
93 | + if($repo->findByLogin($user->getLogin())){ |
|
94 | + try{ |
|
95 | + JobContext::removeJobByUser($user); |
|
96 | + $repo->remove($user,true); |
|
97 | + }catch (\Exception $e){ |
|
98 | 98 | |
99 | - } |
|
100 | - } |
|
101 | - } |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * @BeforeScenario |
|
106 | - * @param BeforeScenarioScope $scope |
|
107 | - */ |
|
108 | - public function beforeScenario(BeforeScenarioScope $scope) |
|
109 | - { |
|
110 | - $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
111 | - $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
112 | - static::$userRepo = $this->getUserRepository(); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @return User |
|
117 | - */ |
|
118 | - public function getCurrentUser() |
|
119 | - { |
|
120 | - return $this->currentUser; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * @When I fill in login form with :provider user |
|
125 | - */ |
|
126 | - public function iSignInWithSocialUser($provider) |
|
127 | - { |
|
128 | - $provider = strtolower($provider); |
|
129 | - $mink = $this->minkContext; |
|
130 | - foreach($this->socialLoginInfo[$provider] as $field=>$value){ |
|
131 | - $mink->fillField($field,$value); |
|
132 | - } |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @Given I am logged in as a recruiter |
|
137 | - * @Given I am logged in as a recruiter with :organization as organization |
|
138 | - */ |
|
139 | - public function iAmLoggedInAsARecruiter($organization=null) |
|
140 | - { |
|
141 | - $user = $this->thereIsAUserIdentifiedBy( |
|
142 | - '[email protected]', |
|
143 | - 'test',User::ROLE_RECRUITER, |
|
144 | - 'Test Recruiter', |
|
145 | - $organization |
|
146 | - ); |
|
147 | - $this->startLogin($user,'test'); |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * @Given I don't have :login user |
|
152 | - * @param string $login |
|
153 | - */ |
|
154 | - public function iDonTHaveUser($login) |
|
155 | - { |
|
156 | - $repo = $this->getUserRepository(); |
|
157 | - $user=$repo->findByLogin($login); |
|
158 | - if($user instanceof UserInterface){ |
|
159 | - $repo->remove($user,true); |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * @Given I have a :role with the following: |
|
165 | - * @param $role |
|
166 | - * @param TableNode $fields |
|
167 | - */ |
|
168 | - public function iHaveUserWithTheFollowing($role,TableNode $fields) |
|
169 | - { |
|
170 | - $normalizedFields = [ |
|
171 | - 'login' => '[email protected]', |
|
172 | - 'fullname' => 'Test Login', |
|
173 | - 'role' => User::ROLE_USER, |
|
174 | - 'password' => 'test', |
|
175 | - 'organization' => 'Cross Solution' |
|
176 | - ]; |
|
177 | - foreach($fields->getRowsHash() as $field=>$value){ |
|
178 | - $field = Inflector::camelize($field); |
|
179 | - $normalizedFields[$field] = $value; |
|
180 | - } |
|
99 | + } |
|
100 | + } |
|
101 | + } |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * @BeforeScenario |
|
106 | + * @param BeforeScenarioScope $scope |
|
107 | + */ |
|
108 | + public function beforeScenario(BeforeScenarioScope $scope) |
|
109 | + { |
|
110 | + $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class); |
|
111 | + $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class); |
|
112 | + static::$userRepo = $this->getUserRepository(); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * @return User |
|
117 | + */ |
|
118 | + public function getCurrentUser() |
|
119 | + { |
|
120 | + return $this->currentUser; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * @When I fill in login form with :provider user |
|
125 | + */ |
|
126 | + public function iSignInWithSocialUser($provider) |
|
127 | + { |
|
128 | + $provider = strtolower($provider); |
|
129 | + $mink = $this->minkContext; |
|
130 | + foreach($this->socialLoginInfo[$provider] as $field=>$value){ |
|
131 | + $mink->fillField($field,$value); |
|
132 | + } |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * @Given I am logged in as a recruiter |
|
137 | + * @Given I am logged in as a recruiter with :organization as organization |
|
138 | + */ |
|
139 | + public function iAmLoggedInAsARecruiter($organization=null) |
|
140 | + { |
|
141 | + $user = $this->thereIsAUserIdentifiedBy( |
|
142 | + '[email protected]', |
|
143 | + 'test',User::ROLE_RECRUITER, |
|
144 | + 'Test Recruiter', |
|
145 | + $organization |
|
146 | + ); |
|
147 | + $this->startLogin($user,'test'); |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * @Given I don't have :login user |
|
152 | + * @param string $login |
|
153 | + */ |
|
154 | + public function iDonTHaveUser($login) |
|
155 | + { |
|
156 | + $repo = $this->getUserRepository(); |
|
157 | + $user=$repo->findByLogin($login); |
|
158 | + if($user instanceof UserInterface){ |
|
159 | + $repo->remove($user,true); |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * @Given I have a :role with the following: |
|
165 | + * @param $role |
|
166 | + * @param TableNode $fields |
|
167 | + */ |
|
168 | + public function iHaveUserWithTheFollowing($role,TableNode $fields) |
|
169 | + { |
|
170 | + $normalizedFields = [ |
|
171 | + 'login' => '[email protected]', |
|
172 | + 'fullname' => 'Test Login', |
|
173 | + 'role' => User::ROLE_USER, |
|
174 | + 'password' => 'test', |
|
175 | + 'organization' => 'Cross Solution' |
|
176 | + ]; |
|
177 | + foreach($fields->getRowsHash() as $field=>$value){ |
|
178 | + $field = Inflector::camelize($field); |
|
179 | + $normalizedFields[$field] = $value; |
|
180 | + } |
|
181 | 181 | |
182 | - $this->thereIsAUserIdentifiedBy( |
|
183 | - $normalizedFields['login'], |
|
184 | - $normalizedFields['password'], |
|
185 | - $role, |
|
186 | - $normalizedFields['fullname'], |
|
187 | - $normalizedFields['organization'] |
|
188 | - ); |
|
182 | + $this->thereIsAUserIdentifiedBy( |
|
183 | + $normalizedFields['login'], |
|
184 | + $normalizedFields['password'], |
|
185 | + $role, |
|
186 | + $normalizedFields['fullname'], |
|
187 | + $normalizedFields['organization'] |
|
188 | + ); |
|
189 | 189 | |
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * @Given I am logged in as an administrator |
|
194 | - */ |
|
195 | - public function iAmLoggedInAsAnAdmin() |
|
196 | - { |
|
197 | - $user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN); |
|
198 | - $this->startLogin($user,'test'); |
|
199 | - } |
|
200 | - |
|
201 | - private function startLogin(UserInterface $user, $password) |
|
202 | - { |
|
203 | - $currentUser = $this->currentUser; |
|
204 | - if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){ |
|
205 | - $this->iWantToLogIn(); |
|
206 | - $this->iSpecifyTheUsernameAs($user->getLogin()); |
|
207 | - $this->iSpecifyThePasswordAs($password); |
|
208 | - $this->iLogIn(); |
|
209 | - $this->currentUser = $user; |
|
210 | - } |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * @return UserRepository |
|
215 | - */ |
|
216 | - public function getUserRepository() |
|
217 | - { |
|
218 | - return $this->coreContext->getRepositories()->get('Auth\Entity\User'); |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * @Given there is a user :email identified by :password |
|
223 | - */ |
|
224 | - public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null) |
|
225 | - { |
|
226 | - $repo = $this->getUserRepository(); |
|
227 | - if(!is_object($user=$repo->findByEmail($email))){ |
|
228 | - $user = $this->createUser($email,$password,$role,$fullname,$organization); |
|
229 | - } |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * @Given I am logged in as an administrator |
|
194 | + */ |
|
195 | + public function iAmLoggedInAsAnAdmin() |
|
196 | + { |
|
197 | + $user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN); |
|
198 | + $this->startLogin($user,'test'); |
|
199 | + } |
|
200 | + |
|
201 | + private function startLogin(UserInterface $user, $password) |
|
202 | + { |
|
203 | + $currentUser = $this->currentUser; |
|
204 | + if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){ |
|
205 | + $this->iWantToLogIn(); |
|
206 | + $this->iSpecifyTheUsernameAs($user->getLogin()); |
|
207 | + $this->iSpecifyThePasswordAs($password); |
|
208 | + $this->iLogIn(); |
|
209 | + $this->currentUser = $user; |
|
210 | + } |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * @return UserRepository |
|
215 | + */ |
|
216 | + public function getUserRepository() |
|
217 | + { |
|
218 | + return $this->coreContext->getRepositories()->get('Auth\Entity\User'); |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * @Given there is a user :email identified by :password |
|
223 | + */ |
|
224 | + public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null) |
|
225 | + { |
|
226 | + $repo = $this->getUserRepository(); |
|
227 | + if(!is_object($user=$repo->findByEmail($email))){ |
|
228 | + $user = $this->createUser($email,$password,$role,$fullname,$organization); |
|
229 | + } |
|
230 | 230 | |
231 | - if(!is_null($organization)){ |
|
232 | - $this->iHaveMainOrganization($user,$organization); |
|
233 | - } |
|
234 | - $this->addCreatedUser($user); |
|
235 | - return $user; |
|
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * @param $email |
|
240 | - * @param $password |
|
241 | - * @param $username |
|
242 | - * @param string $fullname |
|
243 | - * @param string $role |
|
244 | - * |
|
245 | - * @return \Auth\Entity\UserInterface |
|
246 | - */ |
|
247 | - public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter") |
|
248 | - { |
|
249 | - /* @var Register $service */ |
|
250 | - $repo = $this->getUserRepository(); |
|
251 | - $user = $repo->create([]); |
|
252 | - $user->setLogin($email); |
|
253 | - $user->setPassword($password); |
|
254 | - $user->setRole($role); |
|
231 | + if(!is_null($organization)){ |
|
232 | + $this->iHaveMainOrganization($user,$organization); |
|
233 | + } |
|
234 | + $this->addCreatedUser($user); |
|
235 | + return $user; |
|
236 | + } |
|
237 | + |
|
238 | + /** |
|
239 | + * @param $email |
|
240 | + * @param $password |
|
241 | + * @param $username |
|
242 | + * @param string $fullname |
|
243 | + * @param string $role |
|
244 | + * |
|
245 | + * @return \Auth\Entity\UserInterface |
|
246 | + */ |
|
247 | + public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter") |
|
248 | + { |
|
249 | + /* @var Register $service */ |
|
250 | + $repo = $this->getUserRepository(); |
|
251 | + $user = $repo->create([]); |
|
252 | + $user->setLogin($email); |
|
253 | + $user->setPassword($password); |
|
254 | + $user->setRole($role); |
|
255 | 255 | |
256 | - $expFullName = explode(' ',$fullname); |
|
257 | - $info = $user->getInfo(); |
|
258 | - $info->setFirstName(array_shift($expFullName)); |
|
259 | - $info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):''); |
|
260 | - $info->setEmail($email); |
|
261 | - $info->setEmailVerified(true); |
|
262 | - $repo->store($user); |
|
263 | - /* @var \Core\EventManager\EventManager $events */ |
|
264 | - /* @var \Auth\Listener\Events\AuthEvent $event */ |
|
265 | - //@TODO: [Behat] event not working in travis |
|
266 | - //$events = $this->coreContext->getEventManager(); |
|
267 | - //$event = $events->getEvent(AuthEvent::EVENT_USER_REGISTERED, $this); |
|
268 | - //$event->setUser($user); |
|
269 | - //$events->triggerEvent($event); |
|
270 | - return $user; |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * @When I have :organization as my main organization |
|
275 | - * @param $orgName |
|
276 | - */ |
|
277 | - public function iHaveMainOrganization(UserInterface $user,$orgName) |
|
278 | - { |
|
279 | - /* @var $repoOrganization OrganizationRepository */ |
|
280 | - $repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization'); |
|
281 | - $organization=$repoOrganization->findByName($orgName); |
|
282 | - if(!$organization instanceof Organization){ |
|
283 | - $organization = new Organization(); |
|
284 | - $organizationName = new OrganizationName($orgName); |
|
285 | - $organization->setOrganizationName($organizationName); |
|
286 | - } |
|
287 | - $organization->setUser($user); |
|
288 | - $repoOrganization->store($organization); |
|
289 | - } |
|
290 | - |
|
291 | - /** |
|
292 | - * @When I want to log in |
|
293 | - */ |
|
294 | - public function iWantToLogIn() |
|
295 | - { |
|
296 | - $session = $this->minkContext->getSession(); |
|
297 | - $url = $this->minkContext->locatePath('/en/login'); |
|
298 | - $session->visit($url); |
|
299 | - } |
|
300 | - |
|
301 | - /** |
|
302 | - * @When I specify the username as :username |
|
303 | - */ |
|
304 | - public function iSpecifyTheUsernameAs($username) |
|
305 | - { |
|
306 | - $this->minkContext->fillField('Login name',$username); |
|
307 | - } |
|
308 | - |
|
309 | - /** |
|
310 | - * @When I specify the password as :password |
|
311 | - */ |
|
312 | - public function iSpecifyThePasswordAs($password) |
|
313 | - { |
|
314 | - $this->minkContext->fillField('Password',$password); |
|
315 | - } |
|
316 | - |
|
317 | - /** |
|
318 | - * @Given I am logged in as :username identified by :password |
|
319 | - */ |
|
320 | - public function iAmLoggedInAsIdentifiedBy($username, $password) |
|
321 | - { |
|
322 | - $repo = $this->getUserRepository(); |
|
323 | - $user = $repo->findByLogin($username); |
|
256 | + $expFullName = explode(' ',$fullname); |
|
257 | + $info = $user->getInfo(); |
|
258 | + $info->setFirstName(array_shift($expFullName)); |
|
259 | + $info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):''); |
|
260 | + $info->setEmail($email); |
|
261 | + $info->setEmailVerified(true); |
|
262 | + $repo->store($user); |
|
263 | + /* @var \Core\EventManager\EventManager $events */ |
|
264 | + /* @var \Auth\Listener\Events\AuthEvent $event */ |
|
265 | + //@TODO: [Behat] event not working in travis |
|
266 | + //$events = $this->coreContext->getEventManager(); |
|
267 | + //$event = $events->getEvent(AuthEvent::EVENT_USER_REGISTERED, $this); |
|
268 | + //$event->setUser($user); |
|
269 | + //$events->triggerEvent($event); |
|
270 | + return $user; |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * @When I have :organization as my main organization |
|
275 | + * @param $orgName |
|
276 | + */ |
|
277 | + public function iHaveMainOrganization(UserInterface $user,$orgName) |
|
278 | + { |
|
279 | + /* @var $repoOrganization OrganizationRepository */ |
|
280 | + $repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization'); |
|
281 | + $organization=$repoOrganization->findByName($orgName); |
|
282 | + if(!$organization instanceof Organization){ |
|
283 | + $organization = new Organization(); |
|
284 | + $organizationName = new OrganizationName($orgName); |
|
285 | + $organization->setOrganizationName($organizationName); |
|
286 | + } |
|
287 | + $organization->setUser($user); |
|
288 | + $repoOrganization->store($organization); |
|
289 | + } |
|
290 | + |
|
291 | + /** |
|
292 | + * @When I want to log in |
|
293 | + */ |
|
294 | + public function iWantToLogIn() |
|
295 | + { |
|
296 | + $session = $this->minkContext->getSession(); |
|
297 | + $url = $this->minkContext->locatePath('/en/login'); |
|
298 | + $session->visit($url); |
|
299 | + } |
|
300 | + |
|
301 | + /** |
|
302 | + * @When I specify the username as :username |
|
303 | + */ |
|
304 | + public function iSpecifyTheUsernameAs($username) |
|
305 | + { |
|
306 | + $this->minkContext->fillField('Login name',$username); |
|
307 | + } |
|
308 | + |
|
309 | + /** |
|
310 | + * @When I specify the password as :password |
|
311 | + */ |
|
312 | + public function iSpecifyThePasswordAs($password) |
|
313 | + { |
|
314 | + $this->minkContext->fillField('Password',$password); |
|
315 | + } |
|
316 | + |
|
317 | + /** |
|
318 | + * @Given I am logged in as :username identified by :password |
|
319 | + */ |
|
320 | + public function iAmLoggedInAsIdentifiedBy($username, $password) |
|
321 | + { |
|
322 | + $repo = $this->getUserRepository(); |
|
323 | + $user = $repo->findByLogin($username); |
|
324 | 324 | |
325 | - if(!$user instanceof User){ |
|
326 | - throw new \Exception(sprintf('There is no user with this login: "%s"',$username)); |
|
327 | - } |
|
328 | - $this->currentUser = $user; |
|
329 | - $this->iWantToLogIn(); |
|
330 | - $this->iSpecifyTheUsernameAs($username); |
|
331 | - $this->iSpecifyThePasswordAs($password); |
|
332 | - $this->iLogIn(); |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * @When I log in |
|
337 | - */ |
|
338 | - public function iLogIn() |
|
339 | - { |
|
340 | - $this->minkContext->pressButton('login'); |
|
341 | - } |
|
342 | - |
|
343 | - /** |
|
344 | - * @When I press logout link |
|
345 | - */ |
|
346 | - public function iPressLogoutLink() |
|
347 | - { |
|
348 | - //@TODO: [ZF3] replace this with click method |
|
349 | - $url = $this->coreContext->generateUrl('/logout'); |
|
350 | - $this->minkContext->visit($url); |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * @Given I log in with username :username and password :password |
|
355 | - */ |
|
356 | - public function iLogInWith($username, $password) |
|
357 | - { |
|
358 | - $repo = $this->getUserRepository(); |
|
359 | - $user = $repo->findByLogin($username); |
|
360 | - $this->iWantToLogIn(); |
|
361 | - $this->iSpecifyTheUsernameAs($username); |
|
362 | - $this->iSpecifyThePasswordAs($password); |
|
363 | - $this->iLogIn(); |
|
364 | - $this->loggedInUser = $user; |
|
365 | - } |
|
366 | - |
|
367 | - /** |
|
368 | - * @When I go to profile page |
|
369 | - */ |
|
370 | - public function iGoToProfilePage() |
|
371 | - { |
|
372 | - $url = $this->coreContext->generateUrl('/en/my/profile'); |
|
373 | - $this->minkContext->visit($url); |
|
374 | - } |
|
375 | - |
|
376 | - /** |
|
377 | - * @Given there is a user with the following: |
|
378 | - */ |
|
379 | - public function thereIsAUserWithTheFollowing(TableNode $table) |
|
380 | - { |
|
381 | - $repo = $this->getUserRepository(); |
|
382 | - $data = $table->getRowsHash(); |
|
383 | - $email = isset($data['email']) ? $data['email']:'[email protected]'; |
|
384 | - $password = isset($data['password']) ? $data['password']:'test'; |
|
385 | - $fullname = isset($data['fullname']) ? $data['fullname']:'Test User'; |
|
386 | - $role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER; |
|
325 | + if(!$user instanceof User){ |
|
326 | + throw new \Exception(sprintf('There is no user with this login: "%s"',$username)); |
|
327 | + } |
|
328 | + $this->currentUser = $user; |
|
329 | + $this->iWantToLogIn(); |
|
330 | + $this->iSpecifyTheUsernameAs($username); |
|
331 | + $this->iSpecifyThePasswordAs($password); |
|
332 | + $this->iLogIn(); |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * @When I log in |
|
337 | + */ |
|
338 | + public function iLogIn() |
|
339 | + { |
|
340 | + $this->minkContext->pressButton('login'); |
|
341 | + } |
|
342 | + |
|
343 | + /** |
|
344 | + * @When I press logout link |
|
345 | + */ |
|
346 | + public function iPressLogoutLink() |
|
347 | + { |
|
348 | + //@TODO: [ZF3] replace this with click method |
|
349 | + $url = $this->coreContext->generateUrl('/logout'); |
|
350 | + $this->minkContext->visit($url); |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * @Given I log in with username :username and password :password |
|
355 | + */ |
|
356 | + public function iLogInWith($username, $password) |
|
357 | + { |
|
358 | + $repo = $this->getUserRepository(); |
|
359 | + $user = $repo->findByLogin($username); |
|
360 | + $this->iWantToLogIn(); |
|
361 | + $this->iSpecifyTheUsernameAs($username); |
|
362 | + $this->iSpecifyThePasswordAs($password); |
|
363 | + $this->iLogIn(); |
|
364 | + $this->loggedInUser = $user; |
|
365 | + } |
|
366 | + |
|
367 | + /** |
|
368 | + * @When I go to profile page |
|
369 | + */ |
|
370 | + public function iGoToProfilePage() |
|
371 | + { |
|
372 | + $url = $this->coreContext->generateUrl('/en/my/profile'); |
|
373 | + $this->minkContext->visit($url); |
|
374 | + } |
|
375 | + |
|
376 | + /** |
|
377 | + * @Given there is a user with the following: |
|
378 | + */ |
|
379 | + public function thereIsAUserWithTheFollowing(TableNode $table) |
|
380 | + { |
|
381 | + $repo = $this->getUserRepository(); |
|
382 | + $data = $table->getRowsHash(); |
|
383 | + $email = isset($data['email']) ? $data['email']:'[email protected]'; |
|
384 | + $password = isset($data['password']) ? $data['password']:'test'; |
|
385 | + $fullname = isset($data['fullname']) ? $data['fullname']:'Test User'; |
|
386 | + $role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER; |
|
387 | 387 | |
388 | - if(!is_object($user=$repo->findByLogin($email))){ |
|
389 | - $user = $this->createUser($email,$password,$role,$fullname); |
|
390 | - } |
|
391 | - $this->currentUser = $user; |
|
392 | - $this->addCreatedUser($user); |
|
393 | - } |
|
394 | - |
|
395 | - private function addCreatedUser(UserInterface $user) |
|
396 | - { |
|
397 | - if(!in_array($user,static::$users)){ |
|
398 | - static::$users[] = $user; |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - /** |
|
403 | - * @When I want to change my password |
|
404 | - */ |
|
405 | - public function iWantToChangeMyPassword() |
|
406 | - { |
|
407 | - $mink = $this->minkContext; |
|
408 | - $url = $this->coreContext->generateUrl('/en/my/password'); |
|
409 | - $mink->getSession()->visit($url); |
|
410 | - } |
|
388 | + if(!is_object($user=$repo->findByLogin($email))){ |
|
389 | + $user = $this->createUser($email,$password,$role,$fullname); |
|
390 | + } |
|
391 | + $this->currentUser = $user; |
|
392 | + $this->addCreatedUser($user); |
|
393 | + } |
|
394 | + |
|
395 | + private function addCreatedUser(UserInterface $user) |
|
396 | + { |
|
397 | + if(!in_array($user,static::$users)){ |
|
398 | + static::$users[] = $user; |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + /** |
|
403 | + * @When I want to change my password |
|
404 | + */ |
|
405 | + public function iWantToChangeMyPassword() |
|
406 | + { |
|
407 | + $mink = $this->minkContext; |
|
408 | + $url = $this->coreContext->generateUrl('/en/my/password'); |
|
409 | + $mink->getSession()->visit($url); |
|
410 | + } |
|
411 | 411 | |
412 | 412 | } |
413 | 413 | \ No newline at end of file |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | private $loggedInUser; |
68 | 68 | |
69 | - public function __construct($parameters=[]) |
|
69 | + public function __construct($parameters = []) |
|
70 | 70 | { |
71 | 71 | $defaultLoginInfo = [ |
72 | 72 | 'facebook' => [ |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | 'session_password-login' => getenv('LINKEDIN_USER_PASSWORD') |
79 | 79 | ], |
80 | 80 | ]; |
81 | - $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[]; |
|
82 | - $this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig); |
|
81 | + $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info'] : []; |
|
82 | + $this->socialLoginInfo = array_merge($defaultLoginInfo, $socialLoginConfig); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | static public function afterSuite(AfterSuiteScope $scope) |
90 | 90 | { |
91 | 91 | $repo = static::$userRepo; |
92 | - foreach(static::$users as $user){ |
|
93 | - if($repo->findByLogin($user->getLogin())){ |
|
94 | - try{ |
|
92 | + foreach (static::$users as $user) { |
|
93 | + if ($repo->findByLogin($user->getLogin())) { |
|
94 | + try { |
|
95 | 95 | JobContext::removeJobByUser($user); |
96 | - $repo->remove($user,true); |
|
97 | - }catch (\Exception $e){ |
|
96 | + $repo->remove($user, true); |
|
97 | + } catch (\Exception $e) { |
|
98 | 98 | |
99 | 99 | } |
100 | 100 | } |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | { |
128 | 128 | $provider = strtolower($provider); |
129 | 129 | $mink = $this->minkContext; |
130 | - foreach($this->socialLoginInfo[$provider] as $field=>$value){ |
|
131 | - $mink->fillField($field,$value); |
|
130 | + foreach ($this->socialLoginInfo[$provider] as $field=>$value) { |
|
131 | + $mink->fillField($field, $value); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | * @Given I am logged in as a recruiter |
137 | 137 | * @Given I am logged in as a recruiter with :organization as organization |
138 | 138 | */ |
139 | - public function iAmLoggedInAsARecruiter($organization=null) |
|
139 | + public function iAmLoggedInAsARecruiter($organization = null) |
|
140 | 140 | { |
141 | 141 | $user = $this->thereIsAUserIdentifiedBy( |
142 | 142 | '[email protected]', |
143 | - 'test',User::ROLE_RECRUITER, |
|
143 | + 'test', User::ROLE_RECRUITER, |
|
144 | 144 | 'Test Recruiter', |
145 | 145 | $organization |
146 | 146 | ); |
147 | - $this->startLogin($user,'test'); |
|
147 | + $this->startLogin($user, 'test'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | public function iDonTHaveUser($login) |
155 | 155 | { |
156 | 156 | $repo = $this->getUserRepository(); |
157 | - $user=$repo->findByLogin($login); |
|
158 | - if($user instanceof UserInterface){ |
|
159 | - $repo->remove($user,true); |
|
157 | + $user = $repo->findByLogin($login); |
|
158 | + if ($user instanceof UserInterface) { |
|
159 | + $repo->remove($user, true); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param $role |
166 | 166 | * @param TableNode $fields |
167 | 167 | */ |
168 | - public function iHaveUserWithTheFollowing($role,TableNode $fields) |
|
168 | + public function iHaveUserWithTheFollowing($role, TableNode $fields) |
|
169 | 169 | { |
170 | 170 | $normalizedFields = [ |
171 | 171 | 'login' => '[email protected]', |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | 'password' => 'test', |
175 | 175 | 'organization' => 'Cross Solution' |
176 | 176 | ]; |
177 | - foreach($fields->getRowsHash() as $field=>$value){ |
|
177 | + foreach ($fields->getRowsHash() as $field=>$value) { |
|
178 | 178 | $field = Inflector::camelize($field); |
179 | 179 | $normalizedFields[$field] = $value; |
180 | 180 | } |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function iAmLoggedInAsAnAdmin() |
196 | 196 | { |
197 | - $user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN); |
|
198 | - $this->startLogin($user,'test'); |
|
197 | + $user = $this->thereIsAUserIdentifiedBy('[email protected]', 'test', User::ROLE_ADMIN); |
|
198 | + $this->startLogin($user, 'test'); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | private function startLogin(UserInterface $user, $password) |
202 | 202 | { |
203 | 203 | $currentUser = $this->currentUser; |
204 | - if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){ |
|
204 | + if (!is_object($currentUser) || $user->getId() != $currentUser->getId()) { |
|
205 | 205 | $this->iWantToLogIn(); |
206 | 206 | $this->iSpecifyTheUsernameAs($user->getLogin()); |
207 | 207 | $this->iSpecifyThePasswordAs($password); |
@@ -221,15 +221,15 @@ discard block |
||
221 | 221 | /** |
222 | 222 | * @Given there is a user :email identified by :password |
223 | 223 | */ |
224 | - public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null) |
|
224 | + public function thereIsAUserIdentifiedBy($email, $password, $role = User::ROLE_RECRUITER, $fullname = "Test Recruiter", $organization = null) |
|
225 | 225 | { |
226 | 226 | $repo = $this->getUserRepository(); |
227 | - if(!is_object($user=$repo->findByEmail($email))){ |
|
228 | - $user = $this->createUser($email,$password,$role,$fullname,$organization); |
|
227 | + if (!is_object($user = $repo->findByEmail($email))) { |
|
228 | + $user = $this->createUser($email, $password, $role, $fullname, $organization); |
|
229 | 229 | } |
230 | 230 | |
231 | - if(!is_null($organization)){ |
|
232 | - $this->iHaveMainOrganization($user,$organization); |
|
231 | + if (!is_null($organization)) { |
|
232 | + $this->iHaveMainOrganization($user, $organization); |
|
233 | 233 | } |
234 | 234 | $this->addCreatedUser($user); |
235 | 235 | return $user; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return \Auth\Entity\UserInterface |
246 | 246 | */ |
247 | - public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter") |
|
247 | + public function createUser($email, $password, $role = User::ROLE_RECRUITER, $fullname = "Test Recruiter") |
|
248 | 248 | { |
249 | 249 | /* @var Register $service */ |
250 | 250 | $repo = $this->getUserRepository(); |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | $user->setPassword($password); |
254 | 254 | $user->setRole($role); |
255 | 255 | |
256 | - $expFullName = explode(' ',$fullname); |
|
256 | + $expFullName = explode(' ', $fullname); |
|
257 | 257 | $info = $user->getInfo(); |
258 | 258 | $info->setFirstName(array_shift($expFullName)); |
259 | - $info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):''); |
|
259 | + $info->setLastName(count($expFullName) > 0 ? implode(' ', $expFullName) : ''); |
|
260 | 260 | $info->setEmail($email); |
261 | 261 | $info->setEmailVerified(true); |
262 | 262 | $repo->store($user); |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | * @When I have :organization as my main organization |
275 | 275 | * @param $orgName |
276 | 276 | */ |
277 | - public function iHaveMainOrganization(UserInterface $user,$orgName) |
|
277 | + public function iHaveMainOrganization(UserInterface $user, $orgName) |
|
278 | 278 | { |
279 | 279 | /* @var $repoOrganization OrganizationRepository */ |
280 | 280 | $repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization'); |
281 | - $organization=$repoOrganization->findByName($orgName); |
|
282 | - if(!$organization instanceof Organization){ |
|
281 | + $organization = $repoOrganization->findByName($orgName); |
|
282 | + if (!$organization instanceof Organization) { |
|
283 | 283 | $organization = new Organization(); |
284 | 284 | $organizationName = new OrganizationName($orgName); |
285 | 285 | $organization->setOrganizationName($organizationName); |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function iSpecifyTheUsernameAs($username) |
305 | 305 | { |
306 | - $this->minkContext->fillField('Login name',$username); |
|
306 | + $this->minkContext->fillField('Login name', $username); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function iSpecifyThePasswordAs($password) |
313 | 313 | { |
314 | - $this->minkContext->fillField('Password',$password); |
|
314 | + $this->minkContext->fillField('Password', $password); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | $repo = $this->getUserRepository(); |
323 | 323 | $user = $repo->findByLogin($username); |
324 | 324 | |
325 | - if(!$user instanceof User){ |
|
326 | - throw new \Exception(sprintf('There is no user with this login: "%s"',$username)); |
|
325 | + if (!$user instanceof User) { |
|
326 | + throw new \Exception(sprintf('There is no user with this login: "%s"', $username)); |
|
327 | 327 | } |
328 | 328 | $this->currentUser = $user; |
329 | 329 | $this->iWantToLogIn(); |
@@ -380,13 +380,13 @@ discard block |
||
380 | 380 | { |
381 | 381 | $repo = $this->getUserRepository(); |
382 | 382 | $data = $table->getRowsHash(); |
383 | - $email = isset($data['email']) ? $data['email']:'[email protected]'; |
|
384 | - $password = isset($data['password']) ? $data['password']:'test'; |
|
385 | - $fullname = isset($data['fullname']) ? $data['fullname']:'Test User'; |
|
386 | - $role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER; |
|
383 | + $email = isset($data['email']) ? $data['email'] : '[email protected]'; |
|
384 | + $password = isset($data['password']) ? $data['password'] : 'test'; |
|
385 | + $fullname = isset($data['fullname']) ? $data['fullname'] : 'Test User'; |
|
386 | + $role = isset($data['role']) ? $data['role'] : User::ROLE_RECRUITER; |
|
387 | 387 | |
388 | - if(!is_object($user=$repo->findByLogin($email))){ |
|
389 | - $user = $this->createUser($email,$password,$role,$fullname); |
|
388 | + if (!is_object($user = $repo->findByLogin($email))) { |
|
389 | + $user = $this->createUser($email, $password, $role, $fullname); |
|
390 | 390 | } |
391 | 391 | $this->currentUser = $user; |
392 | 392 | $this->addCreatedUser($user); |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | |
395 | 395 | private function addCreatedUser(UserInterface $user) |
396 | 396 | { |
397 | - if(!in_array($user,static::$users)){ |
|
397 | + if (!in_array($user, static::$users)) { |
|
398 | 398 | static::$users[] = $user; |
399 | 399 | } |
400 | 400 | } |
@@ -94,7 +94,7 @@ |
||
94 | 94 | try{ |
95 | 95 | JobContext::removeJobByUser($user); |
96 | 96 | $repo->remove($user,true); |
97 | - }catch (\Exception $e){ |
|
97 | + } catch (\Exception $e){ |
|
98 | 98 | |
99 | 99 | } |
100 | 100 | } |
@@ -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 |