Completed
Push — develop ( 321e68...dce9ea )
by Carsten
09:20
created
module/Behat/src/ApplicationContext.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -22,35 +22,35 @@
 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
-	/**
49
-	 * @Given I visit job categories
50
-	 */
51
-	public function visitJobsCategories()
52
-	{
53
-		$url = '/en/admin/jobs/categories';
54
-		$this->visit($url);
55
-	}
48
+    /**
49
+     * @Given I visit job categories
50
+     */
51
+    public function visitJobsCategories()
52
+    {
53
+        $url = '/en/admin/jobs/categories';
54
+        $this->visit($url);
55
+    }
56 56
 }
57 57
\ No newline at end of file
Please login to merge, or discard this patch.
module/Behat/src/SummaryFormContext.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -15,112 +15,112 @@
 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
-		$method = 'iSave'.$type;
73
-		if(method_exists($this,$method)){
74
-			call_user_func([$this,$method]);
75
-		}else{
76
-			$locator = $this->elementMap[$type].'-buttons-submit';
77
-			$this->coreContext->scrollIntoView($locator);
78
-			$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
79
-			$element->click();
80
-		}
81
-	}
66
+    /**
67
+     * @When I save :type form
68
+     */
69
+    public function iSaveForm($type)
70
+    {
71
+        $type = Inflector::camelize($type);
72
+        $method = 'iSave'.$type;
73
+        if(method_exists($this,$method)){
74
+            call_user_func([$this,$method]);
75
+        }else{
76
+            $locator = $this->elementMap[$type].'-buttons-submit';
77
+            $this->coreContext->scrollIntoView($locator);
78
+            $element = $this->minkContext->getSession()->getPage()->find('css',$locator);
79
+            $element->click();
80
+        }
81
+    }
82 82
 	
83
-	public function iSaveOrganizationName()
84
-	{
85
-		$locator = '#nameForm-buttons-submit';
86
-		$this->coreContext->scrollIntoView($locator);
87
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
88
-		$element->click();
89
-	}
83
+    public function iSaveOrganizationName()
84
+    {
85
+        $locator = '#nameForm-buttons-submit';
86
+        $this->coreContext->scrollIntoView($locator);
87
+        $element = $this->minkContext->getSession()->getPage()->find('css',$locator);
88
+        $element->click();
89
+    }
90 90
 	
91
-	/**
92
-	 * Saving organization workflow
93
-	 */
94
-	public function iSaveWorkflow()
95
-	{
96
-		$locator = '#workflowSettings-buttons-submit';
97
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
98
-		$element->click();
99
-	}
91
+    /**
92
+     * Saving organization workflow
93
+     */
94
+    public function iSaveWorkflow()
95
+    {
96
+        $locator = '#workflowSettings-buttons-submit';
97
+        $element = $this->minkContext->getSession()->getPage()->find('css',$locator);
98
+        $element->click();
99
+    }
100 100
 	
101
-	public function iSaveOrganizationLocation()
102
-	{
103
-		$locator = '#locationForm-buttons-submit';
104
-		$this->coreContext->scrollIntoView($locator);
105
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
106
-		$element->click();
107
-	}
101
+    public function iSaveOrganizationLocation()
102
+    {
103
+        $locator = '#locationForm-buttons-submit';
104
+        $this->coreContext->scrollIntoView($locator);
105
+        $element = $this->minkContext->getSession()->getPage()->find('css',$locator);
106
+        $element->click();
107
+    }
108 108
 	
109 109
 	
110
-	public function iSaveJobClassification()
111
-	{
112
-		$locator = '#general-classifications-buttons-submit';
113
-		$this->coreContext->scrollIntoView($locator);
114
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
115
-		$element->click();
116
-	}
110
+    public function iSaveJobClassification()
111
+    {
112
+        $locator = '#general-classifications-buttons-submit';
113
+        $this->coreContext->scrollIntoView($locator);
114
+        $element = $this->minkContext->getSession()->getPage()->find('css',$locator);
115
+        $element->click();
116
+    }
117 117
 	
118
-	public function iSaveCustomerNote()
119
-	{
120
-		$locator = '#general-customerNote-buttons-submit';
121
-		$this->coreContext->scrollIntoView('#sf-general-customerNote');
122
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
123
-		$element->click();
124
-	}
118
+    public function iSaveCustomerNote()
119
+    {
120
+        $locator = '#general-customerNote-buttons-submit';
121
+        $this->coreContext->scrollIntoView('#sf-general-customerNote');
122
+        $element = $this->minkContext->getSession()->getPage()->find('css',$locator);
123
+        $element->click();
124
+    }
125 125
 	
126 126
 }
127 127
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 		$name = Inflector::camelize($name);
40 40
 		$type = $this->elementMap[$name];
41 41
 		$locator = $type.' .sf-summary .sf-controls button';
