GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FeatureContext::iniializeContainer()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
namespace Codeliner\CargoFeature;
3
4
use Behat\Behat\Context\ClosuredContextInterface,
5
    Behat\Behat\Context\TranslatedContextInterface,
6
    Behat\Behat\Context\BehatContext,
7
    Behat\Behat\Exception\PendingException;
8
use Behat\Gherkin\Node\PyStringNode,
9
    Behat\Gherkin\Node\TableNode;
10
use Behat\MinkExtension\Context\MinkContext;
11
use Zend\Mvc\Application;
12
use Zend\ServiceManager\ServiceManager;
13
14
//
15
// Require 3rd-party libraries here:
16
//
17
//   require_once 'PHPUnit/Autoload.php';
18
//   require_once 'PHPUnit/Framework/Assert/Functions.php';
19
//
20
21
/**
22
 * Features context.
23
 */
24
class FeatureContext extends MinkContext
25
{
26
    /**
27
     * @var \Interop\Container\ContainerInterface
28
     */
29
    private static $container;
30
    
31
    /**
32
     * Initializes context.
33
     * Every scenario gets it's own context object.
34
     *
35
     * @param array $parameters context parameters (set them up through behat.yml)
0 ignored issues
show
Bug introduced by
There is no parameter named $parameters. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
36
     */
37
    public function __construct()
38
    {
39
        // Initialize your context here
40
    }
41
42
    /**
43
     * @BeforeSuite
44
     */
45
    static public function iniializeContainer()
46
    {
47
        if (self::$container === null) {
48
            self::$container = require __DIR__ . '/../../config/container.php';
49
        }
50
    }
51
    
52
    /**
53
     * @BeforeFeature
54
     */
55
    public static function clearDatabase()
56
    {
57
        $em = self::$container->get('doctrine.entitymanager.orm_default');
58
        $q = $em->createQuery('delete from Codeliner\CargoBackend\Model\Cargo\Cargo');
59
        $q->execute();
60
    }
61
    
62
    /**
63
     * @Given /^I click the submit button$/
64
     */
65
    public function iClickTheSubmitButton()
66
    {
67
        $session = $this->getSession();
68
        $page = $session->getPage();
69
        
70
        $submit = $page->find('css', 'form input[type=submit]');
71
        
72
        if ($submit) {
73
            $submit->click();
74
        } else {
75
            throw new \RuntimeException("Can not find the submit btn");
76
        }
77
    }
78
79
    /**
80
     * @Then /^I should wait until I see "([^"]*)"$/
81
     */
82
    public function iShouldSeeAvailableRoutes($arg1)
83
    {
84
        $this->getSession()->wait(5000, '(0 === jQuery.active)');
85
86
        $this->assertElementOnPage($arg1);
87
    }
88
    
89
    /**
90
     * @When /^I click on first item in the list "([^"]*)"$/
91
     */
92
    public function iClickOnFirstItemInTheList($arg1)
0 ignored issues
show
Unused Code introduced by
The parameter $arg1 is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
93
    {
94
        $session = $this->getSession();
95
        $page = $session->getPage();
96
        
97
        $ul = $page->find('css', '#cargo-list');
98
        
99
        $li = $ul->find('css', 'li');
100
        
101
        $li->find('css', 'a')->click();
102
    }
103
104
    /**
105
     * @When /^I follow first "([^"]*)" link$/
106
     */
107
    public function iFollowFirstLink($arg1)
108
    {
109
        $page = $this->getSession()->getPage();
110
111
        $link = $page->find('css', $arg1);
112
113
        if ($link) {
114
            $link->click();
115
        }
116
    }
117
    
118
    /**
119
     * @Given /^I wait until I am on page "(?P<page>[^"]+)"$/
120
     */
121
    public function iWaitUntilIAmOnPage($page)
122
    {
123
        $matchingFound = false;
124
        
125
        for($i=1;$i++;$i<=5) {
126
            if (strpos($this->getSession()->getCurrentUrl(), $this->locatePath($page)) !== false) {
127
                $matchingFound = true;
128
                break;
129
            }
130
            sleep(1);
131
        }
132
        
133
        if (!$matchingFound) {
134
            throw new \Exception('Stoped waiting, timelimit reached!');
135
        }
136
    }
137
138
}
139