Completed
Pull Request — develop (#434)
by Carsten
06:27
created
module/Behat/src/CoreContext.php 1 patch
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -22,244 +22,244 @@
 block discarded – undo
22 22
  */
23 23
 class CoreContext extends RawMinkContext
24 24
 {
25
-	static protected $application;
25
+    static protected $application;
26 26
 	
27
-	/**
28
-	 * @var MinkContext
29
-	 */
30
-	protected $minkContext;
27
+    /**
28
+     * @var MinkContext
29
+     */
30
+    protected $minkContext;
31 31
 	
32
-	/**
33
-	 * @BeforeScenario
34
-	 * @param BeforeScenarioScope $scope
35
-	 */
36
-	public function gatherContexts(BeforeScenarioScope $scope)
37
-	{
38
-		$this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class);
39
-	}
32
+    /**
33
+     * @BeforeScenario
34
+     * @param BeforeScenarioScope $scope
35
+     */
36
+    public function gatherContexts(BeforeScenarioScope $scope)
37
+    {
38
+        $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class);
39
+    }
40 40
 	
41
-	/**
42
-	 * @return Application
43
-	 */
44
-	public function getApplication()
45
-	{
46
-		if(!is_object(static::$application)){
47
-			$configFile = realpath(__DIR__.'/../../../config/config.php');
48
-			$config = include($configFile);
49
-			static::$application = Application::init($config);
50
-		}
51
-		return static::$application;
52
-	}
41
+    /**
42
+     * @return Application
43
+     */
44
+    public function getApplication()
45
+    {
46
+        if(!is_object(static::$application)){
47
+            $configFile = realpath(__DIR__.'/../../../config/config.php');
48
+            $config = include($configFile);
49
+            static::$application = Application::init($config);
50
+        }
51
+        return static::$application;
52
+    }
53 53
 	
54
-	/**
55
-	 * @return \Zend\ServiceManager\ServiceManager
56
-	 */
57
-	public function getServiceManager()
58
-	{
59
-		return $this->getApplication()->getServiceManager();
60
-	}
54
+    /**
55
+     * @return \Zend\ServiceManager\ServiceManager
56
+     */
57
+    public function getServiceManager()
58
+    {
59
+        return $this->getApplication()->getServiceManager();
60
+    }
61 61
 	
62
-	/**
63
-	 * @return \Zend\EventManager\EventManagerInterface
64
-	 */
65
-	public function getEventManager()
66
-	{
67
-		return $this->getApplication()->getEventManager();
68
-	}
62
+    /**
63
+     * @return \Zend\EventManager\EventManagerInterface
64
+     */
65
+    public function getEventManager()
66
+    {
67
+        return $this->getApplication()->getEventManager();
68
+    }
69 69
 	
70
-	/**
71
-	 * @return RepositoryService
72
-	 */
73
-	public function getRepositories()
74
-	{
75
-		return $this->getServiceManager()->get('repositories');
76
-	}
70
+    /**
71
+     * @return RepositoryService
72
+     */
73
+    public function getRepositories()
74
+    {
75
+        return $this->getServiceManager()->get('repositories');
76
+    }
77 77
 	
78
-	/**
79
-	 * @param $name
80
-	 * @param array $params
81
-	 *
82
-	 * @return string
83
-	 */
84
-	public function generateUrl($name)
85
-	{
86
-		return $this->minkContext->locatePath($name);
87
-	}
78
+    /**
79
+     * @param $name
80
+     * @param array $params
81
+     *
82
+     * @return string
83
+     */
84
+    public function generateUrl($name)
85
+    {
86
+        return $this->minkContext->locatePath($name);
87
+    }
88 88
 	
89
-	/**
90
-	 * @When /^I hover over the element "([^"]*)"$/
91
-	 */
92
-	public function iHoverOverTheElement($locator)
93
-	{
94
-		$session = $this->minkContext->getSession(); // get the mink session
95
-		$element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element
89
+    /**
90
+     * @When /^I hover over the element "([^"]*)"$/
91
+     */
92
+    public function iHoverOverTheElement($locator)
93
+    {
94
+        $session = $this->minkContext->getSession(); // get the mink session
95
+        $element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element
96 96
 		
97
-		// errors must not pass silently
98
-		if (null === $element) {
99
-			throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator));
100
-		}
97
+        // errors must not pass silently
98
+        if (null === $element) {
99
+            throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator));
100
+        }
101 101
 		
102
-		// ok, let's hover it
103
-		$element->mouseOver();
104
-	}
102
+        // ok, let's hover it
103
+        $element->mouseOver();
104
+    }
105 105
 	