42
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
43
-		if(!$element){
42
+		$element = $this->minkContext->getSession()->getPage()->find('css', $locator);
43
+		if (!$element) {
44 44
 			throw new \Exception('No element found with this locator: "'.$locator.'"');
45 45
 		}
46 46
 		$element->click();
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
 	{
71 71
 		$type = Inflector::camelize($type);
72 72
 		$method = 'iSave'.$type;
73
-		if(method_exists($this,$method)){
74
-			call_user_func([$this,$method]);
75
-		}else{
73
+		if (method_exists($this, $method)) {
74
+			call_user_func([$this, $method]);
75
+		} else {
76 76
 			$locator = $this->elementMap[$type].'-buttons-submit';
77 77
 			$this->coreContext->scrollIntoView($locator);
78
-			$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
78
+			$element = $this->minkContext->getSession()->getPage()->find('css', $locator);
79 79
 			$element->click();
80 80
 		}
81 81
 	}
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	{
85 85
 		$locator = '#nameForm-buttons-submit';
86 86
 		$this->coreContext->scrollIntoView($locator);
87
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
87
+		$element = $this->minkContext->getSession()->getPage()->find('css', $locator);
88 88
 		$element->click();
89 89
 	}
90 90
 	
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	public function iSaveWorkflow()
95 95
 	{
96 96
 		$locator = '#workflowSettings-buttons-submit';
97
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
97
+		$element = $this->minkContext->getSession()->getPage()->find('css', $locator);
98 98
 		$element->click();
99 99
 	}
100 100
 	
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	{
103 103
 		$locator = '#locationForm-buttons-submit';
104 104
 		$this->coreContext->scrollIntoView($locator);
105
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
105
+		$element = $this->minkContext->getSession()->getPage()->find('css', $locator);
106 106
 		$element->click();
107 107
 	}
108 108
 	
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	{
112 112
 		$locator = '#general-classifications-buttons-submit';
113 113
 		$this->coreContext->scrollIntoView($locator);
114
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
114
+		$element = $this->minkContext->getSession()->getPage()->find('css', $locator);
115 115
 		$element->click();
116 116
 	}
117 117
 	
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	{
120 120
 		$locator = '#general-customerNote-buttons-submit';
121 121
 		$this->coreContext->scrollIntoView('#sf-general-customerNote');
122
-		$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
122
+		$element = $this->minkContext->getSession()->getPage()->find('css', $locator);
123 123
 		$element->click();
124 124
 	}
125 125
 	
Please login to merge, or discard this patch.
module/Behat/src/UserContext.php 3 patches
Indentation   +385 added lines, -385 removed lines patch added patch discarded remove patch
@@ -32,398 +32,398 @@
 block discarded – undo
32 32
 
33 33
 class UserContext implements Context
34 34
 {
35
-	/**
36
-	 * @var CoreContext
37
-	 */
38
-	private $coreContext;
39
-	
40
-	/**
41
-	 * @var MinkContext
42
-	 */
43
-	private $minkContext;
44
-	
45
-	/**
46
-	 * @var User
47
-	 */
48
-	private $currentUser;
49
-	
50
-	/**
51
-	 * @var User[]
52
-	 */
53
-	static private $users = [];
54
-	
55
-	/**
56
-	 * @var UserRepository
57
-	 */
58
-	static private $userRepo;
59
-	
60
-	/**
61
-	 * @var string
62
-	 */
63
-	static private $currentSession;
64
-	
65
-	private $socialLoginInfo = [];
66
-	
67
-	/**
68
-	 * @var UserInterface
69
-	 */
70
-	private $loggedInUser;
71
-	
72
-	public function __construct($parameters=[])
73
-	{
74
-		$defaultLoginInfo = [
75
-			'facebook' => [
76
-				'email' => getenv('FACEBOOK_USER_EMAIL'),
77
-				'pass' => getenv('FACEBOOK_USER_PASSWORD')
78
-			],
79
-			'linkedin' => [
80
-				'session_key-login' => getenv('LINKEDIN_USER_EMAIL'),
81
-				'session_password-login' => getenv('LINKEDIN_USER_PASSWORD')
82
-			],
83
-		];
84
-		$socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[];
85
-		$this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig);
86
-	}
87
-	
88
-	/**
89
-	 * @AfterSuite
90
-	 * @param AfterSuiteScope $scope
91
-	 */
92
-	static public function afterSuite(AfterSuiteScope $scope)
93
-	{
94
-		$repo = static::$userRepo;
95
-		foreach(static::$users as $user){
96
-			if($repo->findByLogin($user->getLogin())){
97
-				try{
98
-					JobContext::removeJobByUser($user);
99
-					$repo->remove($user,true);
100
-				}catch (\Exception $e){
35
+    /**
36
+     * @var CoreContext
37
+     */
38
+    private $coreContext;
39
+	
40
+    /**
41
+     * @var MinkContext
42
+     */
43
+    private $minkContext;
44
+	
45
+    /**
46
+     * @var User
47
+     */
48
+    private $currentUser;
49
+	
50
+    /**
51
+     * @var User[]
52
+     */
53
+    static private $users = [];
54
+	
55
+    /**
56
+     * @var UserRepository
57
+     */
58
+    static private $userRepo;
59
+	
60
+    /**
61
+     * @var string
62
+     */
63
+    static private $currentSession;
64
+	
65
+    private $socialLoginInfo = [];
66
+	
67
+    /**
68
+     * @var UserInterface
69
+     */
70
+    private $loggedInUser;
71
+	
72
+    public function __construct($parameters=[])
73
+    {
74
+        $defaultLoginInfo = [
75
+            'facebook' => [
76
+                'email' => getenv('FACEBOOK_USER_EMAIL'),
77
+                'pass' => getenv('FACEBOOK_USER_PASSWORD')
78
+            ],
79
+            'linkedin' => [
80
+                'session_key-login' => getenv('LINKEDIN_USER_EMAIL'),
81
+                'session_password-login' => getenv('LINKEDIN_USER_PASSWORD')
82
+            ],
83
+        ];
84
+        $socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[];
85
+        $this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig);
86
+    }
87
+	
88
+    /**
89
+     * @AfterSuite
90
+     * @param AfterSuiteScope $scope
91
+     */
92
+    static public function afterSuite(AfterSuiteScope $scope)
93
+    {
94
+        $repo = static::$userRepo;
95
+        foreach(static::$users as $user){
96
+            if($repo->findByLogin($user->getLogin())){
97
+                try{
98
+                    JobContext::removeJobByUser($user);
99
+                    $repo->remove($user,true);
100
+                }catch (\Exception $e){
101 101
 				
102
-				}
103
-			}
104
-		}
105
-	}
106
-	
107
-	/**
108
-	 * @BeforeScenario
109
-	 * @param BeforeScenarioScope $scope
110
-	 */
111
-	public function beforeScenario(BeforeScenarioScope $scope)
112
-	{
113
-		$this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class);
114
-		$this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class);
115
-		static::$userRepo = $this->getUserRepository();
116
-	}
117
-	
118
-	/**
119
-	 * @return User
120
-	 */
121
-	public function getCurrentUser()
122
-	{
123
-		return $this->currentUser;
124
-	}
125
-	
126
-	/**
127
-	 * @When I fill in login form with :provider user
128
-	 */
129
-	public function iSignInWithSocialUser($provider)
130
-	{
131
-		$provider = strtolower($provider);
132
-		$mink = $this->minkContext;
133
-		foreach($this->socialLoginInfo[$provider] as $field=>$value){
134
-			$mink->fillField($field,$value);
135
-		}
136
-	}
137
-	
138
-	/**
139
-	 * @Given I am logged in as a recruiter
140
-	 * @Given I am logged in as a recruiter with :organization as organization
141
-	 */
142
-	public function iAmLoggedInAsARecruiter($organization=null)
143
-	{
144
-		$user = $this->thereIsAUserIdentifiedBy(
145
-			'[email protected]',
146
-			'test',User::ROLE_RECRUITER,
147
-			'Test Recruiter',
148
-			$organization
149
-		);
150
-		$this->startLogin($user,'test');
151
-	}
152
-	
153
-	/**
154
-	 * @Given I don't have :login user
155
-	 * @param string $login
156
-	 */
157
-	public function iDonTHaveUser($login)
158
-	{
159
-		$repo = $this->getUserRepository();
160
-		$user=$repo->findByLogin($login);
161
-		if($user instanceof UserInterface){
162
-			$repo->remove($user,true);
163
-		}
164
-	}
165
-	
166
-	/**
167
-	 * @Given I have a :role with the following:
168
-	 * @param $role
169
-	 * @param TableNode $fields
170
-	 */
171
-	public function iHaveUserWithTheFollowing($role,TableNode $fields)
172
-	{
173
-		$normalizedFields = [
174
-			'login' => '[email protected]',
175
-			'fullname' => 'Test Login',
176
-			'role' => User::ROLE_USER,
177
-			'password' => 'test',
178
-			'organization' => 'Cross Solution'
179
-		];
180
-		foreach($fields->getRowsHash() as $field=>$value){
181
-			$field = Inflector::camelize($field);
182
-			$normalizedFields[$field] = $value;
183
-		}
102
+                }
103
+            }
104
+        }
105
+    }
106
+	
107
+    /**
108
+     * @BeforeScenario
109
+     * @param BeforeScenarioScope $scope
110
+     */
111
+    public function beforeScenario(BeforeScenarioScope $scope)
112
+    {
113
+        $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class);
114
+        $this->coreContext = $scope->getEnvironment()->getContext(CoreContext::class);
115
+        static::$userRepo = $this->getUserRepository();
116
+    }
117
+	
118
+    /**
119
+     * @return User
120
+     */
121
+    public function getCurrentUser()
122
+    {
123
+        return $this->currentUser;
124
+    }
125
+	
126
+    /**
127
+     * @When I fill in login form with :provider user
128
+     */
129
+    public function iSignInWithSocialUser($provider)
130
+    {
131
+        $provider = strtolower($provider);
132
+        $mink = $this->minkContext;
133
+        foreach($this->socialLoginInfo[$provider] as $field=>$value){
134
+            $mink->fillField($field,$value);
135
+        }
136
+    }
137
+	
138
+    /**
139
+     * @Given I am logged in as a recruiter
140
+     * @Given I am logged in as a recruiter with :organization as organization
141
+     */
142
+    public function iAmLoggedInAsARecruiter($organization=null)
143
+    {
144
+        $user = $this->thereIsAUserIdentifiedBy(
145
+            '[email protected]',
146
+            'test',User::ROLE_RECRUITER,
147
+            'Test Recruiter',
148
+            $organization
149
+        );
150
+        $this->startLogin($user,'test');
151
+    }
152
+	
153
+    /**
154
+     * @Given I don't have :login user
155
+     * @param string $login
156
+     */
157
+    public function iDonTHaveUser($login)
158
+    {
159
+        $repo = $this->getUserRepository();
160
+        $user=$repo->findByLogin($login);
161
+        if($user instanceof UserInterface){
162
+            $repo->remove($user,true);
163
+        }
164
+    }
165
+	
166
+    /**
167
+     * @Given I have a :role with the following:
168
+     * @param $role
169
+     * @param TableNode $fields
170
+     */
171
+    public function iHaveUserWithTheFollowing($role,TableNode $fields)
172
+    {
173
+        $normalizedFields = [
174
+            'login' => '[email protected]',
175
+            'fullname' => 'Test Login',
176
+            'role' => User::ROLE_USER,
177
+            'password' => 'test',
178
+            'organization' => 'Cross Solution'
179
+        ];
180
+        foreach($fields->getRowsHash() as $field=>$value){
181
+            $field = Inflector::camelize($field);
182
+            $normalizedFields[$field] = $value;
183
+        }
184 184
 		
185
-		$this->thereIsAUserIdentifiedBy(
186
-			$normalizedFields['login'],
187
-			$normalizedFields['password'],
188
-			$role,
189
-			$normalizedFields['fullname'],
190
-			$normalizedFields['organization']
191
-		);
185
+        $this->thereIsAUserIdentifiedBy(
186
+            $normalizedFields['login'],
187
+            $normalizedFields['password'],
188
+            $role,
189
+            $normalizedFields['fullname'],
190
+            $normalizedFields['organization']
191
+        );
192 192
 		
193
-	}
194
-	
195
-	/**
196
-	 * @Given I am logged in as an administrator
197
-	 */
198
-	public function iAmLoggedInAsAnAdmin()
199
-	{
200
-		$user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN);
201
-		$this->startLogin($user,'test');
202
-	}
203
-	
204
-	private function startLogin(UserInterface $user, $password)
205
-	{
206
-		$currentUser = $this->currentUser;
207
-		if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){
208
-			$this->iWantToLogIn();
209
-			$this->iSpecifyTheUsernameAs($user->getLogin());
210
-			$this->iSpecifyThePasswordAs($password);
211
-			$this->iLogIn();
212
-			$this->currentUser = $user;
213
-		}
214
-	}
215
-	
216
-	/**
217
-	 * @return UserRepository
218
-	 */
219
-	public function getUserRepository()
220
-	{
221
-		return $this->coreContext->getRepositories()->get('Auth\Entity\User');
222
-	}
223
-	
224
-	/**
225
-	 * @Given there is a user :email identified by :password
226
-	 */
227
-	public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null)
228
-	{
229
-		$repo = $this->getUserRepository();
230
-		if(!is_object($user=$repo->findByEmail($email))){
231
-			$user = $this->createUser($email,$password,$role,$fullname,$organization);
232
-		}
193
+    }
194
+	
195
+    /**
196
+     * @Given I am logged in as an administrator
197
+     */
198
+    public function iAmLoggedInAsAnAdmin()
199
+    {
200
+        $user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN);
201
+        $this->startLogin($user,'test');
202
+    }
203
+	
204
+    private function startLogin(UserInterface $user, $password)
205
+    {
206
+        $currentUser = $this->currentUser;
207
+        if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){
208
+            $this->iWantToLogIn();
209
+            $this->iSpecifyTheUsernameAs($user->getLogin());
210
+            $this->iSpecifyThePasswordAs($password);
211
+            $this->iLogIn();
212
+            $this->currentUser = $user;
213
+        }
214
+    }
215
+	
216
+    /**
217
+     * @return UserRepository
218
+     */
219
+    public function getUserRepository()
220
+    {
221
+        return $this->coreContext->getRepositories()->get('Auth\Entity\User');
222
+    }
223
+	
224
+    /**
225
+     * @Given there is a user :email identified by :password
226
+     */
227
+    public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null)
228
+    {
229
+        $repo = $this->getUserRepository();
230
+        if(!is_object($user=$repo->findByEmail($email))){
231
+            $user = $this->createUser($email,$password,$role,$fullname,$organization);
232
+        }
233 233
 		
234
-		if(!is_null($organization)){
235
-			$this->iHaveMainOrganization($user,$organization);
236
-		}
237
-		$this->addCreatedUser($user);
238
-		return $user;
239
-	}
240
-	
241
-	/**
242
-	 * @param $email
243
-	 * @param $password
244
-	 * @param $username
245
-	 * @param string $fullname
246
-	 * @param string $role
247
-	 *
248
-	 * @return \Auth\Entity\UserInterface
249
-	 */
250
-	public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter")
251
-	{
252
-		/* @var Register $service */
253
-		/* @var User $user */
254
-		$repo = $this->getUserRepository();
255
-		$user = $repo->create([]);
256
-		$user->setLogin($email);
257
-		$user->setPassword($password);
258
-		$user->setRole($role);
259
-		$settings = $user->getSettings('Applications');
234
+        if(!is_null($organization)){
235
+            $this->iHaveMainOrganization($user,$organization);
236
+        }
237
+        $this->addCreatedUser($user);
238
+        return $user;
239
+    }
240
+	
241
+    /**
242
+     * @param $email
243
+     * @param $password
244
+     * @param $username
245
+     * @param string $fullname
246
+     * @param string $role
247
+     *
248
+     * @return \Auth\Entity\UserInterface
249
+     */
250
+    public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter")
251
+    {
252
+        /* @var Register $service */
253
+        /* @var User $user */
254
+        $repo = $this->getUserRepository();
255
+        $user = $repo->create([]);
256
+        $user->setLogin($email);
257
+        $user->setPassword($password);
258
+        $user->setRole($role);
259
+        $settings = $user->getSettings('Applications');
260 260
 		
261
-		$expFullName = explode(' ',$fullname);
262
-		$info = $user->getInfo();
263
-		$info->setFirstName(array_shift($expFullName));
264
-		$info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):'');
265
-		$info->setEmail($email);
266
-		$info->setEmailVerified(true);
267
-		$repo->store($user);
268
-		$repo->getDocumentManager()->refresh($user);
261
+        $expFullName = explode(' ',$fullname);
262
+        $info = $user->getInfo();
263
+        $info->setFirstName(array_shift($expFullName));
264
+        $info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):'');
265
+        $info->setEmail($email);
266
+        $info->setEmailVerified(true);
267
+        $repo->store($user);
268
+        $repo->getDocumentManager()->refresh($user);
269 269
 		
