|
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', '/'); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.