106
-	/**
107
-	 * @Given /^I wait for (\d+) seconds$/
108
-	 */
109
-	public function iWaitForSecond($second)
110
-	{
111
-		sleep($second);
112
-	}
106
+    /**
107
+     * @Given /^I wait for (\d+) seconds$/
108
+     */
109
+    public function iWaitForSecond($second)
110
+    {
111
+        sleep($second);
112
+    }
113 113
 	
114
-	/**
115
-	 * @Then /^I wait for the ajax response$/
116
-	 */
117
-	public function iWaitForTheAjaxResponse()
118
-	{
119
-		$this->getSession()->wait(5000, '(0 === jQuery.active)');
120
-	}
114
+    /**
115
+     * @Then /^I wait for the ajax response$/
116
+     */
117
+    public function iWaitForTheAjaxResponse()
118
+    {
119
+        $this->getSession()->wait(5000, '(0 === jQuery.active)');
120
+    }
121 121
 	
122
-	/**
123
-	 * Some forms do not have a Submit button just pass the ID
124
-	 *
125
-	 * @Given /^I submit the form with id "([^"]*)"$/
126
-	 */
127
-	public function iSubmitTheFormWithId($arg)
128
-	{
129
-		$node = $this->minkContext->getSession()->getPage()->find('css', $arg);
130
-		if($node) {
131
-			$this->minkContext->getSession()->executeScript("jQuery('$arg').submit();");
132
-		} else {
133
-			throw new \Exception('Element not found');
134
-		}
135
-	}
122
+    /**
123
+     * Some forms do not have a Submit button just pass the ID
124
+     *
125
+     * @Given /^I submit the form with id "([^"]*)"$/
126
+     */
127
+    public function iSubmitTheFormWithId($arg)
128
+    {
129
+        $node = $this->minkContext->getSession()->getPage()->find('css', $arg);
130
+        if($node) {
131
+            $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();");
132
+        } else {
133
+            throw new \Exception('Element not found');
134
+        }
135
+    }
136 136
 	
137
-	/**
138
-	 * @Then I switch to popup :name
139
-	 *
140
-	 * @param $name
141
-	 */
142
-	public function iSwitchToPopup($name)
143
-	{
144
-		$this->iSetMainWindowName();
145
-		$this->getSession()->switchToWindow($name);
146
-	}
137
+    /**
138
+     * @Then I switch to popup :name
139
+     *
140
+     * @param $name
141
+     */
142
+    public function iSwitchToPopup($name)
143
+    {
144
+        $this->iSetMainWindowName();
145
+        $this->getSession()->switchToWindow($name);
146
+    }
147 147
 	
148
-	/**
149
-	 * @Then I set main window name
150
-	 */
151
-	public function iSetMainWindowName()
152
-	{
153
-		$window_name = 'main_window';
154
-		$script = 'window.name = "' . $window_name . '"';
155
-		$this->getSession()->executeScript($script);
156
-	}
148
+    /**
149
+     * @Then I set main window name
150
+     */
151
+    public function iSetMainWindowName()
152
+    {
153
+        $window_name = 'main_window';
154
+        $script = 'window.name = "' . $window_name . '"';
155
+        $this->getSession()->executeScript($script);
156
+    }
157 157
 	
158
-	/**
159
-	 * @Then I switch back to main window
160
-	 */
161
-	public function iSwitchBackToMainWindow()
162
-	{
163
-		$this->getSession()->switchToWindow('main_window');
164
-	}
158
+    /**
159
+     * @Then I switch back to main window
160
+     */
161
+    public function iSwitchBackToMainWindow()
162
+    {
163
+        $this->getSession()->switchToWindow('main_window');
164
+    }
165 165
 	
166
-	public function iVisit($url)
167
-	{
168
-		$this->minkContext->getSession()->visit($url);
169
-	}
166
+    public function iVisit($url)
167
+    {
168
+        $this->minkContext->getSession()->visit($url);
169
+    }
170 170
 	