270
-		$eventArgs = new LifecycleEventArgs($user, $repo->getDocumentManager());
271
-		$repo->getDocumentManager()->getEventManager()->dispatchEvent(
272
-			Events::postLoad,
273
-			$eventArgs
274
-		);
275
-		/* @var \Core\EventManager\EventManager $events */
276
-		/* @var \Auth\Listener\Events\AuthEvent $event */
277
-		//@TODO: [Behat] event not working in travis
278
-		//$events = $this->coreContext->getEventManager();
279
-		//$event  = $events->getEvent(AuthEvent::EVENT_USER_REGISTERED, $this);
280
-		//$event->setUser($user);
281
-		//$events->triggerEvent($event);
282
-		return $user;
283
-	}
284
-	
285
-	/**
286
-	 * @When I have :organization as my main organization
287
-	 * @param $orgName
288
-	 */
289
-	public function iHaveMainOrganization(UserInterface $user,$orgName)
290
-	{
291
-		/* @var $repoOrganization OrganizationRepository */
292
-		$repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization');
293
-		$organization=$repoOrganization->findByName($orgName);
294
-		if(!$organization instanceof Organization){
295
-			$organization = new Organization();
296
-			$organizationName = new OrganizationName($orgName);
297
-			$organization->setOrganizationName($organizationName);
298
-			$permissions = $organization->getPermissions();
299
-			$permissions->grant($user,Permissions::PERMISSION_ALL);
300
-		}else {
301
-			$organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL);
302
-		}
303
-		$organization->setUser($user);
304
-		$repoOrganization->store($organization);
305
-		$repoOrganization->getDocumentManager()->refresh($organization);
306
-	}
307
-	
308
-	/**
309
-	 * @When I want to log in
310
-	 */
311
-	public function iWantToLogIn()
312
-	{
313
-		$session = $this->minkContext->getSession();
314
-		$url = $this->minkContext->locatePath('/en/login');
315
-		$session->visit($url);
316
-	}
317
-	
318
-	/**
319
-	 * @When I specify the username as :username
320
-	 */
321
-	public function iSpecifyTheUsernameAs($username)
322
-	{
323
-		$this->minkContext->fillField('Login name',$username);
324
-	}
325
-	
326
-	/**
327
-	 * @When I specify the password as :password
328
-	 */
329
-	public function iSpecifyThePasswordAs($password)
330
-	{
331
-		$this->minkContext->fillField('Password',$password);
332
-	}
333
-	
334
-	/**
335
-	 * @Given I am logged in as :username identified by :password
336
-	 */
337
-	public function iAmLoggedInAsIdentifiedBy($username, $password)
338
-	{
339
-		$repo = $this->getUserRepository();
340
-		$user = $repo->findByLogin($username);
270
+        $eventArgs = new LifecycleEventArgs($user, $repo->getDocumentManager());
271
+        $repo->getDocumentManager()->getEventManager()->dispatchEvent(
272
+            Events::postLoad,
273
+            $eventArgs
274
+        );
275
+        /* @var \Core\EventManager\EventManager $events */
276
+        /* @var \Auth\Listener\Events\AuthEvent $event */
277
+        //@TODO: [Behat] event not working in travis
278
+        //$events = $this->coreContext->getEventManager();
279
+        //$event  = $events->getEvent(AuthEvent::EVENT_USER_REGISTERED, $this);
280
+        //$event->setUser($user);
281
+        //$events->triggerEvent($event);
282
+        return $user;
283
+    }
284
+	
285
+    /**
286
+     * @When I have :organization as my main organization
287
+     * @param $orgName
288
+     */
289
+    public function iHaveMainOrganization(UserInterface $user,$orgName)
290
+    {
291
+        /* @var $repoOrganization OrganizationRepository */
292
+        $repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization');
293
+        $organization=$repoOrganization->findByName($orgName);
294
+        if(!$organization instanceof Organization){
295
+            $organization = new Organization();
296
+            $organizationName = new OrganizationName($orgName);
297
+            $organization->setOrganizationName($organizationName);
298
+            $permissions = $organization->getPermissions();
299
+            $permissions->grant($user,Permissions::PERMISSION_ALL);
300
+        }else {
301
+            $organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL);
302
+        }
303
+        $organization->setUser($user);
304
+        $repoOrganization->store($organization);
305
+        $repoOrganization->getDocumentManager()->refresh($organization);
306
+    }
307
+	
308
+    /**
309
+     * @When I want to log in
310
+     */
311
+    public function iWantToLogIn()
312
+    {
313
+        $session = $this->minkContext->getSession();
314
+        $url = $this->minkContext->locatePath('/en/login');
315
+        $session->visit($url);
316
+    }
317
+	
318
+    /**
319
+     * @When I specify the username as :username
320
+     */
321
+    public function iSpecifyTheUsernameAs($username)
322
+    {
323
+        $this->minkContext->fillField('Login name',$username);
324
+    }
325
+	
326
+    /**
327
+     * @When I specify the password as :password
328
+     */
329
+    public function iSpecifyThePasswordAs($password)
330
+    {
331
+        $this->minkContext->fillField('Password',$password);
332
+    }
333
+	
334
+    /**
335
+     * @Given I am logged in as :username identified by :password
336
+     */
337
+    public function iAmLoggedInAsIdentifiedBy($username, $password)
338
+    {
339
+        $repo = $this->getUserRepository();
340
+        $user = $repo->findByLogin($username);
341 341
 		
342
-		if(!$user instanceof User){
343
-			throw new \Exception(sprintf('There is no user with this login: "%s"',$username));
344
-		}
345
-		$this->currentUser = $user;
346
-		$this->iWantToLogIn();
347
-		$this->iSpecifyTheUsernameAs($username);
348
-		$this->iSpecifyThePasswordAs($password);
349
-		$this->iLogIn();
350
-	}
351
-	
352
-	/**
353
-	 * @When I log in
354
-	 */
355
-	public function iLogIn()
356
-	{
357
-		$this->minkContext->pressButton('login');
358
-	}
359
-	
360
-	/**
361
-	 * @When I press logout link
362
-	 */
363
-	public function iPressLogoutLink()
364
-	{
365
-		//@TODO: [ZF3] replace this with click method
366
-		$url = $this->coreContext->generateUrl('/logout');
367
-		$this->minkContext->visit($url);
368
-	}
369
-	
370
-	/**
371
-	 * @Given I log in with username :username and password :password
372
-	 */
373
-	public function iLogInWith($username, $password)
374
-	{
375
-		$repo = $this->getUserRepository();
376
-		$user = $repo->findByLogin($username);
377
-		$this->iWantToLogIn();
378
-		$this->iSpecifyTheUsernameAs($username);
379
-		$this->iSpecifyThePasswordAs($password);
380
-		$this->iLogIn();
381
-		$this->loggedInUser = $user;
382
-	}
383
-	
384
-	/**
385
-	 * @When I go to profile page
386
-	 */
387
-	public function iGoToProfilePage()
388
-	{
389
-		$url = $this->coreContext->generateUrl('/en/my/profile');
390
-		$this->minkContext->visit($url);
391
-	}
392
-	
393
-	/**
394
-	 * @Given there is a user with the following:
395
-	 */
396
-	public function thereIsAUserWithTheFollowing(TableNode $table)
397
-	{
398
-		$repo = $this->getUserRepository();
399
-		$data = $table->getRowsHash();
400
-		$email = isset($data['email']) ? $data['email']:'[email protected]';
401
-		$password = isset($data['password']) ? $data['password']:'test';
402
-		$fullname = isset($data['fullname']) ? $data['fullname']:'Test User';
403
-		$role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER;
342
+        if(!$user instanceof User){
343
+            throw new \Exception(sprintf('There is no user with this login: "%s"',$username));
344
+        }
345
+        $this->currentUser = $user;
346
+        $this->iWantToLogIn();
347
+        $this->iSpecifyTheUsernameAs($username);
348
+        $this->iSpecifyThePasswordAs($password);
349
+        $this->iLogIn();
350
+    }
351
+	
352
+    /**
353
+     * @When I log in
354
+     */
355
+    public function iLogIn()
356
+    {
357
+        $this->minkContext->pressButton('login');
358
+    }
359
+	
360
+    /**
361
+     * @When I press logout link
362
+     */
363
+    public function iPressLogoutLink()
364
+    {
365
+        //@TODO: [ZF3] replace this with click method
366
+        $url = $this->coreContext->generateUrl('/logout');
367
+        $this->minkContext->visit($url);
368
+    }
369
+	
370
+    /**
371
+     * @Given I log in with username :username and password :password
372
+     */
373
+    public function iLogInWith($username, $password)
374
+    {
375
+        $repo = $this->getUserRepository();
376
+        $user = $repo->findByLogin($username);
377
+        $this->iWantToLogIn();
378
+        $this->iSpecifyTheUsernameAs($username);
379
+        $this->iSpecifyThePasswordAs($password);
380
+        $this->iLogIn();
381
+        $this->loggedInUser = $user;
382
+    }
383
+	
384
+    /**
385
+     * @When I go to profile page
386
+     */
387
+    public function iGoToProfilePage()
388
+    {
389
+        $url = $this->coreContext->generateUrl('/en/my/profile');
390
+        $this->minkContext->visit($url);
391
+    }
392
+	
393
+    /**
394
+     * @Given there is a user with the following:
395
+     */
396
+    public function thereIsAUserWithTheFollowing(TableNode $table)
397
+    {
398
+        $repo = $this->getUserRepository();
399
+        $data = $table->getRowsHash();
400
+        $email = isset($data['email']) ? $data['email']:'[email protected]';
401
+        $password = isset($data['password']) ? $data['password']:'test';
402
+        $fullname = isset($data['fullname']) ? $data['fullname']:'Test User';
403
+        $role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER;
404 404
 		
405
-		if(!is_object($user=$repo->findByLogin($email))){
406
-			$user = $this->createUser($email,$password,$role,$fullname);
407
-		}
408
-		$this->currentUser = $user;
409
-		$this->addCreatedUser($user);
410
-	}
411
-	
412
-	private function addCreatedUser(UserInterface $user)
413
-	{
414
-		if(!in_array($user,static::$users)){
415
-			static::$users[] = $user;
416
-		}
417
-	}
418
-	
419
-	/**
420
-	 * @When I want to change my password
421
-	 */
422
-	public function iWantToChangeMyPassword()
423
-	{
424
-		$mink = $this->minkContext;
425
-		$url = $this->coreContext->generateUrl('/en/my/password');
426
-		$mink->getSession()->visit($url);
427
-	}
405
+        if(!is_object($user=$repo->findByLogin($email))){
406
+            $user = $this->createUser($email,$password,$role,$fullname);
407
+        }
408
+        $this->currentUser = $user;
409
+        $this->addCreatedUser($user);
410
+    }
411
+	
412
+    private function addCreatedUser(UserInterface $user)
413
+    {
414
+        if(!in_array($user,static::$users)){
415
+            static::$users[] = $user;
416
+        }
417
+    }
418
+	
419
+    /**
420
+     * @When I want to change my password
421
+     */
422
+    public function iWantToChangeMyPassword()
423
+    {
424
+        $mink = $this->minkContext;
425
+        $url = $this->coreContext->generateUrl('/en/my/password');
426
+        $mink->getSession()->visit($url);
427
+    }
428 428
 	
