Completed
Push — master ( a275c7...1793be )
by Laurent
25:09
created

InventoryControllerTest::testIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace AppBundle\Tests\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
7
class InventoryControllerTest extends WebTestCase
8
{
9
    public function testIndex() {
10
        $client = self::createClient(
11
//            array(),
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
12
//            array(
13
//               'HTTP_HOST' => 'symfony2.local',
14
//            )
15
        );
16
17
        $crawler = $client->request('GET', '/inventory/');
18
        $this->assertEquals(1, $crawler->filter('.container .row #content h2:contains("Inventaires - Liste")')->count());
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 121 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
19
20
//        $this->assertContains('Inventaires - Liste', $crawler->filter('.container .row #content h2')->text());
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
21
    }
22
23 View Code Duplication
    public function testCreate()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    {
25
        $client = static::createClient();
26
        $crawler = $client->request('GET', '/inventory/');
27
        $this->assertCount(8, $crawler->filter('table.records_list tbody tr'));
28
        $crawler = $client->click($crawler->filter('.new_entry a')->link());
29
        $form = $crawler->filter('form button[type="submit"]')->form(array(
30
            'inventory[date]' => new \DateTime(),
31
            'inventory[active]' => true,
32
            'inventory[amount]' => 10.99,
33
            'inventory[file]' => 'Lorem ipsum dolor sit amet',
34
                    ));
35
        $client->submit($form);
36
        $crawler = $client->followRedirect();
37
        $crawler = $client->click($crawler->filter('.record_actions a')->link());
38
        $this->assertCount(9, $crawler->filter('table.records_list tbody tr'));
39
    }
40
41
//    public function testCreateError()
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
42
//    {
43
//        $client = static::createClient();
44
//        $crawler = $client->request('GET', '/inventory/new');
45
//        $form = $crawler->filter('form button[type="submit"]')->form();
46
//        $crawler = $client->submit($form);
47
//        $this->assertGreaterThan(0, $crawler->filter('form div.has-error')->count());
48
//        $this->assertTrue($client->getResponse()->isSuccessful());
49
//    }
50
//
51
//    /**
52
//     * @depends testCreate
53
//     */
54
//    public function testEdit()
55
//    {
56
//        $client = static::createClient();
57
//        $crawler = $client->request('GET', '/inventory/');
58
//        $this->assertCount(1, $crawler->filter('table.records_list tbody tr:contains("First value")'));
59
//        $this->assertCount(0, $crawler->filter('table.records_list tbody tr:contains("Changed")'));
60
//        $crawler = $client->click($crawler->filter('table.records_list tbody tr td .btn-group a')->eq(1)->link());
61
//        $form = $crawler->filter('form button[type="submit"]')->form(array(
62
//            'inventory[date]' => new \DateTime(),
63
//            'inventory[active]' => true,
64
//            'inventory[amount]' => 10.99,
65
//            'inventory[file]' => 'Changed',
66
//            // ... adapt fields value here ...
67
//        ));
68
//        $client->submit($form);
69
//        $crawler = $client->followRedirect();
70
//        $crawler = $client->click($crawler->filter('.record_actions a')->link());
71
//        $this->assertCount(0, $crawler->filter('table.records_list tbody tr:contains("First value")'));
72
//        $this->assertCount(1, $crawler->filter('table.records_list tbody tr:contains("Changed")'));
73
//    }
74
//
75
//    /**
76
//     * @depends testCreate
77
//     */
78
//    public function testEditError()
79
//    {
80
//        $client = static::createClient();
81
//        $crawler = $client->request('GET', '/inventory/');
82
//        $crawler = $client->click($crawler->filter('table.records_list tbody tr td .btn-group a')->eq(1)->link());
83
//        $form = $crawler->filter('form button[type="submit"]')->form(array(
84
//            'inventory[field_name]' => '',
85
//            // ... use a required field here ...
86
//        ));
87
//        $crawler = $client->submit($form);
88
//        $this->assertGreaterThan(0, $crawler->filter('form div.has-error')->count());
89
//    }
90
//
91
//    /**
92
//     * @depends testCreate
93
//     */
94
//    public function testDelete()
95
//    {
96
//        $client = static::createClient();
97
//        $crawler = $client->request('GET', '/inventory/');
98
//        $this->assertTrue($client->getResponse()->isSuccessful());
99
//        $this->assertCount(1, $crawler->filter('table.records_list tbody tr'));
100
//        $crawler = $client->click($crawler->filter('table.records_list tbody tr td .btn-group a')->eq(0)->link());
101
//        $client->submit($crawler->filter('form#delete button[type="submit"]')->form());
102
//        $crawler = $client->followRedirect();
103
//        $this->assertCount(0, $crawler->filter('table.records_list tbody tr'));
104
//    }
105
}
106