Completed
Pull Request — develop (#435)
by ANTHONIUS
05:57
created
module/Behat/src/CvContext.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,22 +22,22 @@
 block discarded – undo
22 22
  */
23 23
 class CvContext implements Context
24 24
 {
25
-	use CommonContextTrait;
25
+    use CommonContextTrait;
26 26
 	
27 27
 	
28
-	/**
29
-	 * @Given I go to manage my resume page
30
-	 */
31
-	public function iGoToManageResumePage()
32
-	{
33
-		$this->visit('/en/my/cv');
34
-	}
28
+    /**
29
+     * @Given I go to manage my resume page
30
+     */
31
+    public function iGoToManageResumePage()
32
+    {
33
+        $this->visit('/en/my/cv');
34
+    }
35 35
 	
36
-	/**
37
-	 * @When I click edit on my personal information
38
-	 */
39
-	public function iClickEditOnPersonalInformations()
40
-	{
41
-		$this->summaryFormContext->iClickEditOnForm('resumePersonalInformations');
42
-	}
36
+    /**
37
+     * @When I click edit on my personal information
38
+     */
39
+    public function iClickEditOnPersonalInformations()
40
+    {
41
+        $this->summaryFormContext->iClickEditOnForm('resumePersonalInformations');
42
+    }
43 43
 }
44 44
\ No newline at end of file
Please login to merge, or discard this patch.
module/Behat/src/OrganizationContext.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -23,39 +23,39 @@
 block discarded – undo
23 23
  */
24 24
 class OrganizationContext implements Context
25 25
 {
26
-	use CommonContextTrait;
26
+    use CommonContextTrait;
27 27
 	
28
-	/**
29
-	 * @Given I go to my organization page
30
-	 */
31
-	public function iGoToMyOrganizationPage()
32
-	{
33
-		$url = $this->coreContext->generateUrl('/en/my/organization');
34
-		$this->coreContext->iVisit($url);
35
-	}
28
+    /**
29
+     * @Given I go to my organization page
30
+     */
31
+    public function iGoToMyOrganizationPage()
32
+    {
33
+        $url = $this->coreContext->generateUrl('/en/my/organization');
34
+        $this->coreContext->iVisit($url);
35
+    }
36 36
 	
37
-	/**
38
-	 * @When I hover over name form
39
-	 */
40
-	public function iMouseOverOrganizationNameForm()
41
-	{
42
-		$locator = '#sf-nameForm .sf-summary';
43
-		$this->coreContext->iHoverOverTheElement($locator);
44
-	}
37
+    /**
38
+     * @When I hover over name form
39
+     */
40
+    public function iMouseOverOrganizationNameForm()
41
+    {
42
+        $locator = '#sf-nameForm .sf-summary';
43
+        $this->coreContext->iHoverOverTheElement($locator);
44
+    }
45 45
 	
46
-	/**
47
-	 * @Given I go to create new organization page
48
-	 */
49
-	public function iGoToCreateNewOrganizationPage()
50
-	{
51
-		$this->visit('/en/organizations/edit');
52
-	}
46
+    /**
47
+     * @Given I go to create new organization page
48
+     */
49
+    public function iGoToCreateNewOrganizationPage()
50
+    {
51
+        $this->visit('/en/organizations/edit');
52
+    }
53 53
 	
54
-	/**
55
-	 * @Given I go to organization overview page
56
-	 */
57
-	public function iGoToOrganizationOverviewPage()
58
-	{
59
-		$this->visit('/en/organizations');
60
-	}
54
+    /**
55
+     * @Given I go to organization overview page
56
+     */
57
+    public function iGoToOrganizationOverviewPage()
58
+    {
59
+        $this->visit('/en/organizations');
60
+    }
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
module/Behat/src/SettingsContext.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@
 block discarded – undo
14 14
 
15 15
 class SettingsContext implements Context
16 16
 {
17
-	use CommonContextTrait;
17
+    use CommonContextTrait;
18 18
 	
19
-	/**
20
-	 * @Given I go to settings page
21
-	 */
22
-	public function iGoToSettingsPage()
23
-	{
24
-		$this->visit('/en/settings');
25
-	}
19
+    /**
20
+     * @Given I go to settings page
21
+     */
22
+    public function iGoToSettingsPage()
23
+    {
24
+        $this->visit('/en/settings');
25
+    }
26 26
 	
27
-	/**
28
-	 * @Given I go to email template settings page
29
-	 */
30
-	public function iGoToEmailTemplatePage()
31
-	{
32
-		$this->visit('/en/settings/Applications');
33
-	}
27
+    /**
28
+     * @Given I go to email template settings page
29
+     */
30
+    public function iGoToEmailTemplatePage()
31
+    {
32
+        $this->visit('/en/settings/Applications');
33
+    }
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
module/Behat/src/JobContext.php 1 patch
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -33,312 +33,312 @@
 block discarded – undo
33 33
  */
34 34
 class JobContext implements Context
35 35
 {
36
-	use CommonContextTrait;
36
+    use CommonContextTrait;
37 37
 	
38
-	/**
39
-	 * @var Select2Context
40
-	 */
41
-	private $select2Context;
38
+    /**
39
+     * @var Select2Context
40
+     */
41
+    private $select2Context;
42 42
 	
43
-	/**
44
-	 * @var Job
45
-	 */
46
-	private $currentJob;
43
+    /**
44
+     * @var Job
45
+     */
46
+    private $currentJob;
47 47
 	
48
-	/**
49
-	 * @var JobRepository
50
-	 */
51
-	static private $jobRepo;
48
+    /**
49
+     * @var JobRepository
50
+     */
51
+    static private $jobRepo;
52 52
 	
53
-	/**
54
-	 * @param User $user
55
-	 */
56
-	static public function removeJobByUser(User $user)
57
-	{
58
-		$repo = static::$jobRepo;
59
-		$results = $repo->findBy(['user' => $user]);
60
-		foreach($results as $result){
61
-			$repo->remove($result,true);
62
-		}
63
-	}
53
+    /**
54
+     * @param User $user
55
+     */
56
+    static public function removeJobByUser(User $user)
57
+    {
58
+        $repo = static::$jobRepo;
59
+        $results = $repo->findBy(['user' => $user]);
60
+        foreach($results as $result){
61
+            $repo->remove($result,true);
62
+        }
63
+    }
64 64
 	
65
-	/**
66
-	 * @BeforeScenario
67
-	 *
68
-	 * @param BeforeScenarioScope $scope
69
-	 */
70
-	public function beforeScenario(BeforeScenarioScope $scope)
71
-	{
72
-		$this->select2Context = $scope->getEnvironment()->getContext(Select2Context::class);
73
-		if(is_null(static::$jobRepo)){
74
-			$this->gatherContexts($scope);
75
-			static::$jobRepo = $this->getJobRepository();
76
-		}
77
-	}
65
+    /**
66
+     * @BeforeScenario
67
+     *
68
+     * @param BeforeScenarioScope $scope
69
+     */
70
+    public function beforeScenario(BeforeScenarioScope $scope)
71
+    {
72
+        $this->select2Context = $scope->getEnvironment()->getContext(Select2Context::class);
73
+        if(is_null(static::$jobRepo)){
74
+            $this->gatherContexts($scope);
75
+            static::$jobRepo = $this->getJobRepository();
76
+        }
77
+    }
78 78
 	
79
-	/**
80
-	 * @Given I go to job board page
81
-	 */
82
-	public function iGoToJobBoardPage()
83
-	{
84
-		$this->visit('/en/jobboard');
85
-	}
79
+    /**
80
+     * @Given I go to job board page
81
+     */
82
+    public function iGoToJobBoardPage()
83
+    {
84
+        $this->visit('/en/jobboard');
85
+    }
86 86
 	
87
-	/**
88
-	 * @Given I go to create job page
89
-	 */
90
-	public function iGoToMyOrganizationPage()
91
-	{
92
-		$this->visit('/en/jobs/edit');
93
-	}
87
+    /**
88
+     * @Given I go to create job page
89
+     */
90
+    public function iGoToMyOrganizationPage()
91
+    {
92
+        $this->visit('/en/jobs/edit');
93
+    }
94 94
 	
95
-	/**
96
-	 * @Given I go to job overview page
97
-	 */
98
-	public function iGoToJobOverviewPage()
99
-	{
100
-		$this->visit('/en/jobs');
101
-	}
95
+    /**
96
+     * @Given I go to job overview page
97
+     */
98
+    public function iGoToJobOverviewPage()
99
+    {
100
+        $this->visit('/en/jobs');
101
+    }
102 102
 	
103
-	/**
104
-	 * @Given I go to edit job draft with title :jobTitle
105
-	 * @param $jobTitle
106
-	 * @throws \Exception when job is not found
107
-	 */
108
-	public function iGoToEditJobWithTitle($jobTitle)
109
-	{
110
-		$job = $this->getJobRepository()->findOneBy(['title' => $jobTitle]);
111
-		if(!$job instanceof Job){
112
-			throw new \Exception(sprintf('Job with title "%s" is not found',$jobTitle));
113
-		}
114
-		$this->currentJob = $job;
115
-		$url = '/en/jobs/edit?id='.$job->getId();
116
-		$this->visit($url);
117
-	}
103
+    /**
104
+     * @Given I go to edit job draft with title :jobTitle
105
+     * @param $jobTitle
106
+     * @throws \Exception when job is not found
107
+     */
108
+    public function iGoToEditJobWithTitle($jobTitle)
109
+    {
110
+        $job = $this->getJobRepository()->findOneBy(['title' => $jobTitle]);
111
+        if(!$job instanceof Job){
112
+            throw new \Exception(sprintf('Job with title "%s" is not found',$jobTitle));
113
+        }
114
+        $this->currentJob = $job;
115
+        $url = '/en/jobs/edit?id='.$job->getId();
116
+        $this->visit($url);
117
+    }
118 118
 	
119
-	/**
120
-	 * @Given I don't have any classification data
121
-	 */
122
-	public function iDonTHaveAnyClassificationData()
123
-	{
124
-		$this->currentJob->setClassifications(new Classifications());
125
-		$this->getJobRepository()->store($this->currentJob);
126
-	}
119
+    /**
120
+     * @Given I don't have any classification data
121
+     */
122
+    public function iDonTHaveAnyClassificationData()
123
+    {
124
+        $this->currentJob->setClassifications(new Classifications());
125
+        $this->getJobRepository()->store($this->currentJob);
126
+    }
127 127
 	
128
-	/**
129
-	 * @When I don't have any posted job
130
-	 */
131
-	public function iDonTHaveAnyPostedJob()
132
-	{
133
-		/* @var $jobRepository JobRepository */
134
-		/* @var $job Job */
135
-		$user = $this->getCurrentUser();
136
-		$jobRepository = $this->getJobRepository();
137
-		$results = $jobRepository->getUserJobs($user->getId());
138
-		foreach($results as $job){
139
-			$jobRepository->remove($job,true);
140
-		}
141
-		$this->currentJob = null;
142
-	}
128
+    /**
129
+     * @When I don't have any posted job
130
+     */
131
+    public function iDonTHaveAnyPostedJob()
132
+    {
133
+        /* @var $jobRepository JobRepository */
134
+        /* @var $job Job */
135
+        $user = $this->getCurrentUser();
136
+        $jobRepository = $this->getJobRepository();
137
+        $results = $jobRepository->getUserJobs($user->getId());
138
+        foreach($results as $job){
139
+            $jobRepository->remove($job,true);
140
+        }
141
+        $this->currentJob = null;
142
+    }
143 143
 	
144
-	/**
145
-	 * @When I fill job location search with :search and choose :choice
146
-	 *
147
-	 */
148
-	public function iFillJobLocationAndChoose($search,$choice)
149
-	{
150
-		$select2 = $this->select2Context;
151
-		$select2->iFillInSelect2FieldWith('jobBase[geoLocation]',$search,$choice);
152
-	}
144
+    /**
145
+     * @When I fill job location search with :search and choose :choice
146
+     *
147
+     */
148
+    public function iFillJobLocationAndChoose($search,$choice)
149
+    {
150
+        $select2 = $this->select2Context;
151
+        $select2->iFillInSelect2FieldWith('jobBase[geoLocation]',$search,$choice);
152
+    }
153 153
 	
154
-	/**
155
-	 * @When I choose :value from :field
156
-	 */
157
-	public function iJobClassificationSelect($value,$field)
158
-	{
159
-		$field = Inflector::camelize($field);
154
+    /**
155
+     * @When I choose :value from :field
156
+     */
157
+    public function iJobClassificationSelect($value,$field)
158
+    {
159
+        $field = Inflector::camelize($field);
160 160
 		
161
-		$mapSelect2 = [
162
-			'professions' => '#classifications-professions-span .select2-container',
163
-			'industries'  => '#classifications-industries-span .select2-container',
164
-			'employmentTypes' => '#classifications-employmentTypes-span .select2-container',
165
-		];
161
+        $mapSelect2 = [
162
+            'professions' => '#classifications-professions-span .select2-container',
163
+            'industries'  => '#classifications-industries-span .select2-container',
164
+            'employmentTypes' => '#classifications-employmentTypes-span .select2-container',
165
+        ];
166 166
 		
167
-		$mapMultiple = [
168
-			'professions'       => "select#classifications-professions",
169
-			'industries'        => "select#classifications-industries",
170
-			'employmentTypes'    => "select#classifications-employmentTypes",
171
-		];
167
+        $mapMultiple = [
168
+            'professions'       => "select#classifications-professions",
169
+            'industries'        => "select#classifications-industries",
170
+            'employmentTypes'    => "select#classifications-employmentTypes",
171
+        ];
172 172
 		
173
-		if(!isset($mapSelect2[$field])){
174
-			throw new \Exception('Undefined field selection value "'.$field.'"');
175
-		}
173
+        if(!isset($mapSelect2[$field])){
174
+            throw new \Exception('Undefined field selection value "'.$field.'"');
175
+        }
176 176
 		
177
-		$multipleField = $mapMultiple[$field];
178
-		$page = $this->minkContext->getSession()->getPage();
179
-		$element = $page->find('css',$mapMultiple[$field]);
180
-		if(!is_null($element) && $element->getAttribute('multiple')=='multiple'){
181
-			$this->minkContext->selectOption($value,$multipleField);
182
-		}else{
183
-			$locator = $mapSelect2[$field];
184
-			$this->select2Context->iFillInSelect2Field($locator,$value);
185
-		}
186
-	}
177
+        $multipleField = $mapMultiple[$field];
178
+        $page = $this->minkContext->getSession()->getPage();
179
+        $element = $page->find('css',$mapMultiple[$field]);
180
+        if(!is_null($element) && $element->getAttribute('multiple')=='multiple'){
181
+            $this->minkContext->selectOption($value,$multipleField);
182
+        }else{
183
+            $locator = $mapSelect2[$field];
184
+            $this->select2Context->iFillInSelect2Field($locator,$value);
185
+        }
186
+    }
187 187
 	
188
-	/**
189
-	 * @return JobRepository
190
-	 */
191
-	public function getJobRepository()
192
-	{
193
-		return $this->getRepository('Jobs/Job');
194
-	}
188
+    /**
189
+     * @return JobRepository
190
+     */
191
+    public function getJobRepository()
192
+    {
193
+        return $this->getRepository('Jobs/Job');
194
+    }
195 195
 	
196
-	/**
197
-	 * @return CategoriesRepo
198
-	 */
199
-	public function getCategoriesRepository()
200
-	{
201
-		return $this->getRepository('Jobs/Category');
202
-	}
196
+    /**
197
+     * @return CategoriesRepo
198
+     */
199
+    public function getCategoriesRepository()
200
+    {
201
+        return $this->getRepository('Jobs/Category');
202
+    }
203 203
 	
204
-	/**
205
-	 * @When I have a :status job with the following:
206
-	 * @param TableNode $fields
207
-	 */
208
-	public function iHaveAJobWithTheFollowing($status,TableNode $fields)
209
-	{
210
-		$normalizedField = [
211
-			'template' => 'modern',
212
-		];
213
-		foreach($fields->getRowsHash() as $field => $value){
214
-			$field = Inflector::camelize($field);
215
-			if($field == 'professions' || $field == 'industries'){
216
-				$value = explode(',',$value);
217
-			}
218
-			$normalizedField[$field] = $value;
219
-		}
220
-		$jobRepo = $this->getJobRepository();
221
-		$job = $jobRepo->findOneBy(['title' => $normalizedField['title']]);
222
-		if(!$job instanceof Job){
223
-			$job = new Job();
224
-			$job->setTitle($normalizedField['title']);
225
-		}
226
-		if(isset($normalizedField['user'])){
227
-			/* @var $userRepo UserRepository */
228
-			$userRepo = $this->getRepository('Auth\Entity\User');
229
-			$user = $userRepo->findOneBy(['login' => $normalizedField['user']]);
230
-			if($user instanceof User){
231
-				$job->setUser($user);
232
-				$job->setOrganization($user->getOrganization()->getOrganization());
233
-			}else{
234
-				throw new \Exception('There is no user with this login:"'.$normalizedField['user'.'"']);
235
-			}
236
-		}
204
+    /**
205
+     * @When I have a :status job with the following:
206
+     * @param TableNode $fields
207
+     */
208
+    public function iHaveAJobWithTheFollowing($status,TableNode $fields)
209
+    {
210
+        $normalizedField = [
211
+            'template' => 'modern',
212
+        ];
213
+        foreach($fields->getRowsHash() as $field => $value){
214
+            $field = Inflector::camelize($field);
215
+            if($field == 'professions' || $field == 'industries'){
216
+                $value = explode(',',$value);
217
+            }
218
+            $normalizedField[$field] = $value;
219
+        }
220
+        $jobRepo = $this->getJobRepository();
221
+        $job = $jobRepo->findOneBy(['title' => $normalizedField['title']]);
222
+        if(!$job instanceof Job){
223
+            $job = new Job();
224
+            $job->setTitle($normalizedField['title']);
225
+        }
226
+        if(isset($normalizedField['user'])){
227
+            /* @var $userRepo UserRepository */
228
+            $userRepo = $this->getRepository('Auth\Entity\User');
229
+            $user = $userRepo->findOneBy(['login' => $normalizedField['user']]);
230
+            if($user instanceof User){
231
+                $job->setUser($user);
232
+                $job->setOrganization($user->getOrganization()->getOrganization());
233
+            }else{
234
+                throw new \Exception('There is no user with this login:"'.$normalizedField['user'.'"']);
235
+            }
236
+        }
237 237
 		
238
-		if($status == 'draft'){
239
-			$job->setIsDraft(true);
240
-		}elseif($status == 'published'){
241
-			$job->setIsDraft(false);
242
-			$job->setDatePublishStart(new \DateTime());
243
-		}
244
-		$job->setStatus(Status::ACTIVE);
238
+        if($status == 'draft'){
239
+            $job->setIsDraft(true);
240
+        }elseif($status == 'published'){
241
+            $job->setIsDraft(false);
242
+            $job->setDatePublishStart(new \DateTime());
243
+        }
244
+        $job->setStatus(Status::ACTIVE);
245 245
 		
246
-		if(isset($normalizedField['professions'])){
247
-			$this->addProfessions($job,$normalizedField['professions']);
248
-		}
246
+        if(isset($normalizedField['professions'])){
247
+            $this->addProfessions($job,$normalizedField['professions']);
248
+        }
249 249
 		
250
-		if(isset($normalizedField['industries'])){
251
-			$this->addIndustries($job,$normalizedField['industries']);
252
-		}
250
+        if(isset($normalizedField['industries'])){
251
+            $this->addIndustries($job,$normalizedField['industries']);
252
+        }
253 253
 		
254
-		if(isset($normalizedField['location'])){
255
-			$this->setLocation($job,$normalizedField['location']);
256
-		}
257
-		if(isset($normalizedField['employmentTypes'])){
258
-			$types = $this->getCategories([$normalizedField['employmentTypes']]);
259
-			$type = array_shift($types);
254
+        if(isset($normalizedField['location'])){
255
+            $this->setLocation($job,$normalizedField['location']);
256
+        }
257
+        if(isset($normalizedField['employmentTypes'])){
258
+            $types = $this->getCategories([$normalizedField['employmentTypes']]);
259
+            $type = array_shift($types);
260 260
 			
261
-			$job->getClassifications()->getEmploymentTypes()->getItems()->add($type);
262
-		}
263
-		if(isset($normalizedField['companyName'])){
264
-			$job->setCompany($normalizedField['companyName']);
265
-		}
261
+            $job->getClassifications()->getEmploymentTypes()->getItems()->add($type);
262
+        }
263
+        if(isset($normalizedField['companyName'])){
264
+            $job->setCompany($normalizedField['companyName']);
265
+        }
266 266
 		
267
-		$jobRepo->store($job);
268
-		$this->currentJob = $job;
269
-	}
267
+        $jobRepo->store($job);
268
+        $this->currentJob = $job;
269
+    }
270 270
 	
271
-	private function setLocation(Job $job, $term)
272
-	{
273
-		/* @var $client Photon */
274
-		$client = $this->coreContext->getServiceManager()->get('Geo/Client');
275
-		$result = $client->queryOne($term);
276
-		$location = new Location();
277
-		$serialized = Json::encode($result);
278
-		$location->fromString($serialized);
271
+    private function setLocation(Job $job, $term)
272
+    {
273
+        /* @var $client Photon */
274
+        $client = $this->coreContext->getServiceManager()->get('Geo/Client');
275
+        $result = $client->queryOne($term);
276
+        $location = new Location();
277
+        $serialized = Json::encode($result);
278
+        $location->fromString($serialized);
279 279
 		
280
-		$locations = $job->getLocations();
281
-		if(count($locations)){
282
-			$locations->clear();
283
-		}
284
-		$job->getLocations()->add($location);
285
-	}
280
+        $locations = $job->getLocations();
281
+        if(count($locations)){
282
+            $locations->clear();
283
+        }
284
+        $job->getLocations()->add($location);
285
+    }
286 286
 	
287
-	private function addProfessions(Job $job,$terms)
288
-	{
289
-		$professions = $this->getCategories($terms);
290
-		foreach($professions as $profession){
291
-			$job->getClassifications()->getProfessions()->getItems()->add($profession);
292
-		}
293
-	}
287
+    private function addProfessions(Job $job,$terms)
288
+    {
289
+        $professions = $this->getCategories($terms);
290
+        foreach($professions as $profession){
291
+            $job->getClassifications()->getProfessions()->getItems()->add($profession);
292
+        }
293
+    }
294 294
 	
295
-	private function addIndustries(Job $job, $terms)
296
-	{
297
-		$industries = $this->getCategories($terms);
298
-		foreach($industries as $industry){
299
-			$job->getClassifications()->getIndustries()->getItems()->add($industry);
300
-		}
301
-	}
295
+    private function addIndustries(Job $job, $terms)
296
+    {
297
+        $industries = $this->getCategories($terms);
298
+        foreach($industries as $industry){
299
+            $job->getClassifications()->getIndustries()->getItems()->add($industry);
300
+        }
301
+    }
302 302
 	
303
-	/**
304
-	 * @param array $categories
305
-	 *
306
-	 * @return mixed
307
-	 */
308
-	private function getCategories(array $categories)
309
-	{
310
-		$catRepo = $this->getCategoriesRepository();
303
+    /**
304
+     * @param array $categories
305
+     *
306
+     * @return mixed
307
+     */
308
+    private function getCategories(array $categories)
309
+    {
310
+        $catRepo = $this->getCategoriesRepository();
311 311
 		
312
-		// get a professions
313
-		$qb = $catRepo->createQueryBuilder()
314
-		              ->field('name')->in($categories)
315
-		              ->getQuery()
316
-		;
317
-		$results = $qb->execute();
318
-		return $results->toArray();
319
-	}
312
+        // get a professions
313
+        $qb = $catRepo->createQueryBuilder()
314
+                        ->field('name')->in($categories)
315
+                        ->getQuery()
316
+        ;
317
+        $results = $qb->execute();
318
+        return $results->toArray();
319
+    }
320 320
 	
321
-	/**
322
-	 * @return Job
323
-	 */
324
-	private function getCurrentUserJobDraft($jobTitle)
325
-	{
326
-		$repo = $this->getJobRepository();
327
-		$user = $this->getCurrentUser();
321
+    /**
322
+     * @return Job
323
+     */
324
+    private function getCurrentUserJobDraft($jobTitle)
325
+    {
326
+        $repo = $this->getJobRepository();
327
+        $user = $this->getCurrentUser();
328 328
 		
329
-		$job = $repo->findDraft($user);
329
+        $job = $repo->findDraft($user);
330 330
 		
331
-		if(is_null($job)){
332
-			$job = new Job();
333
-			$job
334
-				->setUser($user)
335
-				->setOrganization($user->getOrganization()->getOrganization())
336
-				->setStatus(StatusInterface::CREATED)
337
-			;
338
-			$job->setIsDraft(true);
339
-		}
340
-		$job->setTitle($jobTitle);
341
-		$repo->store($job);
342
-		return $job;
343
-	}
331
+        if(is_null($job)){
332
+            $job = new Job();
333
+            $job
334
+                ->setUser($user)
335
+                ->setOrganization($user->getOrganization()->getOrganization())
336
+                ->setStatus(StatusInterface::CREATED)
337
+            ;
338
+            $job->setIsDraft(true);
339
+        }
340
+        $job->setTitle($jobTitle);
341
+        $repo->store($job);
342
+        return $job;
343
+    }
344 344
 }
345 345
\ No newline at end of file
Please login to merge, or discard this patch.
module/Behat/src/Select2Context.php 1 patch
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -24,130 +24,130 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
module/Behat/src/CommonContextTrait.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -16,73 +16,73 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
module/Behat/src/ApplicationContext.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -22,26 +22,26 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
module/Behat/src/UserContext.php 1 patch
Indentation   +372 added lines, -372 removed lines patch added patch discarded remove patch
@@ -29,384 +29,384 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
module/Jobs/config/module.config.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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' => [
Please login to merge, or discard this patch.