Completed
Pull Request — develop (#455)
by ANTHONIUS
24:00
created
module/Behat/src/JobContext.php 1 patch
Spacing   +44 added lines, -44 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
 		}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function iGoToCreateJob()
91 91
 	{
92
-	    $url = $this->generateUrl('lang/jobs/manage',['action' => 'edit']);
92
+	    $url = $this->generateUrl('lang/jobs/manage', ['action' => 'edit']);
93 93
 		$this->visit($url);
94 94
 	}
95 95
 	
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 	public function iGoToEditJobWithTitle($jobTitle)
110 110
 	{
111 111
 		$job = $this->getJobRepository()->findOneBy(['title' => $jobTitle]);
112
-		if(!$job instanceof Job){
113
-			throw new \Exception(sprintf('Job with title "%s" is not found',$jobTitle));
112
+		if (!$job instanceof Job) {
113
+			throw new \Exception(sprintf('Job with title "%s" is not found', $jobTitle));
114 114
 		}
115 115
 		$this->currentJob = $job;
116
-		$url = $this->generateUrl('lang/jobs/manage',[
116
+		$url = $this->generateUrl('lang/jobs/manage', [
117 117
 		    'id' => $job->getId()
118 118
         ]);
119 119
 		$this->visit($url);
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 
140 140
 		$jobRepository = $this->getJobRepository();
141 141
 		$results = $jobRepository->getUserJobs($user->getId());
142
-		foreach($results as $job){
143
-			$jobRepository->remove($job,true);
142
+		foreach ($results as $job) {
143
+			$jobRepository->remove($job, true);
144 144
 		}
145 145
 		$this->currentJob = null;
146 146
 	}
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
 	 * @When I fill job location search with :search and choose :choice
150 150
 	 *
151 151
 	 */
152
-	public function iFillJobLocationAndChoose($search,$choice)
152
+	public function iFillJobLocationAndChoose($search, $choice)
153 153
 	{
154 154
 		$select2 = $this->select2Context;
155
-		$select2->iFillInSelect2FieldWith('jobBase[geoLocation]',$search,$choice);
155
+		$select2->iFillInSelect2FieldWith('jobBase[geoLocation]', $search, $choice);
156 156
 	}
157 157
 	
158 158
 	/**
159 159
 	 * @When I choose :value from :field
160 160
 	 */
161
-	public function iJobClassificationSelect($value,$field)
161
+	public function iJobClassificationSelect($value, $field)
162 162
 	{
163 163
 		$field = Inflector::camelize($field);
164 164
 		
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
 			'employmentTypes'    => "select#classifications-employmentTypes",
175 175
 		];
176 176
 		
177
-		if(!isset($mapSelect2[$field])){
177
+		if (!isset($mapSelect2[$field])) {
178 178
 			throw new \Exception('Undefined field selection value "'.$field.'"');
179 179
 		}
180 180
 		
181 181
 		$multipleField = $mapMultiple[$field];
182 182
 		$page = $this->minkContext->getSession()->getPage();
183
-		$element = $page->find('css',$mapMultiple[$field]);
184
-		if(!is_null($element) && $element->getAttribute('multiple')=='multiple'){
185
-			$this->minkContext->selectOption($value,$multipleField);
186
-		}else{
183
+		$element = $page->find('css', $mapMultiple[$field]);
184
+		if (!is_null($element) && $element->getAttribute('multiple') == 'multiple') {
185
+			$this->minkContext->selectOption($value, $multipleField);
186
+		} else {
187 187
 			$locator = $mapSelect2[$field];
188
-			$this->select2Context->iFillInSelect2Field($locator,$value);
188
+			$this->select2Context->iFillInSelect2Field($locator, $value);
189 189
 		}
190 190
 	}
191 191
 	
@@ -209,62 +209,62 @@  discard block
 block discarded – undo
209 209
 	 * @When I have a :status job with the following:
210 210
 	 * @param TableNode $fields
211 211
 	 */
212
-	public function iHaveAJobWithTheFollowing($status,TableNode $fields)
212
+	public function iHaveAJobWithTheFollowing($status, TableNode $fields)
213 213
 	{
214 214
 		$normalizedField = [
215 215
 			'template' => 'modern',
216 216
 		];
217
-		foreach($fields->getRowsHash() as $field => $value){
217
+		foreach ($fields->getRowsHash() as $field => $value) {
218 218
 			$field = Inflector::camelize($field);
219
-			if($field == 'professions' || $field == 'industries'){
220
-				$value = explode(',',$value);
219
+			if ($field == 'professions' || $field == 'industries') {
220
+				$value = explode(',', $value);
221 221
 			}
222 222
 			$normalizedField[$field] = $value;
223 223
 		}
224 224
 		$jobRepo = $this->getJobRepository();
225 225
 		$job = $jobRepo->findOneBy(['title' => $normalizedField['title']]);
226
-		if(!$job instanceof Job){
226
+		if (!$job instanceof Job) {
227 227
 			$job = new Job();
228 228
 			$job->setTitle($normalizedField['title']);
229 229
 		}
230
-		if(isset($normalizedField['user'])){
230
+		if (isset($normalizedField['user'])) {
231 231
 			/* @var $userRepo UserRepository */
232 232
 			$userRepo = $this->getRepository('Auth\Entity\User');
233 233
 			$user = $userRepo->findOneBy(['login' => $normalizedField['user']]);
234
-			if($user instanceof User){
234
+			if ($user instanceof User) {
235 235
 				$job->setUser($user);
236 236
 				$job->setOrganization($user->getOrganization()->getOrganization());
237
-			}else{
237
+			} else {
238 238
 				throw new \Exception('There is no user with this login:"'.$normalizedField['user'.'"']);
239 239
 			}
240 240
 		}
241 241
 		
242
-		if($status == 'draft'){
242
+		if ($status == 'draft') {
243 243
 			$job->setIsDraft(true);
244
-		}elseif($status == 'published'){
244
+		}elseif ($status == 'published') {
245 245
 			$job->setIsDraft(false);
246 246
 			$job->setDatePublishStart(new \DateTime());
247 247
 		}
248 248
 		$job->setStatus(Status::ACTIVE);
249 249
 		
250
-		if(isset($normalizedField['location'])){
251
-			$this->setLocation($job,$normalizedField['location']);
250
+		if (isset($normalizedField['location'])) {
251
+			$this->setLocation($job, $normalizedField['location']);
252 252
 		}
253
-		if(isset($normalizedField['companyName'])){
253
+		if (isset($normalizedField['companyName'])) {
254 254
 			//$job->setCompany($normalizedField['companyName']);
255 255
 		}
256
-		if(isset($normalizedField['professions'])){
257
-			$this->addProfessions($job,$normalizedField['professions']);
256
+		if (isset($normalizedField['professions'])) {
257
+			$this->addProfessions($job, $normalizedField['professions']);
258 258
 		}
259 259
 		
260
-		if(isset($normalizedField['industries'])){
261
-			$this->addIndustries($job,$normalizedField['industries']);
260
+		if (isset($normalizedField['industries'])) {
261
+			$this->addIndustries($job, $normalizedField['industries']);
262 262
 		}
263
-		if(isset($normalizedField['employmentTypes'])){
263
+		if (isset($normalizedField['employmentTypes'])) {
264 264
 			$types = $this->getCategories([$normalizedField['employmentTypes']]);
265 265
 			$type = array_shift($types);
266 266
 			$values = $job->getClassifications()->getEmploymentTypes()->getValues();
267
-			if(!is_array($values) || !in_array($type,$values)){
267
+			if (!is_array($values) || !in_array($type, $values)) {
268 268
 				$job->getClassifications()->getEmploymentTypes()->getItems()->add($type);
269 269
 			}
270 270
 		}
@@ -283,18 +283,18 @@  discard block
 block discarded – undo
283 283
 		$location->fromString($serialized);
284 284
 		
285 285
 		$locations = $job->getLocations();
286
-		if(count($locations)){
286
+		if (count($locations)) {
287 287
 			$locations->clear();
288 288
 		}
289 289
 		$job->getLocations()->add($location);
290 290
 	}
291 291
 	
292
-	private function addProfessions(Job &$job,$terms)
292
+	private function addProfessions(Job &$job, $terms)
293 293
 	{
294 294
 		$professions = $this->getCategories($terms);
295
-		foreach($professions as $profession){
295
+		foreach ($professions as $profession) {
296 296
 			$values = $job->getClassifications()->getProfessions()->getValues();
297
-			if(!is_array($values) || !in_array($profession,$values)){
297
+			if (!is_array($values) || !in_array($profession, $values)) {
298 298
 				$job->getClassifications()->getProfessions()->getItems()->add($profession);
299 299
 			}
300 300
 		}
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 	private function addIndustries(Job &$job, $terms)
304 304
 	{
305 305
 		$industries = $this->getCategories($terms);
306
-		foreach($industries as $industry){
306
+		foreach ($industries as $industry) {
307 307
 			$values = $job->getClassifications()->getIndustries()->getValues();
308
-			if(!is_array($values) || !in_array($industry,$values)){
308
+			if (!is_array($values) || !in_array($industry, $values)) {
309 309
 				$job->getClassifications()->getIndustries()->getItems()->add($industry);
310 310
 			}
311 311
 		}
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 		
341 341
 		$job = $repo->findDraft($user);
342 342
 		
343
-		if(is_null($job)){
343
+		if (is_null($job)) {
344 344
 			$job = new Job();
345 345
 			$job
346 346
 				->setUser($user)
Please login to merge, or discard this patch.