@@ -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 |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | 'Jobs/ApiJobListByChannel' => 'Jobs\Controller\ApiJobListByChannelController', |
275 | 275 | ], |
276 | 276 | 'factories' => [ |
277 | - 'Jobs/Console' => [ConsoleController::class,'factory'], |
|
278 | - 'Jobs/AdminCategories' => [AdminCategoriesController::class,'factory'], |
|
279 | - 'Jobs/Admin' => [AdminController::class,'factory'], |
|
277 | + 'Jobs/Console' => [ConsoleController::class,'factory'], |
|
278 | + 'Jobs/AdminCategories' => [AdminCategoriesController::class,'factory'], |
|
279 | + 'Jobs/Admin' => [AdminController::class,'factory'], |
|
280 | 280 | 'Jobs/Template' => 'Jobs\Factory\Controller\TemplateControllerFactory', |
281 | 281 | 'Jobs/Index' => 'Jobs\Factory\Controller\IndexControllerFactory', |
282 | 282 | 'Jobs/Approval' => 'Jobs\Factory\Controller\ApprovalControllerFactory', |
@@ -428,15 +428,15 @@ discard block |
||
428 | 428 | 'invokables' => [ |
429 | 429 | 'Jobs/Location/New' => 'Jobs\Form\InputFilter\JobLocationNew', |
430 | 430 | //'Jobs/Location/Edit' => 'Jobs\Form\InputFilter\JobLocationEdit', |
431 | - JobLocationEdit::class => JobLocationEdit::class, |
|
431 | + JobLocationEdit::class => JobLocationEdit::class, |
|
432 | 432 | 'Jobs/Company' => 'Jobs\Form\InputFilter\CompanyName', |
433 | 433 | ], |
434 | 434 | 'factories' => [ |
435 | 435 | 'Jobs/AtsMode' => 'Jobs\Factory\Form\InputFilter\AtsModeFactory', |
436 | 436 | ], |
437 | - 'aliases' => [ |
|
438 | - 'Jobs/Location/Edit' => JobLocationEdit::class |
|
439 | - ] |
|
437 | + 'aliases' => [ |
|
438 | + 'Jobs/Location/Edit' => JobLocationEdit::class |
|
439 | + ] |
|
440 | 440 | ], |
441 | 441 | |
442 | 442 | 'filters' => [ |
@@ -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 | } |
@@ -33,17 +33,17 @@ |
||
33 | 33 | */ |
34 | 34 | $jobRepository = $container->get('repositories')->get('Jobs/Job'); |
35 | 35 | $options = $container->get('Jobs/Options'); |
36 | - $viewModelTemplateFilter = $container->get('Jobs/ViewModelTemplateFilter'); |
|
37 | - $translator = $container->get('translator'); |
|
38 | - $viewHelper = $container->get('ViewHelperManager'); |
|
39 | - $formManager = $container->get('FormElementManager'); |
|
36 | + $viewModelTemplateFilter = $container->get('Jobs/ViewModelTemplateFilter'); |
|
37 | + $translator = $container->get('translator'); |
|
38 | + $viewHelper = $container->get('ViewHelperManager'); |
|
39 | + $formManager = $container->get('FormElementManager'); |
|
40 | 40 | return new TemplateController( |
41 | - $jobRepository, |
|
42 | - $viewModelTemplateFilter, |
|
43 | - $translator, |
|
44 | - $options, |
|
45 | - $viewHelper, |
|
46 | - $formManager |
|
41 | + $jobRepository, |
|
42 | + $viewModelTemplateFilter, |
|
43 | + $translator, |
|
44 | + $options, |
|
45 | + $viewHelper, |
|
46 | + $formManager |
|
47 | 47 | ); |
48 | 48 | } |
49 | 49 | } |
@@ -45,17 +45,17 @@ |
||
45 | 45 | $jobEvents = $container->get('Jobs/Events'); |
46 | 46 | $jobEvent = $container->get('Jobs/Event'); |
47 | 47 | return new ManageController( |
48 | - $auth, |
|
49 | - $repositoryService, |
|
50 | - $translator, |
|
51 | - $filterManager, |
|
52 | - $jobFormEvents, |
|
53 | - $formManager, |
|
54 | - $options, |
|
55 | - $viewHelper, |
|
56 | - $validatorManager, |
|
57 | - $jobEvents, |
|
58 | - $jobEvent |
|
48 | + $auth, |
|
49 | + $repositoryService, |
|
50 | + $translator, |
|
51 | + $filterManager, |
|
52 | + $jobFormEvents, |
|
53 | + $formManager, |
|
54 | + $options, |
|
55 | + $viewHelper, |
|
56 | + $validatorManager, |
|
57 | + $jobEvents, |
|
58 | + $jobEvent |
|
59 | 59 | ); |
60 | 60 | } |
61 | 61 | } |