429 429
 }
430 430
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	private $loggedInUser;
71 71
 	
72
-	public function __construct($parameters=[])
72
+	public function __construct($parameters = [])
73 73
 	{
74 74
 		$defaultLoginInfo = [
75 75
 			'facebook' => [
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 				'session_password-login' => getenv('LINKEDIN_USER_PASSWORD')
82 82
 			],
83 83
 		];
84
-		$socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info']:[];
85
-		$this->socialLoginInfo = array_merge($defaultLoginInfo,$socialLoginConfig);
84
+		$socialLoginConfig = isset($parameters['social_login_info']) ? $parameters['social_login_info'] : [];
85
+		$this->socialLoginInfo = array_merge($defaultLoginInfo, $socialLoginConfig);
86 86
 	}
87 87
 	
88 88
 	/**
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 	static public function afterSuite(AfterSuiteScope $scope)
93 93
 	{
94 94
 		$repo = static::$userRepo;
95
-		foreach(static::$users as $user){
96
-			if($repo->findByLogin($user->getLogin())){
97
-				try{
95
+		foreach (static::$users as $user) {
96
+			if ($repo->findByLogin($user->getLogin())) {
97
+				try {
98 98
 					JobContext::removeJobByUser($user);
99
-					$repo->remove($user,true);
100
-				}catch (\Exception $e){
99
+					$repo->remove($user, true);
100
+				} catch (\Exception $e) {
101 101
 				
102 102
 				}
103 103
 			}
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
 	{
131 131
 		$provider = strtolower($provider);
132 132
 		$mink = $this->minkContext;
133
-		foreach($this->socialLoginInfo[$provider] as $field=>$value){
134
-			$mink->fillField($field,$value);
133
+		foreach ($this->socialLoginInfo[$provider] as $field=>$value) {
134
+			$mink->fillField($field, $value);
135 135
 		}
136 136
 	}
137 137
 	
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 	 * @Given I am logged in as a recruiter
140 140
 	 * @Given I am logged in as a recruiter with :organization as organization
141 141
 	 */
142
-	public function iAmLoggedInAsARecruiter($organization=null)
142
+	public function iAmLoggedInAsARecruiter($organization = null)
143 143
 	{
144 144
 		$user = $this->thereIsAUserIdentifiedBy(
145 145
 			'[email protected]',
146
-			'test',User::ROLE_RECRUITER,
146
+			'test', User::ROLE_RECRUITER,
147 147
 			'Test Recruiter',
148 148
 			$organization
149 149
 		);
150
-		$this->startLogin($user,'test');
150
+		$this->startLogin($user, 'test');
151 151
 	}
152 152
 	
153 153
 	/**
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 	public function iDonTHaveUser($login)
158 158
 	{
159 159
 		$repo = $this->getUserRepository();
160
-		$user=$repo->findByLogin($login);
161
-		if($user instanceof UserInterface){
162
-			$repo->remove($user,true);
160
+		$user = $repo->findByLogin($login);
161
+		if ($user instanceof UserInterface) {
162
+			$repo->remove($user, true);
163 163
 		}
164 164
 	}
165 165
 	
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @param $role
169 169
 	 * @param TableNode $fields
170 170
 	 */
