Completed
Push — develop ( 321e68...dce9ea )
by Carsten
09:20
created

ApplicationContext::visitJobsCategories()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2017 Cross Solution <http://cross-solution.de>
8
 */
9
10
namespace Yawik\Behat;
11
12
use Behat\Behat\Context\Context;
13
use Jobs\Entity\Job;
14
use Jobs\Repository\Job as JobRepository;
15
16
/**
17
 * Class ApplicationContext
18
 *
19
 * @package Yawik\Behat
20
 *
21
 * @author Anthonius Munthi <[email protected]>
22
 */
23
class ApplicationContext implements Context
24
{
25
	use CommonContextTrait;
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);
43
		
44
		$url = '/en/apply/'.$job->getApplyId();
45
		$this->visit($url);
46
	}
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
	}
56
}