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.

EsprimaTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 101
c 0
b 0
f 0
wmc 6
lcom 1
cbo 3
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testInvalidArgumentExceptionIsThrownIfFilePathIsNotLocalFile() 0 9 1
A testInvalidArgumentIsThrownIfFileDoesNotExist() 0 9 1
A testEngineCanBeLoaded() 0 7 1
A testEngineCanBeCovertedToString() 0 7 1
A getEsprima() 0 6 1
A getFileLocator() 0 8 1
1
<?php
2
3
/*
4
 * This file is part of the php-phantomjs.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
namespace JonnyW\PhantomJs\Tests\Unit\Validator;
10
11
use Symfony\Component\Config\FileLocator;
12
use JonnyW\PhantomJs\Validator\Esprima;
13
14
/**
15
 * PHP PhantomJs
16
 *
17
 * @author Jon Wenmoth <[email protected]>
18
 */
19
class EsprimaTest extends \PHPUnit_Framework_TestCase
20
{
21
22
/** +++++++++++++++++++++++++++++++++++ **/
23
/** ++++++++++++++ TESTS ++++++++++++++ **/
24
/** +++++++++++++++++++++++++++++++++++ **/
25
26
    /**
27
     * Test invalid argument exception is thrown
28
     * if file path is not local file.
29
     *
30
     * @access public
31
     * @return void
32
     */
33
    public function testInvalidArgumentExceptionIsThrownIfFilePathIsNotLocalFile()
34
    {
35
        $this->setExpectedException('\InvalidArgumentException');
36
37
        $fileLocator = $this->getFileLocator();
38
        $esprima     = $this->getEsprima($fileLocator, 'http://example.com');
39
40
        $esprima->load();
41
    }
42
43
    /**
44
     * Test invalid argument exception is thrown if
45
     * file does not exist.
46
     *
47
     * @access public
48
     * @return void
49
     */
50
    public function testInvalidArgumentIsThrownIfFileDoesNotExist()
51
    {
52
        $this->setExpectedException('\InvalidArgumentException');
53
54
        $fileLocator = $this->getFileLocator();
55
        $esprima     = $this->getEsprima($fileLocator, 'invalidFile.js');
56
57
        $esprima->load();
58
    }
59
60
    /**
61
     * Test engine can be loaded.
62
     *
63
     * @access public
64
     * @return void
65
     */
66
    public function testEngineCanBeLoaded()
67
    {
68
        $fileLocator = $this->getFileLocator();
69
        $esprima     = $this->getEsprima($fileLocator, 'esprima-2.0.0.js');
70
71
        $this->assertContains('esprima', $esprima->load());
72
    }
73
74
    /**
75
     * Test engine can be converted to string.
76
     *
77
     * @access public
78
     * @return void
79
     */
80
    public function testEngineCanBeCovertedToString()
81
    {
82
       $fileLocator = $this->getFileLocator();
83
        $esprima     = $this->getEsprima($fileLocator, 'esprima-2.0.0.js');
84
85
        $this->assertContains('esprima', (string) $esprima);
86
    }
87
88
/** +++++++++++++++++++++++++++++++++++ **/
89
/** ++++++++++ TEST ENTITIES ++++++++++ **/
90
/** +++++++++++++++++++++++++++++++++++ **/
91
92
    /**
93
     * Get esprima.
94
     *
95
     * @access protected
96
     * @return \JonnyW\PhantomJs\Validator\Esprima
97
     */
98
    protected function getEsprima(FileLocator $fileLocator, $file)
99
    {
100
        $esprima = new Esprima($fileLocator, $file);
101
102
        return $esprima;
103
    }
104
105
    /**
106
     * Get file locator.
107
     *
108
     * @access protected
109
     * @return \Symfony\Component\Config\FileLocator
110
     */
111
    protected function getFileLocator()
112
    {
113
        $fileLocator = new FileLocator(
114
            sprintf('%s/../../../Resources/validators/', __DIR__)
115
        );
116
117
        return $fileLocator;
118
    }
119
}
120