171
-	/**
172
-	 * @When I scroll :selector into view
173
-	 *
174
-	 * @param string $selector Allowed selectors: #id, .className, //xpath
175
-	 *
176
-	 * @throws \Exception
177
-	 */
178
-	public function scrollIntoView($selector)
179
-	{
180
-		$locator = substr($selector, 0, 1);
171
+    /**
172
+     * @When I scroll :selector into view
173
+     *
174
+     * @param string $selector Allowed selectors: #id, .className, //xpath
175
+     *
176
+     * @throws \Exception
177
+     */
178
+    public function scrollIntoView($selector)
179
+    {
180
+        $locator = substr($selector, 0, 1);
181 181
 		
182
-		switch ($locator) {
183
-			case '/' : // XPath selector
184
-				$function = <<<JS
182
+        switch ($locator) {
183
+            case '/' : // XPath selector
184
+                $function = <<<JS
185 185
 (function(){
186 186
   var elem = document.evaluate($selector, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
187 187
   elem.scrollIntoView(false);
188 188
 })()
189 189
 JS;
190
-				break;
190
+                break;
191 191
 			
192
-			case '#' : // ID selector
193
-				$selector = substr($selector, 1);
194
-				$function = <<<JS
192
+            case '#' : // ID selector
193
+                $selector = substr($selector, 1);
194
+                $function = <<<JS
195 195
 (function(){
196 196
   var elem = document.getElementById("$selector");
197 197
   elem.scrollIntoView(false);
198 198
 })()
199 199
 JS;
200
-				break;
200
+                break;
201 201
 			
202
-			case '.' : // Class selector
203
-				$selector = substr($selector, 1);
204
-				$function = <<<JS
202
+            case '.' : // Class selector
203
+                $selector = substr($selector, 1);
204
+                $function = <<<JS
205 205
 (function(){
206 206
   var elem = document.getElementsByClassName("$selector");
207 207
   elem[0].scrollIntoView(false);
208 208
 })()
209 209
 JS;
210
-				break;
210
+                break;
211 211
 			
212
-			default:
213
-				throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath');
214
-				break;
215
-		}
212
+            default:
213
+                throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath');
214
+                break;
215
+        }
216 216
 		
217
-		try {
218
-			$this->getSession()->executeScript($function);
219
-		} catch (\Exception $e) {
220
-			throw new \Exception(__METHOD__ . ' failed');
221
-		}
222
-	}
217
+        try {
218
+            $this->getSession()->executeScript($function);
219
+        } catch (\Exception $e) {
220
+            throw new \Exception(__METHOD__ . ' failed');
221
+        }
222
+    }
223 223
 	
224 224
 	
225
-	/**
226
-	 * @When I click location selector
227
-	 */
228
-	public function iClickLocationSelector()
229
-	{
230
-		$locator = '#jobBase-geoLocation-span .select2';
231
-		$element = $this->getElement($locator);
232
-		$element->click();
233
-	}
225
+    /**
226
+     * @When I click location selector
227
+     */
228
+    public function iClickLocationSelector()
229
+    {
230
+        $locator = '#jobBase-geoLocation-span .select2';
231
+        $element = $this->getElement($locator);
232
+        $element->click();
233
+    }
234 234
 	
235
-	/**
236
-	 * @param $locator
237
-	 * @param string $selector
238
-	 *
239
-	 * @return \Behat\Mink\Element\NodeElement|mixed|null
240
-	 */
241
-	public function getElement($locator,$selector='css')
242
-	{
243
-		$page = $this->minkContext->getSession()->getPage();
244
-		$element = $page->find('css',$locator);
245
-		return $element;
246
-	}
235
+    /**
236
+     * @param $locator
237
+     * @param string $selector
238
+     *
239
+     * @return \Behat\Mink\Element\NodeElement|mixed|null
240
+     */
241
+    public function getElement($locator,$selector='css')
242
+    {
243
+        $page = $this->minkContext->getSession()->getPage();
244
+        $element = $page->find('css',$locator);
245
+        return $element;
246
+    }
247 247
 	
248
-	/**
249
-	 * @When I fill in location search with :term
250
-	 * @param $term
251
-	 */
252
-	public function iFillInLocationSearch($term)
253
-	{
254
-		$locator = '.select2-container--open .select2-search__field';
255
-		$element = $this->getElement($locator);
256
-		$element->focus();
257
-		$element->setValue($term);
258
-		$this->iWaitForTheAjaxResponse();
259
-	}
248
+    /**
249
+     * @When I fill in location search with :term
250
+     * @param $term
251
+     */
252
+    public function iFillInLocationSearch($term)
253
+    {
254
+        $locator = '.select2-container--open .select2-search__field';
255
+        $element = $this->getElement($locator);
256
+        $element->focus();
257
+        $element->setValue($term);
258
+        $this->iWaitForTheAjaxResponse();
259
+    }
260 260
 	
261
-	public function iClickOn()
262
-	{
261
+    public function iClickOn()
262
+    {
263 263
 	
264
-	}
264
+    }
265 265
 }
