IndexFileTest::getFixtureClasses()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Tests\Acceptance;
4
5
use App\DataFixtures\UserReferenceTrait;
6
use App\DataFixtures\Users;
7
8
class IndexFileTest extends BaseAcceptanceTest
9
{
10
    use UserReferenceTrait;
11
12
    /**
13
     * {@inheritdoc}
14
     */
15
    protected function getFixtureClasses()
16
    {
17
        return [Users::class];
18
    }
19
20
    public function testIndexFileShown()
21
    {
22
        $referenceRepository = $this->loadClientAndFixtures([Users::class]);
23
24
        $this->login($this->getUser(Users::COMMITTER, $referenceRepository));
25
26
        $crawler = $this->client->request('GET', '/');
0 ignored issues
show
Unused Code introduced by
$crawler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
27
//        $this->assertStatusCode(302, $client);
28
        $this->assertEquals(302, $this->client->getResponse()->getStatusCode());
29
30
        $location = $this->client->getResponse()->headers->get('Location');
31
        $this->assertEquals('/browse/?action=index', $location);
32
        $crawler = $this->client->request('GET', $location);
0 ignored issues
show
Unused Code introduced by
$crawler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
Bug introduced by
It seems like $location defined by $this->client->getRespon...eaders->get('Location') on line 30 can also be of type array or null; however, Symfony\Component\BrowserKit\Client::request() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
33
//        $this->assertStatusCode(302, $client);
34
35
        $this->assertEquals(302, $this->client->getResponse()->getStatusCode());
36
        $location = $this->client->getResponse()->headers->get('Location');
37
        $this->assertEquals('/browse/index.md', $location);
38
        $crawler = $this->client->request('GET', $location);
0 ignored issues
show
Bug introduced by
It seems like $location defined by $this->client->getRespon...eaders->get('Location') on line 36 can also be of type array or null; however, Symfony\Component\BrowserKit\Client::request() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
39
//        $this->assertStatusCode(200, $client);
40
41
        $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
42
        $this->assertEquals('Welcome', $crawler->filter('h1')->text());
43
    }
44
}
45