@@ -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 |
@@ -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 |
@@ -22,26 +22,26 @@ |
||
22 | 22 | */ |
23 | 23 | class ApplicationContext implements Context |
24 | 24 | { |
25 | - use CommonContextTrait; |
|
25 | + use CommonContextTrait; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @Given I apply for :title job |
|
29 | - * |
|
30 | - * @param string $title |
|
31 | - * @throws \Exception when the titled job not exists |
|
32 | - */ |
|
33 | - public function iApplyAJob($title) |
|
34 | - { |
|
35 | - /* @var $repo JobRepository */ |
|
36 | - $repo = $this->getRepository('Jobs/Job'); |
|
37 | - $job = $repo->findOneBy(['title' => $title]); |
|
38 | - if(!$job instanceof Job){ |
|
39 | - throw new \Exception('There is no job titled: "'.$title.'"'); |
|
40 | - } |
|
41 | - $job->setApplyId($job->getId()); |
|
42 | - $repo->store($job); |
|
27 | + /** |
|
28 | + * @Given I apply for :title job |
|
29 | + * |
|
30 | + * @param string $title |
|
31 | + * @throws \Exception when the titled job not exists |
|
32 | + */ |
|
33 | + public function iApplyAJob($title) |
|
34 | + { |
|
35 | + /* @var $repo JobRepository */ |
|
36 | + $repo = $this->getRepository('Jobs/Job'); |
|
37 | + $job = $repo->findOneBy(['title' => $title]); |
|
38 | + if(!$job instanceof Job){ |
|
39 | + throw new \Exception('There is no job titled: "'.$title.'"'); |
|
40 | + } |
|
41 | + $job->setApplyId($job->getId()); |
|
42 | + $repo->store($job); |
|
43 | 43 | |
44 | - $url = '/en/apply/'.$job->getApplyId(); |
|
45 | - $this->visit($url); |
|
46 | - } |
|
44 | + $url = '/en/apply/'.$job->getApplyId(); |
|
45 | + $this->visit($url); |
|
46 | + } |
|
47 | 47 | } |
48 | 48 | \ No newline at end of file |
@@ -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 |
@@ -171,13 +171,13 @@ |
||
171 | 171 | $response_externalIdUpdate = $decodedBody->applyIdUpdate; |
172 | 172 | |
173 | 173 | if ($publisher->externalId != $response_externalIdUpdate || $publisher->reference != $response_referenceUpdate) { |
174 | - $logInfo = 'RestCall changed externalID [' |
|
175 | - . var_export($publisher->externalId, true) |
|
176 | - . ' => ' |
|
177 | - . var_export($response_externalIdUpdate, true) . '], reference [' |
|
178 | - . var_export($publisher->reference, true) |
|
179 | - . ' => ' |
|
180 | - . var_export($response_referenceUpdate, true) . ']'; |
|
174 | + $logInfo = 'RestCall changed externalID [' |
|
175 | + . var_export($publisher->externalId, true) |
|
176 | + . ' => ' |
|
177 | + . var_export($response_externalIdUpdate, true) . '], reference [' |
|
178 | + . var_export($publisher->reference, true) |
|
179 | + . ' => ' |
|
180 | + . var_export($response_referenceUpdate, true) . ']'; |
|
181 | 181 | $log->info($logInfo); |
182 | 182 | $publisher->reference = $response_referenceUpdate; |
183 | 183 | $publisher->externalId = $response_externalIdUpdate; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function onJobAccepted(JobEvent $e) |
108 | 108 | { |
109 | - $target = $e->getTarget(); |
|
109 | + $target = $e->getTarget(); |
|
110 | 110 | |
111 | 111 | $this->sendMail( |
112 | 112 | $target->getJobEntity(), |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | { |
142 | 142 | $mail = $this->mailer->get('htmltemplate'); |
143 | 143 | $mail->setTemplate($template) |
144 | - ->setSubject($subject) |
|
145 | - ->setVariables( |
|
146 | - array( |
|
144 | + ->setSubject($subject) |
|
145 | + ->setVariables( |
|
146 | + array( |
|
147 | 147 | 'job' => $job, |
148 | 148 | 'siteName' => $this->options['siteName'], |
149 | 149 | ) |
150 | - ); |
|
150 | + ); |
|
151 | 151 | |
152 | 152 | if ($adminMail) { |
153 | 153 | $mail->setTo($this->options['adminEmail']); |
@@ -31,54 +31,54 @@ |
||
31 | 31 | */ |
32 | 32 | class ViewModelTemplateFilterFactory implements FactoryInterface |
33 | 33 | { |
34 | - /** |
|
35 | - * @var ServiceLocatorInterface |
|
36 | - */ |
|
37 | - protected $service; |
|
34 | + /** |
|
35 | + * @var ServiceLocatorInterface |
|
36 | + */ |
|
37 | + protected $service; |
|
38 | 38 | |
39 | - public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
40 | - { |
|
41 | - $this->service = $container; |
|
42 | - return $this; |
|
43 | - } |
|
39 | + public function __invoke( ContainerInterface $container, $requestedName, array $options = null ) |
|
40 | + { |
|
41 | + $this->service = $container; |
|
42 | + return $this; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param $element |
|
47 | - * @return \Zend\View\Model\ViewModel |
|
48 | - * @throws \InvalidArgumentException |
|
49 | - * @TODO: [ZF3] renamed this method into getModel because conflict with FactoryInterface::__invoke() method |
|
50 | - */ |
|
51 | - public function getModel($element) |
|
52 | - { |
|
53 | - $filter = null; |
|
54 | - if ($element instanceof EntityInterface) { |
|
55 | - $filter = new ViewModelTemplateFilterJob; |
|
56 | - } |
|
57 | - if ($element instanceof Element) { |
|
58 | - $filter = new ViewModelTemplateFilterForm; |
|
59 | - $viewHelperManager = $this->service->get('ViewHelperManager'); |
|
60 | - $viewHelperForm = $viewHelperManager->get('formSimple'); |
|
61 | - $filter->setViewHelperForm($viewHelperForm); |
|
62 | - } |
|
63 | - if (!isset($filter)) { |
|
64 | - throw new \InvalidArgumentException(get_class($element) . ' cannot be used to initialize a template'); |
|
65 | - } |
|
66 | - $viewManager = $this->service->get('ViewHelperManager'); |
|
67 | - $basePathHelper = $viewManager->get('basePath'); |
|
68 | - $serverUrlHelper = $viewManager->get('serverUrl'); |
|
69 | - $imageFileCacheHelper = $this->service->get('Organizations\ImageFileCache\Manager'); |
|
70 | - $filter->setBasePathHelper($basePathHelper); |
|
71 | - $filter->setImageFileCacheHelper($imageFileCacheHelper); |
|
72 | - $filter->setServerUrlHelper($serverUrlHelper); |
|
45 | + /** |
|
46 | + * @param $element |
|
47 | + * @return \Zend\View\Model\ViewModel |
|
48 | + * @throws \InvalidArgumentException |
|
49 | + * @TODO: [ZF3] renamed this method into getModel because conflict with FactoryInterface::__invoke() method |
|
50 | + */ |
|
51 | + public function getModel($element) |
|
52 | + { |
|
53 | + $filter = null; |
|
54 | + if ($element instanceof EntityInterface) { |
|
55 | + $filter = new ViewModelTemplateFilterJob; |
|
56 | + } |
|
57 | + if ($element instanceof Element) { |
|
58 | + $filter = new ViewModelTemplateFilterForm; |
|
59 | + $viewHelperManager = $this->service->get('ViewHelperManager'); |
|
60 | + $viewHelperForm = $viewHelperManager->get('formSimple'); |
|
61 | + $filter->setViewHelperForm($viewHelperForm); |
|
62 | + } |
|
63 | + if (!isset($filter)) { |
|
64 | + throw new \InvalidArgumentException(get_class($element) . ' cannot be used to initialize a template'); |
|
65 | + } |
|
66 | + $viewManager = $this->service->get('ViewHelperManager'); |
|
67 | + $basePathHelper = $viewManager->get('basePath'); |
|
68 | + $serverUrlHelper = $viewManager->get('serverUrl'); |
|
69 | + $imageFileCacheHelper = $this->service->get('Organizations\ImageFileCache\Manager'); |
|
70 | + $filter->setBasePathHelper($basePathHelper); |
|
71 | + $filter->setImageFileCacheHelper($imageFileCacheHelper); |
|
72 | + $filter->setServerUrlHelper($serverUrlHelper); |
|
73 | 73 | |
74 | - if($filter instanceof ViewModelTemplateFilterJob || method_exists($filter,'setJsonLdHelper')){ |
|
75 | - $jsonLdHelper = $viewManager->get(JsonLd::class); |
|
76 | - $filter->setJsonLdHelper($jsonLdHelper); |
|
77 | - } |
|
78 | - $urlPlugin = $this->service->get('ControllerPluginManager')->get('url'); |
|
79 | - $filter->setUrlPlugin($urlPlugin); |
|
80 | - $options = $this->service->get('Jobs/Options'); |
|
81 | - $filter->setConfig($options); |
|
82 | - return $filter->filter($element); |
|
83 | - } |
|
74 | + if($filter instanceof ViewModelTemplateFilterJob || method_exists($filter,'setJsonLdHelper')){ |
|
75 | + $jsonLdHelper = $viewManager->get(JsonLd::class); |
|
76 | + $filter->setJsonLdHelper($jsonLdHelper); |
|
77 | + } |
|
78 | + $urlPlugin = $this->service->get('ControllerPluginManager')->get('url'); |
|
79 | + $filter->setUrlPlugin($urlPlugin); |
|
80 | + $options = $this->service->get('Jobs/Options'); |
|
81 | + $filter->setConfig($options); |
|
82 | + return $filter->filter($element); |
|
83 | + } |
|
84 | 84 | } |
85 | 85 | \ No newline at end of file |
@@ -47,10 +47,10 @@ |
||
47 | 47 | $params = $viewHelper->get('params'); |
48 | 48 | $serverUrl = $viewHelper->get('serverUrl'); |
49 | 49 | |
50 | - $helper = new JobUrl(); |
|
50 | + $helper = new JobUrl(); |
|
51 | 51 | $helper->setUrlHelper($url) |
52 | - ->setParamsHelper($params) |
|
53 | - ->setServerUrlHelper($serverUrl); |
|
52 | + ->setParamsHelper($params) |
|
53 | + ->setServerUrlHelper($serverUrl); |
|
54 | 54 | return $helper; |
55 | 55 | } |
56 | 56 | } |
@@ -44,11 +44,11 @@ |
||
44 | 44 | $params = $viewHelper->get('params'); |
45 | 45 | $serverUrl = $viewHelper->get('serverUrl'); |
46 | 46 | |
47 | - $helper = new ApplyUrl(); |
|
47 | + $helper = new ApplyUrl(); |
|
48 | 48 | $helper->setUrlHelper($url) |
49 | - ->setTranslateHelper($translate) |
|
50 | - ->setParamsHelper($params) |
|
51 | - ->setServerUrlHelper($serverUrl); |
|
49 | + ->setTranslateHelper($translate) |
|
50 | + ->setParamsHelper($params) |
|
51 | + ->setServerUrlHelper($serverUrl); |
|
52 | 52 | return $helper; |
53 | 53 | } |
54 | 54 | } |