266 266
\ No newline at end of file
Please login to merge, or discard this patch.
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/SummaryFormContext.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -15,63 +15,63 @@
 block discarded – undo
15 15
 
16 16
 class SummaryFormContext implements Context
17 17
 {
18
-	use CommonContextTrait;
18
+    use CommonContextTrait;
19 19
 	
20
-	private $elementMap = array(
21
-		'name' => '#sf-nameForm',
22
-		'location' => '#sf-locationForm',
23
-		'employees' => '#sf-employeesManagement',
24
-		'workflow' => '#sf-workflowSettings',
25
-		'jobTitleAndLocation' => '#general-locationForm',
26
-		'jobClassification' => '#sf-general-classifications',
27
-		'customerNote' => '#sf-general-customerNote',
28
-		'personalInformations' => '#sf-contact-contact',
29
-		'resumePersonalInformations' => '#sf-contact',
30
-	);
20
+    private $elementMap = array(
21
+        'name' => '#sf-nameForm',
22
+        'location' => '#sf-locationForm',
23
+        'employees' => '#sf-employeesManagement',
24
+        'workflow' => '#sf-workflowSettings',
25
+        'jobTitleAndLocation' => '#general-locationForm',
26
+        'jobClassification' => '#sf-general-classifications',
27
+        'customerNote' => '#sf-general-customerNote',
28
+        'personalInformations' => '#sf-contact-contact',
29
+        'resumePersonalInformations' => '#sf-contact',
30
+    );
31 31
 	
32
-	/**
33
-	 * @When I click edit on :name form
34
-	 * @TODO: [ZF3] move this method to CoreContext
35
-	 */
36
-	public function iClickEditOnForm($name)
37
-	{
38
-		$this->iClickForm($name);
39
-		$name = Inflector::camelize($name);
40
-		$type = $this->elementMap[$name];
41
-		$locator = $type.' .sf-summary .sf-controls button';
42
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
43
-		if(!$element){
44
-			throw new \Exception('No element found with this locator: "'.$locator.'"');
45
-		}
46
-		$element->click();
47
-	}
32
+    /**
33
+     * @When I click edit on :name form
34
+     * @TODO: [ZF3] move this method to CoreContext
35
+     */
36
+    public function iClickEditOnForm($name)
37
+    {
38
+        $this->iClickForm($name);
39
+        $name = Inflector::camelize($name);
40
+        $type = $this->elementMap[$name];
41
+        $locator = $type.' .sf-summary .sf-controls button';
42
+        $element = $this->minkContext->getSession()->getPage()->find('css',$locator);
43
+        if(!$element){
44
+            throw new \Exception('No element found with this locator: "'.$locator.'"');
45
+        }
46
+        $element->click();
47
+    }
48 48
 	
49
-	/**
50
-	 * @When I click :form form
51
-	 */
52
-	public function iClickForm($name)
53
-	{
54
-		$name = Inflector::camelize($name);
55
-		$type = $this->elementMap[$name];
56
-		$locator = $type.' .sf-summary';
57
-		$session = $this->minkContext->getSession();
58
-		$script = <<<EOC
49
+    /**
50
+     * @When I click :form form
51
+     */
52
+    public function iClickForm($name)
53
+    {
54
+        $name = Inflector::camelize($name);
55
+        $type = $this->elementMap[$name];
56
+        $locator = $type.' .sf-summary';
57
+        $session = $this->minkContext->getSession();
58
+        $script = <<<EOC
59 59
 var tElement = jQuery("$locator .sf-controls");
60 60
 tElement.css('display','block');
61 61
 tElement.css('visibility','visible');
62 62
 EOC;
63
-		$session->executeScript($script);
64
-	}
63
+        $session->executeScript($script);
64
+    }
65 65
 	
66
-	/**
67
-	 * @When I save :type form
68
-	 */
69
-	public function iSaveForm($type)
70
-	{
71
-		$type = Inflector::camelize($type);
72
-		$locator = $this->elementMap[$type].' button.sf-submit';
73
-		$this->coreContext->scrollIntoView($locator);
74
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
75
-		$element->click();
76
-	}
66
+    /**
67
+     * @When I save :type form
68
+     */
69
+    public function iSaveForm($type)
70
+    {
71
+        $type = Inflector::camelize($type);
72
+        $locator = $this->elementMap[$type].' button.sf-submit';
73
+        $this->coreContext->scrollIntoView($locator);
74
+        $element = $this->minkContext->getSession()->getPage()->find('css',$locator);
75
+        $element->click();
76
+    }
77 77
 }
78 78
\ 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.