171
-	public function iHaveUserWithTheFollowing($role,TableNode $fields)
171
+	public function iHaveUserWithTheFollowing($role, TableNode $fields)
172 172
 	{
173 173
 		$normalizedFields = [
174 174
 			'login' => '[email protected]',
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 			'password' => 'test',
178 178
 			'organization' => 'Cross Solution'
179 179
 		];
180
-		foreach($fields->getRowsHash() as $field=>$value){
180
+		foreach ($fields->getRowsHash() as $field=>$value) {
181 181
 			$field = Inflector::camelize($field);
182 182
 			$normalizedFields[$field] = $value;
183 183
 		}
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	public function iAmLoggedInAsAnAdmin()
199 199
 	{
200
-		$user = $this->thereIsAUserIdentifiedBy('[email protected]','test',User::ROLE_ADMIN);
201
-		$this->startLogin($user,'test');
200
+		$user = $this->thereIsAUserIdentifiedBy('[email protected]', 'test', User::ROLE_ADMIN);
201
+		$this->startLogin($user, 'test');
202 202
 	}
203 203
 	
204 204
 	private function startLogin(UserInterface $user, $password)
205 205
 	{
206 206
 		$currentUser = $this->currentUser;
207
-		if(!is_object($currentUser) || $user->getId()!=$currentUser->getId()){
207
+		if (!is_object($currentUser) || $user->getId() != $currentUser->getId()) {
208 208
 			$this->iWantToLogIn();
209 209
 			$this->iSpecifyTheUsernameAs($user->getLogin());
210 210
 			$this->iSpecifyThePasswordAs($password);
@@ -224,15 +224,15 @@  discard block
 block discarded – undo
224 224
 	/**
225 225
 	 * @Given there is a user :email identified by :password
226 226
 	 */
227
-	public function thereIsAUserIdentifiedBy($email, $password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter",$organization=null)
227
+	public function thereIsAUserIdentifiedBy($email, $password, $role = User::ROLE_RECRUITER, $fullname = "Test Recruiter", $organization = null)
228 228
 	{
229 229
 		$repo = $this->getUserRepository();
230
-		if(!is_object($user=$repo->findByEmail($email))){
231
-			$user = $this->createUser($email,$password,$role,$fullname,$organization);
230
+		if (!is_object($user = $repo->findByEmail($email))) {
231
+			$user = $this->createUser($email, $password, $role, $fullname, $organization);
232 232
 		}
233 233
 		
234
-		if(!is_null($organization)){
235
-			$this->iHaveMainOrganization($user,$organization);
234
+		if (!is_null($organization)) {
235
+			$this->iHaveMainOrganization($user, $organization);
236 236
 		}
237 237
 		$this->addCreatedUser($user);
238 238
 		return $user;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 *
248 248
 	 * @return \Auth\Entity\UserInterface
249 249
 	 */
250
-	public function createUser($email,$password,$role=User::ROLE_RECRUITER,$fullname="Test Recruiter")
250
+	public function createUser($email, $password, $role = User::ROLE_RECRUITER, $fullname = "Test Recruiter")
251 251
 	{
252 252
 		/* @var Register $service */
253 253
 		/* @var User $user */
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 		$user->setRole($role);
259 259
 		$settings = $user->getSettings('Applications');
260 260
 		
261
-		$expFullName = explode(' ',$fullname);
261
+		$expFullName = explode(' ', $fullname);
262 262
 		$info = $user->getInfo();
263 263
 		$info->setFirstName(array_shift($expFullName));
264
-		$info->setLastName(count($expFullName)>0 ? implode(' ',$expFullName):'');
264
+		$info->setLastName(count($expFullName) > 0 ? implode(' ', $expFullName) : '');
265 265
 		$info->setEmail($email);
266 266
 		$info->setEmailVerified(true);
267 267
 		$repo->store($user);
@@ -286,19 +286,19 @@  discard block
 block discarded – undo
286 286
 	 * @When I have :organization as my main organization
287 287
 	 * @param $orgName
288 288
 	 */
289
-	public function iHaveMainOrganization(UserInterface $user,$orgName)
289
+	public function iHaveMainOrganization(UserInterface $user, $orgName)
290 290
 	{
291 291
 		/* @var $repoOrganization OrganizationRepository */
292 292
 		$repoOrganization = $this->coreContext->getRepositories()->get('Organizations/Organization');
293
-		$organization=$repoOrganization->findByName($orgName);
294
-		if(!$organization instanceof Organization){
293
+		$organization = $repoOrganization->findByName($orgName);
294
+		if (!$organization instanceof Organization) {
295 295
 			$organization = new Organization();
296 296
 			$organizationName = new OrganizationName($orgName);
297 297
 			$organization->setOrganizationName($organizationName);
298 298
 			$permissions = $organization->getPermissions();
299
-			$permissions->grant($user,Permissions::PERMISSION_ALL);
300
-		}else {
301
-			$organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL);
299
+			$permissions->grant($user, Permissions::PERMISSION_ALL);
300
+		} else {
301
+			$organization->getPermissions()->grant($user, Permissions::PERMISSION_ALL);
302 302
 		}
303 303
 		$organization->setUser($user);
304 304
 		$repoOrganization->store($organization);
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	public function iSpecifyTheUsernameAs($username)
322 322
 	{
323
-		$this->minkContext->fillField('Login name',$username);
323
+		$this->minkContext->fillField('Login name', $username);
324 324
 	}
325 325
 	
326 326
 	/**
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 */
329 329
 	public function iSpecifyThePasswordAs($password)
330 330
 	{
331
-		$this->minkContext->fillField('Password',$password);
331
+		$this->minkContext->fillField('Password', $password);
332 332
 	}
333 333
 	
334 334
 	/**
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 		$repo = $this->getUserRepository();
340 340
 		$user = $repo->findByLogin($username);
341 341
 		
342
-		if(!$user instanceof User){
343
-			throw new \Exception(sprintf('There is no user with this login: "%s"',$username));
342
+		if (!$user instanceof User) {
343
+			throw new \Exception(sprintf('There is no user with this login: "%s"', $username));
344 344
 		}
345 345
 		$this->currentUser = $user;
346 346
 		$this->iWantToLogIn();
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 	{
398 398
 		$repo = $this->getUserRepository();
399 399
 		$data = $table->getRowsHash();
400
-		$email = isset($data['email']) ? $data['email']:'[email protected]';
401
-		$password = isset($data['password']) ? $data['password']:'test';
402
-		$fullname = isset($data['fullname']) ? $data['fullname']:'Test User';
403
-		$role = isset($data['role']) ? $data['role']:User::ROLE_RECRUITER;
400
+		$email = isset($data['email']) ? $data['email'] : '[email protected]';
401
+		$password = isset($data['password']) ? $data['password'] : 'test';
402
+		$fullname = isset($data['fullname']) ? $data['fullname'] : 'Test User';
403
+		$role = isset($data['role']) ? $data['role'] : User::ROLE_RECRUITER;
404 404
 		
405
-		if(!is_object($user=$repo->findByLogin($email))){
406
-			$user = $this->createUser($email,$password,$role,$fullname);
405
+		if (!is_object($user = $repo->findByLogin($email))) {
406
+			$user = $this->createUser($email, $password, $role, $fullname);
407 407
 		}
408 408
 		$this->currentUser = $user;
409 409
 		$this->addCreatedUser($user);
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	
412 412
 	private function addCreatedUser(UserInterface $user)
413 413
 	{
414
-		if(!in_array($user,static::$users)){
414
+		if (!in_array($user, static::$users)) {
415 415
 			static::$users[] = $user;
416 416
 		}
417 417
 	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 				try{
98 98
 					JobContext::removeJobByUser($user);
99 99
 					$repo->remove($user,true);
100
-				}catch (\Exception $e){
100
+				} catch (\Exception $e){
101 101
 				
102 102
 				}
103 103
 			}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 			$organization->setOrganizationName($organizationName);
298 298
 			$permissions = $organization->getPermissions();
299 299
 			$permissions->grant($user,Permissions::PERMISSION_ALL);
300
-		}else {
300
+		} else {
301 301
 			$organization->getPermissions()->grant($user,Permissions::PERMISSION_ALL);
302 302
 		}
303 303
 		$organization->setUser($user);
Please login to merge, or discard this patch.
module/Behat/src/JobContext.php 2 patches
Indentation   +282 added lines, -282 removed lines patch added patch discarded remove patch
@@ -33,320 +33,320 @@
 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['location'])){
247
-			$this->setLocation($job,$normalizedField['location']);
248
-		}
249
-		if(isset($normalizedField['companyName'])){
250
-			//$job->setCompany($normalizedField['companyName']);
251
-		}
252
-		if(isset($normalizedField['professions'])){
253
-			$this->addProfessions($job,$normalizedField['professions']);
254
-		}
246
+        if(isset($normalizedField['location'])){
247
+            $this->setLocation($job,$normalizedField['location']);
248
+        }
249
+        if(isset($normalizedField['companyName'])){
250
+            //$job->setCompany($normalizedField['companyName']);
251
+        }
252
+        if(isset($normalizedField['professions'])){
253
+            $this->addProfessions($job,$normalizedField['professions']);
254
+        }
255 255
 		
256
-		if(isset($normalizedField['industries'])){
257
-			$this->addIndustries($job,$normalizedField['industries']);
258
-		}
259
-		if(isset($normalizedField['employmentTypes'])){
260
-			$types = $this->getCategories([$normalizedField['employmentTypes']]);
261
-			$type = array_shift($types);
262
-			$values = $job->getClassifications()->getEmploymentTypes()->getValues();
263
-			if(!is_array($values) || !in_array($type,$values)){
264
-				$job->getClassifications()->getEmploymentTypes()->getItems()->add($type);
265
-			}
266
-		}
256
+        if(isset($normalizedField['industries'])){
257
+            $this->addIndustries($job,$normalizedField['industries']);
258
+        }
259
+        if(isset($normalizedField['employmentTypes'])){
260
+            $types = $this->getCategories([$normalizedField['employmentTypes']]);
261
+            $type = array_shift($types);
262
+            $values = $job->getClassifications()->getEmploymentTypes()->getValues();
263
+            if(!is_array($values) || !in_array($type,$values)){
264
+                $job->getClassifications()->getEmploymentTypes()->getItems()->add($type);
265
+            }
266
+        }
267 267
 		
268
-		$jobRepo->store($job);
269
-		$this->currentJob = $job;
270
-	}
268
+        $jobRepo->store($job);
269
+        $this->currentJob = $job;
270
+    }
271 271
 	
272
-	private function setLocation(Job $job, $term)
273
-	{
274
-		/* @var $client Photon */
275
-		$client = $this->coreContext->getServiceManager()->get('Geo/Client');
276
-		$result = $client->queryOne($term);
277
-		$location = new Location();
278
-		$serialized = Json::encode($result);
279
-		$location->fromString($serialized);
272
+    private function setLocation(Job $job, $term)
273
+    {
274
+        /* @var $client Photon */
275
+        $client = $this->coreContext->getServiceManager()->get('Geo/Client');
276
+        $result = $client->queryOne($term);
277
+        $location = new Location();
278
+        $serialized = Json::encode($result);
279
+        $location->fromString($serialized);
280 280
 		
281
-		$locations = $job->getLocations();
282
-		if(count($locations)){
283
-			$locations->clear();
284
-		}
285
-		$job->getLocations()->add($location);
286
-	}
281
+        $locations = $job->getLocations();
282
+        if(count($locations)){
283
+            $locations->clear();
284
+        }
285
+        $job->getLocations()->add($location);
286
+    }
287 287
 	
288
-	private function addProfessions(Job &$job,$terms)
289
-	{
290
-		$professions = $this->getCategories($terms);
291
-		foreach($professions as $profession){
292
-			$values = $job->getClassifications()->getProfessions()->getValues();
293
-			if(!is_array($values) || !in_array($profession,$values)){
294
-				$job->getClassifications()->getProfessions()->getItems()->add($profession);
295
-			}
296
-		}
297
-	}
288
+    private function addProfessions(Job &$job,$terms)
289
+    {
290
+        $professions = $this->getCategories($terms);
291
+        foreach($professions as $profession){
292
+            $values = $job->getClassifications()->getProfessions()->getValues();
293
+            if(!is_array($values) || !in_array($profession,$values)){
294
+                $job->getClassifications()->getProfessions()->getItems()->add($profession);
295
+            }
296
+        }
297
+    }
298 298
 	
299
-	private function addIndustries(Job &$job, $terms)
300
-	{
301
-		$industries = $this->getCategories($terms);
302
-		foreach($industries as $industry){
303
-			$values = $job->getClassifications()->getIndustries()->getValues();
304
-			if(!is_array($values) || !in_array($industry,$values)){
305
-				$job->getClassifications()->getIndustries()->getItems()->add($industry);
306
-			}
307
-		}
308
-	}
299
+    private function addIndustries(Job &$job, $terms)
300
+    {
301
+        $industries = $this->getCategories($terms);
302
+        foreach($industries as $industry){
303
+            $values = $job->getClassifications()->getIndustries()->getValues();
304
+            if(!is_array($values) || !in_array($industry,$values)){
305
+                $job->getClassifications()->getIndustries()->getItems()->add($industry);
306
+            }
307
+        }
308
+    }
309 309
 	
310
-	/**
311
-	 * @param array $categories
312
-	 *
313
-	 * @return mixed
314
-	 */
315
-	private function getCategories(array $categories)
316
-	{
317
-		$catRepo = $this->getCategoriesRepository();
310
+    /**
311
+     * @param array $categories
312
+     *
313
+     * @return mixed
314
+     */
315
+    private function getCategories(array $categories)
316
+    {
317
+        $catRepo = $this->getCategoriesRepository();
318 318
 		
319
-		// get a professions
320
-		$qb = $catRepo->createQueryBuilder()
321
-		              ->field('name')->in($categories)
322
-		              ->getQuery()
323
-		;
324
-		$results = $qb->execute();
325
-		return $results->toArray();
326
-	}
319
+        // get a professions
320
+        $qb = $catRepo->createQueryBuilder()
321
+                        ->field('name')->in($categories)
322
+                        ->getQuery()
323
+        ;
324
+        $results = $qb->execute();
325
+        return $results->toArray();
326
+    }
327 327
 	
328 328
 	
329
-	/**
330
-	 * @return Job
331
-	 */
332
-	private function getCurrentUserJobDraft($jobTitle)
333
-	{
334
-		$repo = $this->getJobRepository();
335
-		$user = $this->getCurrentUser();
329
+    /**
330
+     * @return Job
331
+     */
332
+    private function getCurrentUserJobDraft($jobTitle)
333
+    {
334
+        $repo = $this->getJobRepository();
335
+        $user = $this->getCurrentUser();
336 336
 		
337
-		$job = $repo->findDraft($user);
337
+        $job = $repo->findDraft($user);
338 338
 		
339
-		if(is_null($job)){
340
-			$job = new Job();
341
-			$job
342
-				->setUser($user)
343
-				->setOrganization($user->getOrganization()->getOrganization())
344
-				->setStatus(StatusInterface::CREATED)
345
-			;
346
-			$job->setIsDraft(true);
347
-		}
348
-		$job->setTitle($jobTitle);
349
-		$repo->store($job);
350
-		return $job;
351
-	}
339
+        if(is_null($job)){
340
+            $job = new Job();
341
+            $job
342
+                ->setUser($user)
343
+                ->setOrganization($user->getOrganization()->getOrganization())
344
+                ->setStatus(StatusInterface::CREATED)
345
+            ;
346
+            $job->setIsDraft(true);
347
+        }
348
+        $job->setTitle($jobTitle);
349
+        $repo->store($job);
350
+        return $job;
351
+    }
352 352
 }
353 353
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 	{
58 58
 		$repo = static::$jobRepo;
59 59
 		$results = $repo->findBy(['user' => $user]);
60
-		foreach($results as $result){
61
-			$repo->remove($result,true);
60
+		foreach ($results as $result) {
61
+			$repo->remove($result, true);
62 62
 		}
63 63
 	}
64 64
 	
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	public function beforeScenario(BeforeScenarioScope $scope)
71 71
 	{
72 72
 		$this->select2Context = $scope->getEnvironment()->getContext(Select2Context::class);
73
-		if(is_null(static::$jobRepo)){
73
+		if (is_null(static::$jobRepo)) {
74 74
 			$this->gatherContexts($scope);
75 75
 			static::$jobRepo = $this->getJobRepository();
76 76
 		}
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	public function iGoToEditJobWithTitle($jobTitle)
109 109
 	{
110 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));
111
+		if (!$job instanceof Job) {
112
+			throw new \Exception(sprintf('Job with title "%s" is not found', $jobTitle));
113 113
 		}
114 114
 		$this->currentJob = $job;
115 115
 		$url = '/en/jobs/edit?id='.$job->getId();
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 		$user = $this->getCurrentUser();
136 136
 		$jobRepository = $this->getJobRepository();
137 137
 		$results = $jobRepository->getUserJobs($user->getId());
138
-		foreach($results as $job){
139
-			$jobRepository->remove($job,true);
138
+		foreach ($results as $job) {
139
+			$jobRepository->remove($job, true);
140 140
 		}
141 141
 		$this->currentJob = null;
142 142
 	}
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
 	 * @When I fill job location search with :search and choose :choice
146 146
 	 *
147 147
 	 */
148
-	public function iFillJobLocationAndChoose($search,$choice)
148
+	public function iFillJobLocationAndChoose($search, $choice)
149 149
 	{
150 150
 		$select2 = $this->select2Context;
151
-		$select2->iFillInSelect2FieldWith('jobBase[geoLocation]',$search,$choice);
151
+		$select2->iFillInSelect2FieldWith('jobBase[geoLocation]', $search, $choice);
152 152
 	}
153 153
 	
154 154
 	/**
155 155
 	 * @When I choose :value from :field
156 156
 	 */
157
-	public function iJobClassificationSelect($value,$field)
157
+	public function iJobClassificationSelect($value, $field)
158 158
 	{
159 159
 		$field = Inflector::camelize($field);
160 160
 		
@@ -170,18 +170,18 @@  discard block
 block discarded – undo
170 170
 			'employmentTypes'    => "select#classifications-employmentTypes",
171 171
 		];
172 172
 		
173
-		if(!isset($mapSelect2[$field])){
173
+		if (!isset($mapSelect2[$field])) {
174 174
 			throw new \Exception('Undefined field selection value "'.$field.'"');
175 175
 		}
176 176
 		
177 177
 		$multipleField = $mapMultiple[$field];
178 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{
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 183
 			$locator = $mapSelect2[$field];
184
-			$this->select2Context->iFillInSelect2Field($locator,$value);
184
+			$this->select2Context->iFillInSelect2Field($locator, $value);
185 185
 		}
186 186
 	}
187 187
 	
@@ -205,62 +205,62 @@  discard block
 block discarded – undo
205 205
 	 * @When I have a :status job with the following:
206 206
 	 * @param TableNode $fields
207 207
 	 */
208
-	public function iHaveAJobWithTheFollowing($status,TableNode $fields)
208
+	public function iHaveAJobWithTheFollowing($status, TableNode $fields)
209 209
 	{
210 210
 		$normalizedField = [
211 211
 			'template' => 'modern',
212 212
 		];
213
-		foreach($fields->getRowsHash() as $field => $value){
213
+		foreach ($fields->getRowsHash() as $field => $value) {
214 214
 			$field = Inflector::camelize($field);
215
-			if($field == 'professions' || $field == 'industries'){
216
-				$value = explode(',',$value);
215
+			if ($field == 'professions' || $field == 'industries') {
216
+				$value = explode(',', $value);
217 217
 			}
218 218
 			$normalizedField[$field] = $value;
219 219
 		}
220 220
 		$jobRepo = $this->getJobRepository();
221 221
 		$job = $jobRepo->findOneBy(['title' => $normalizedField['title']]);
222
-		if(!$job instanceof Job){
222
+		if (!$job instanceof Job) {
223 223
 			$job = new Job();
224 224
 			$job->setTitle($normalizedField['title']);
225 225
 		}
226
-		if(isset($normalizedField['user'])){
226
+		if (isset($normalizedField['user'])) {
227 227
 			/* @var $userRepo UserRepository */
228 228
 			$userRepo = $this->getRepository('Auth\Entity\User');
229 229
 			$user = $userRepo->findOneBy(['login' => $normalizedField['user']]);
230
-			if($user instanceof User){
230
+			if ($user instanceof User) {
231 231
 				$job->setUser($user);
232 232
 				$job->setOrganization($user->getOrganization()->getOrganization());
233
-			}else{
233
+			} else {
234 234
 				throw new \Exception('There is no user with this login:"'.$normalizedField['user'.'"']);
235 235
 			}
236 236
 		}
237 237
 		
238
-		if($status == 'draft'){
238
+		if ($status == 'draft') {
239 239
 			$job->setIsDraft(true);
240
-		}elseif($status == 'published'){
240
+		}elseif ($status == 'published') {
241 241
 			$job->setIsDraft(false);
242 242
 			$job->setDatePublishStart(new \DateTime());
243 243
 		}
244 244
 		$job->setStatus(Status::ACTIVE);
245 245
 		
246
-		if(isset($normalizedField['location'])){
247
-			$this->setLocation($job,$normalizedField['location']);
246
+		if (isset($normalizedField['location'])) {
247
+			$this->setLocation($job, $normalizedField['location']);
248 248
 		}
249
-		if(isset($normalizedField['companyName'])){
249
+		if (isset($normalizedField['companyName'])) {
250 250
 			//$job->setCompany($normalizedField['companyName']);
251 251
 		}
252
-		if(isset($normalizedField['professions'])){
253
-			$this->addProfessions($job,$normalizedField['professions']);
252
+		if (isset($normalizedField['professions'])) {
253
+			$this->addProfessions($job, $normalizedField['professions']);
254 254
 		}
255 255
 		
256
-		if(isset($normalizedField['industries'])){
257
-			$this->addIndustries($job,$normalizedField['industries']);
256
+		if (isset($normalizedField['industries'])) {
257
+			$this->addIndustries($job, $normalizedField['industries']);
258 258
 		}
259
-		if(isset($normalizedField['employmentTypes'])){
259
+		if (isset($normalizedField['employmentTypes'])) {
260 260
 			$types = $this->getCategories([$normalizedField['employmentTypes']]);
261 261
 			$type = array_shift($types);
262 262
 			$values = $job->getClassifications()->getEmploymentTypes()->getValues();
263
-			if(!is_array($values) || !in_array($type,$values)){
263
+			if (!is_array($values) || !in_array($type, $values)) {
264 264
 				$job->getClassifications()->getEmploymentTypes()->getItems()->add($type);
265 265
 			}
266 266
 		}
@@ -279,18 +279,18 @@  discard block
 block discarded – undo
279 279
 		$location->fromString($serialized);
280 280
 		
281 281
 		$locations = $job->getLocations();
282
-		if(count($locations)){
282
+		if (count($locations)) {
283 283
 			$locations->clear();
284 284
 		}
285 285
 		$job->getLocations()->add($location);
286 286
 	}
287 287
 	
288
-	private function addProfessions(Job &$job,$terms)
288
+	private function addProfessions(Job &$job, $terms)
289 289
 	{
290 290
 		$professions = $this->getCategories($terms);
291
-		foreach($professions as $profession){
291
+		foreach ($professions as $profession) {
292 292
 			$values = $job->getClassifications()->getProfessions()->getValues();
293
-			if(!is_array($values) || !in_array($profession,$values)){
293
+			if (!is_array($values) || !in_array($profession, $values)) {
294 294
 				$job->getClassifications()->getProfessions()->getItems()->add($profession);
295 295
 			}
296 296
 		}
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 	private function addIndustries(Job &$job, $terms)
300 300
 	{
301 301
 		$industries = $this->getCategories($terms);
302
-		foreach($industries as $industry){
302
+		foreach ($industries as $industry) {
303 303
 			$values = $job->getClassifications()->getIndustries()->getValues();
304
-			if(!is_array($values) || !in_array($industry,$values)){
304
+			if (!is_array($values) || !in_array($industry, $values)) {
305 305
 				$job->getClassifications()->getIndustries()->getItems()->add($industry);
306 306
 			}
307 307
 		}
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		
337 337
 		$job = $repo->findDraft($user);
338 338
 		
339
-		if(is_null($job)){
339
+		if (is_null($job)) {
340 340
 			$job = new Job();
341 341
 			$job
342 342
 				->setUser($user)
Please login to merge, or discard this patch.
module/Behat/src/CoreContext.php 2 patches
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -23,284 +23,284 @@
 block discarded – undo
23 23
  */
24 24
 class CoreContext extends RawMinkContext
25 25
 {
26
-	static protected $application;
26
+    static protected $application;
27 27
 	
28
-	/**
29
-	 * @var MinkContext
30
-	 */
31
-	protected $minkContext;
28
+    /**
29
+     * @var MinkContext
30
+     */
31
+    protected $minkContext;
32 32
 	
33
-	static private $jobCategoryChecked = false;
33
+    static private $jobCategoryChecked = false;
34 34
 	
35
-	/**
36
-	 * @BeforeScenario
37
-	 * @param BeforeScenarioScope $scope
38
-	 */
39
-	public function gatherContexts(BeforeScenarioScope $scope)
40
-	{
41
-		$this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class);
42
-		if(false === static::$jobCategoryChecked){
43
-			/* @var Categories $catRepo */
44
-			$catRepo = $this->getRepositories()->get('Jobs/Category');
45
-			$all = $catRepo->findAll();
46
-			if(count($all) <= 1){
47
-				$catRepo->createDefaultCategory('professions');
48
-				$catRepo->createDefaultCategory('industries');
49
-				$catRepo->createDefaultCategory('employmentTypes');
50
-			}
51
-			static::$jobCategoryChecked = true;
52
-		}
53
-	}
35
+    /**
36
+     * @BeforeScenario
37
+     * @param BeforeScenarioScope $scope
38
+     */
39
+    public function gatherContexts(BeforeScenarioScope $scope)
40
+    {
41
+        $this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class);
42
+        if(false === static::$jobCategoryChecked){
43
+            /* @var Categories $catRepo */
44
+            $catRepo = $this->getRepositories()->get('Jobs/Category');
45
+            $all = $catRepo->findAll();
46
+            if(count($all) <= 1){
47
+                $catRepo->createDefaultCategory('professions');
48
+                $catRepo->createDefaultCategory('industries');
49
+                $catRepo->createDefaultCategory('employmentTypes');
50
+            }
51
+            static::$jobCategoryChecked = true;
52
+        }
53
+    }
54 54
 	
55
-	/**
56
-	 * @return Application
57
-	 */
58
-	public function getApplication()
59
-	{
60
-		if(!is_object(static::$application)){
61
-			$configFile = realpath(__DIR__.'/../../../config/config.php');
62
-			$config = include($configFile);
63
-			static::$application = Application::init($config);
64
-		}
65
-		return static::$application;
66
-	}
55
+    /**
56
+     * @return Application
57
+     */
58
+    public function getApplication()
59
+    {
60
+        if(!is_object(static::$application)){
61
+            $configFile = realpath(__DIR__.'/../../../config/config.php');
62
+            $config = include($configFile);
63
+            static::$application = Application::init($config);
64
+        }
65
+        return static::$application;
66
+    }
67 67
 	
68
-	/**
69
-	 * @return \Zend\ServiceManager\ServiceManager
70
-	 */
71
-	public function getServiceManager()
72
-	{
73
-		return $this->getApplication()->getServiceManager();
74
-	}
68
+    /**
69
+     * @return \Zend\ServiceManager\ServiceManager
70
+     */
71
+    public function getServiceManager()
72
+    {
73
+        return $this->getApplication()->getServiceManager();
74
+    }
75 75
 	
76
-	/**
77
-	 * @return \Zend\EventManager\EventManagerInterface
78
-	 */
79
-	public function getEventManager()
80
-	{
81
-		return $this->getApplication()->getEventManager();
82
-	}
76
+    /**
77
+     * @return \Zend\EventManager\EventManagerInterface
78
+     */
79
+    public function getEventManager()
80
+    {
81
+        return $this->getApplication()->getEventManager();
82
+    }
83 83
 	
84
-	/**
85
-	 * @return RepositoryService
86
-	 */
87
-	public function getRepositories()
88
-	{
89
-		return $this->getServiceManager()->get('repositories');
90
-	}
84
+    /**
85
+     * @return RepositoryService
86
+     */
87
+    public function getRepositories()
88
+    {
89
+        return $this->getServiceManager()->get('repositories');
90
+    }
91 91
 	
92
-	/**
93
-	 * @param $name
94
-	 * @param array $params
95
-	 *
96
-	 * @return string
97
-	 */
98
-	public function generateUrl($name)
99
-	{
100
-		return $this->minkContext->locatePath($name);
101
-	}
92
+    /**
93
+     * @param $name
94
+     * @param array $params
95
+     *
96
+     * @return string
97
+     */
98
+    public function generateUrl($name)
99
+    {
100
+        return $this->minkContext->locatePath($name);
101
+    }
102 102
 	
103
-	/**
104
-	 * @When /^I hover over the element "([^"]*)"$/
105
-	 */
106
-	public function iHoverOverTheElement($locator)
107
-	{
108
-		$session = $this->minkContext->getSession(); // get the mink session
109
-		$element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element
103
+    /**
104
+     * @When /^I hover over the element "([^"]*)"$/
105
+     */
106
+    public function iHoverOverTheElement($locator)
107
+    {
108
+        $session = $this->minkContext->getSession(); // get the mink session
109
+        $element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element
110 110
 		
111
-		// errors must not pass silently
112
-		if (null === $element) {
113
-			throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator));
114
-		}
111
+        // errors must not pass silently
112
+        if (null === $element) {
113
+            throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator));
114
+        }
115 115
 		
116
-		// ok, let's hover it
117
-		$element->mouseOver();
118
-	}
116
+        // ok, let's hover it
117
+        $element->mouseOver();
118
+    }
119 119
 	
120
-	/**
121
-	 * @Given /^I wait for (\d+) seconds$/
122
-	 */
123
-	public function iWaitForSecond($second)
124
-	{
125
-		sleep($second);
126
-	}
120
+    /**
121
+     * @Given /^I wait for (\d+) seconds$/
122
+     */
123
+    public function iWaitForSecond($second)
124
+    {
125
+        sleep($second);
126
+    }
127 127
 	
128
-	/**
129
-	 * @Then /^I wait for the ajax response$/
130
-	 */
131
-	public function iWaitForTheAjaxResponse()
132
-	{
133
-		$this->getSession()->wait(5000, '(0 === jQuery.active)');
134
-	}
128
+    /**
129
+     * @Then /^I wait for the ajax response$/
130
+     */
131
+    public function iWaitForTheAjaxResponse()
132
+    {
133
+        $this->getSession()->wait(5000, '(0 === jQuery.active)');
134
+    }
135 135
 	
136
-	/**
137
-	 * Some forms do not have a Submit button just pass the ID
138
-	 *
139
-	 * @Given /^I submit the form with id "([^"]*)"$/
140
-	 */
141
-	public function iSubmitTheFormWithId($arg)
142
-	{
143
-		$node = $this->minkContext->getSession()->getPage()->find('css', $arg);
144
-		if($node) {
145
-			$this->minkContext->getSession()->executeScript("jQuery('$arg').submit();");
146
-		} else {
147
-			throw new \Exception('Element not found');
148
-		}
149
-	}
136
+    /**
137
+     * Some forms do not have a Submit button just pass the ID
138
+     *
139
+     * @Given /^I submit the form with id "([^"]*)"$/
140
+     */
141
+    public function iSubmitTheFormWithId($arg)
142
+    {
143
+        $node = $this->minkContext->getSession()->getPage()->find('css', $arg);
144
+        if($node) {
145
+            $this->minkContext->getSession()->executeScript("jQuery('$arg').submit();");
146
+        } else {
147
+            throw new \Exception('Element not found');
148
+        }
149
+    }
150 150
 	
151
-	/**
152
-	 * @Then I switch to popup :name
153
-	 *
154
-	 * @param $name
155
-	 */
156
-	public function iSwitchToPopup($name)
157
-	{
158
-		$this->iSetMainWindowName();
159
-		$this->getSession()->switchToWindow($name);
160
-	}
151
+    /**
152
+     * @Then I switch to popup :name
153
+     *
154
+     * @param $name
155
+     */
156
+    public function iSwitchToPopup($name)
157
+    {
158
+        $this->iSetMainWindowName();
159
+        $this->getSession()->switchToWindow($name);
160
+    }
161 161
 	
162
-	/**
163
-	 * @Then I set main window name
164
-	 */
165
-	public function iSetMainWindowName()
166
-	{
167
-		$window_name = 'main_window';
168
-		$script = 'window.name = "' . $window_name . '"';
169
-		$this->getSession()->executeScript($script);
170
-	}
162
+    /**
163
+     * @Then I set main window name
164
+     */
165
+    public function iSetMainWindowName()
166
+    {
167
+        $window_name = 'main_window';
168
+        $script = 'window.name = "' . $window_name . '"';
169
+        $this->getSession()->executeScript($script);
170
+    }
171 171
 	
172
-	/**
173
-	 * @Then I switch back to main window
174
-	 */
175
-	public function iSwitchBackToMainWindow()
176
-	{
177
-		$this->getSession()->switchToWindow('main_window');
178
-	}
172
+    /**
173
+     * @Then I switch back to main window
174
+     */
175
+    public function iSwitchBackToMainWindow()
176
+    {
177
+        $this->getSession()->switchToWindow('main_window');
178
+    }
179 179
 	
180
-	public function iVisit($url)
181
-	{
182
-		$this->minkContext->getSession()->visit($url);
183
-	}
180
+    public function iVisit($url)
181
+    {
182
+        $this->minkContext->getSession()->visit($url);
183
+    }
184 184
 	
185
-	/**
186
-	 * @When I scroll :selector into view
187
-	 *
188
-	 * @param string $selector Allowed selectors: #id, .className, //xpath
189
-	 *
190
-	 * @throws \Exception
191
-	 */
192
-	public function scrollIntoView($selector)
193
-	{
194
-		$locator = substr($selector, 0, 1);
185
+    /**
186
+     * @When I scroll :selector into view
187
+     *
188
+     * @param string $selector Allowed selectors: #id, .className, //xpath
189
+     *
190
+     * @throws \Exception
191
+     */
192
+    public function scrollIntoView($selector)
193
+    {
194
+        $locator = substr($selector, 0, 1);
195 195
 		
196
-		switch ($locator) {
197
-			case '/' : // XPath selector
198
-				$function = <<<JS
196
+        switch ($locator) {
197
+            case '/' : // XPath selector
198
+                $function = <<<JS
199 199
 (function(){
200 200
   var elem = document.evaluate($selector, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
201 201
   elem.scrollIntoView(false);
202 202
 })()
203 203
 JS;
204
-				break;
204
+                break;
205 205
 			
206
-			case '#' : // ID selector
207
-				$selector = substr($selector, 1);
208
-				$function = <<<JS
206
+            case '#' : // ID selector
207
+                $selector = substr($selector, 1);
208
+                $function = <<<JS
209 209
 (function(){
210 210
   var elem = document.getElementById("$selector");
211 211
   elem.scrollIntoView(false);
212 212
 })()
213 213
 JS;
214
-				break;
214
+                break;
215 215
 			
216
-			case '.' : // Class selector
217
-				$selector = substr($selector, 1);
218
-				$function = <<<JS
216
+            case '.' : // Class selector
217
+                $selector = substr($selector, 1);
218
+                $function = <<<JS
219 219
 (function(){
220 220
   var elem = document.getElementsByClassName("$selector");
221 221
   elem[0].scrollIntoView(false);
222 222
 })()
223 223
 JS;
224
-				break;
224
+                break;
225 225
 			
226
-			default:
227
-				throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath');
228
-				break;
229
-		}
226
+            default:
227
+                throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath');
228
+                break;
229
+        }
230 230
 		
231
-		try {
232
-			$this->getSession()->executeScript($function);
233
-		} catch (\Exception $e) {
234
-			throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"');
235
-		}
236
-	}
231
+        try {
232
+            $this->getSession()->executeScript($function);
233
+        } catch (\Exception $e) {
234
+            throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"');
235
+        }
236
+    }
237 237
 	
238 238
 	
239
-	/**
240
-	 * @When I click location selector
241
-	 */
242
-	public function iClickLocationSelector()
243
-	{
244
-		$locator = '#jobBase-geoLocation-span .select2';
245
-		$element = $this->getElement($locator);
246
-		$element->click();
247
-	}
239
+    /**
240
+     * @When I click location selector
241
+     */
242
+    public function iClickLocationSelector()
243
+    {
244
+        $locator = '#jobBase-geoLocation-span .select2';
245
+        $element = $this->getElement($locator);
246
+        $element->click();
247
+    }
248 248
 	
249
-	/**
250
-	 * @param $locator
251
-	 * @param string $selector
252
-	 *
253
-	 * @return \Behat\Mink\Element\NodeElement|mixed|null
254
-	 */
255
-	public function getElement($locator,$selector='css')
256
-	{
257
-		$page = $this->minkContext->getSession()->getPage();
258
-		$element = $page->find('css',$locator);
259
-		return $element;
260
-	}
249
+    /**
250
+     * @param $locator
251
+     * @param string $selector
252
+     *
253
+     * @return \Behat\Mink\Element\NodeElement|mixed|null
254
+     */
255
+    public function getElement($locator,$selector='css')
256
+    {
257
+        $page = $this->minkContext->getSession()->getPage();
258
+        $element = $page->find('css',$locator);
259
+        return $element;
260
+    }
261 261
 	
262
-	/**
263
-	 * @When I fill in location search with :term
264
-	 * @param $term
265
-	 */
266
-	public function iFillInLocationSearch($term)
267
-	{
268
-		$locator = '.select2-container--open .select2-search__field';
269
-		$element = $this->getElement($locator);
270
-		$element->focus();
271
-		$element->setValue($term);
272
-		$this->iWaitForTheAjaxResponse();
273
-	}
262
+    /**
263
+     * @When I fill in location search with :term
264
+     * @param $term
265
+     */
266
+    public function iFillInLocationSearch($term)
267
+    {
268
+        $locator = '.select2-container--open .select2-search__field';
269
+        $element = $this->getElement($locator);
270
+        $element->focus();
271
+        $element->setValue($term);
272
+        $this->iWaitForTheAjaxResponse();
273
+    }
274 274
 	
275
-	public function iClickOn()
276
-	{
275
+    public function iClickOn()
276
+    {
277 277
 	
278
-	}
278
+    }
279 279
 	
280
-	/**
281
-	 * Click some text
282
-	 *
283
-	 * @When /^I click on the text "([^"]*)"$/
284
-	 */
285
-	public function iClickOnTheText($text)
286
-	{
287
-		$session = $this->getSession();
288
-		$element = $session->getPage()->find(
289
-			'xpath',
290
-			$session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]')
291
-		);
292
-		if(null === $element){
293
-			$element = $session->getPage()->find(
294
-				'named',
295
-				array('id',$text)
296
-			);
297
-		}
298
-		if (null === $element) {
299
-			throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));
300
-		}
280
+    /**
281
+     * Click some text
282
+     *
283
+     * @When /^I click on the text "([^"]*)"$/
284
+     */
285
+    public function iClickOnTheText($text)
286
+    {
287
+        $session = $this->getSession();
288
+        $element = $session->getPage()->find(
289
+            'xpath',
290
+            $session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]')
291
+        );
292
+        if(null === $element){
293
+            $element = $session->getPage()->find(
294
+                'named',
295
+                array('id',$text)
296
+            );
297
+        }
298
+        if (null === $element) {
299
+            throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));
300
+        }
301 301
 		
302
-		$element->click();
302
+        $element->click();
303 303
 		
304
-	}
304
+    }
305 305
 	
306 306
 }
307 307
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	public function gatherContexts(BeforeScenarioScope $scope)
40 40
 	{
41 41
 		$this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class);
42
-		if(false === static::$jobCategoryChecked){
42
+		if (false === static::$jobCategoryChecked) {
43 43
 			/* @var Categories $catRepo */
44 44
 			$catRepo = $this->getRepositories()->get('Jobs/Category');
45 45
 			$all = $catRepo->findAll();
46
-			if(count($all) <= 1){
46
+			if (count($all) <= 1) {
47 47
 				$catRepo->createDefaultCategory('professions');
48 48
 				$catRepo->createDefaultCategory('industries');
49 49
 				$catRepo->createDefaultCategory('employmentTypes');
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function getApplication()
59 59
 	{
60
-		if(!is_object(static::$application)){
60
+		if (!is_object(static::$application)) {
61 61
 			$configFile = realpath(__DIR__.'/../../../config/config.php');
62 62
 			$config = include($configFile);
63 63
 			static::$application = Application::init($config);
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	public function iSubmitTheFormWithId($arg)
142 142
 	{
143 143
 		$node = $this->minkContext->getSession()->getPage()->find('css', $arg);
144
-		if($node) {
144
+		if ($node) {
145 145
 			$this->minkContext->getSession()->executeScript("jQuery('$arg').submit();");
146 146
 		} else {
147 147
 			throw new \Exception('Element not found');
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	public function iSetMainWindowName()
166 166
 	{
167 167
 		$window_name = 'main_window';
168
-		$script = 'window.name = "' . $window_name . '"';
168
+		$script = 'window.name = "'.$window_name.'"';
169 169
 		$this->getSession()->executeScript($script);
170 170
 	}
171 171
 	
@@ -224,14 +224,14 @@  discard block
 block discarded – undo
224 224
 				break;
225 225
 			
226 226
 			default:
227
-				throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath');
227
+				throw new \Exception(__METHOD__.' Couldn\'t find selector: '.$selector.' - Allowed selectors: #id, .className, //xpath');
228 228
 				break;
229 229
 		}
230 230
 		
231 231
 		try {
232 232
 			$this->getSession()->executeScript($function);
233 233
 		} catch (\Exception $e) {
234
-			throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"');
234
+			throw new \Exception(__METHOD__.' failed'.' Message: for this locator:"'.$selector.'"');
235 235
 		}
236 236
 	}
237 237
 	
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
 	 *
253 253
 	 * @return \Behat\Mink\Element\NodeElement|mixed|null
254 254
 	 */
255
-	public function getElement($locator,$selector='css')
255
+	public function getElement($locator, $selector = 'css')
256 256
 	{
257 257
 		$page = $this->minkContext->getSession()->getPage();
258
-		$element = $page->find('css',$locator);
258
+		$element = $page->find('css', $locator);
259 259
 		return $element;
260 260
 	}
261 261
 	
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
 		$session = $this->getSession();
288 288
 		$element = $session->getPage()->find(
289 289
 			'xpath',
290
-			$session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]')
290
+			$session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'.$text.'"]')
291 291
 		);
292
-		if(null === $element){
292
+		if (null === $element) {
293 293
 			$element = $session->getPage()->find(
294 294
 				'named',
295
-				array('id',$text)
295
+				array('id', $text)
296 296
 			);
297 297
 		}
298 298
 		if (null === $element) {
Please login to merge, or discard this patch.