Passed
Push — develop ( 28c299...928e2a )
by Mathias
12:40
created

ApplicationContext   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 36
rs 10
c 0
b 0
f 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 = $this->buildUrl('lang/apply',[
45
		    'applyId' => $job->getApplyId()
46
        ]);
47
		$this->visit($url);
48
	}
49
	
50
	/**
51
	 * @Given I visit job categories
52
	 */
53
	public function visitJobsCategories()
54
	{
55
		$url = '/admin/jobs/categories';
56
		$this->visit($url);
57
	}
58
}
59