Completed
Push — master ( 81c6e7...6c71bd )
by Piotr
02:30
created

ResourceContext   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 5
dl 0
loc 51
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace FSi\Bundle\AdminBundle\Behat\Context;
11
12
use Behat\Gherkin\Node\TableNode;
13
use Behat\Symfony2Extension\Context\KernelAwareContext;
14
use SensioLabs\Behat\PageObjectExtension\Context\PageObjectContext;
15
use Symfony\Component\HttpKernel\KernelInterface;
16
17
class ResourceContext extends PageObjectContext implements KernelAwareContext
18
{
19
    /**
20
     * @var KernelInterface
21
     */
22
    protected $kernel;
23
24
    /**
25
     * @param KernelInterface $kernel
26
     */
27
    public function setKernel(KernelInterface $kernel)
28
    {
29
        $this->kernel = $kernel;
30
    }
31
32
    /**
33
     * @Given /^there are following resources added to resource map$/
34
     */
35
    public function thereAreFollowingResourcesAddedToResourceMap(TableNode $resources)
36
    {
37
        foreach ($resources->getHash() as $resource) {
38
            expect($this->kernel->getContainer()
39
                ->get('fsi_resource_repository.map_builder')
40
                ->hasResource($resource['Key']))->toBe(true);
41
42
            if (isset($resource['Type'])) {
43
                expect($this->kernel->getContainer()
44
                    ->get('fsi_resource_repository.map_builder')
45
                    ->getResource($resource['Key']))->toBeAnInstanceOf(
46
                        sprintf('FSi\Bundle\ResourceRepositoryBundle\Repository\Resource\Type\%sType', ucfirst($resource['Type']))
47
                    );
48
            }
49
        }
50
    }
51
52
    /**
53
     * @Given /^I fill form "Content" field with "([^"]*)"$/
54
     */
55
    public function iFillFormFieldWith($value)
56
    {
57
        $this->getElement('Form')->fillField('Content', $value);
58
    }
59
60
    /**
61
     * @Given /^I should see form "Content" field with value "([^"]*)"$/
62
     */
63
    public function iShouldSeeFormFieldWithValue($value)
64
    {
65
        expect($this->getElement('Form')->findField('Content')->getValue())->toBe($value);
66
    }
67
}
68