Completed
Push — master ( 3c5828...866487 )
by Dorian
02:10
created

BooksListTest::testCategoriesList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 5
rs 9.4285
c 2
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Tests\Functional;
4
5
use Gnutix\Kernel\Tests\Functional\WebTestCase;
6
7
/**
8
 * Books List Tests
9
 *
10
 * @group functional
11
 */
12
class BooksListTest extends WebTestCase
13
{
14
    /** @var \Symfony\Component\DomCrawler\Crawler */
15
    protected $crawler;
16
17
    /**
18
     * Set up the test client
19
     */
20
    public function setUp()
21
    {
22
        $this->crawler = $this->client->request('GET', '/');
23
    }
24
25
    /**
26
     * Test the page status code
27
     */
28
    public function testPageStatusCode()
29
    {
30
        $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
31
    }
32
33
    /**
34
     * Tests the page title and description
35
     */
36
    public function testPageHeader()
37
    {
38
        $this->assertContains('Star Wars', $this->crawler->filter('h1')->text());
39
        $this->assertContains('list of Star Wars books', $this->crawler->filter('p')->text());
40
    }
41
42
    /**
43
     * Tests the editors list
44
     */
45
    public function testEditorsList()
46
    {
47
        $this->assertCount(3, $this->crawler->filter('#collapseEditors tbody tr'));
48
49
        $this->assertEquals(
50
            'EN',
51
            $this->crawler->filter('#collapseEditors tbody tr')->first()->filter('img')->attr('alt')
52
        );
53
        $this->assertContains(
54
            'English Publisher',
55
            $this->crawler->filter('#collapseEditors tbody tr')->first()->filter('td')->last()->text()
56
        );
57
58
        $this->assertEquals(
59
            'FR',
60
            $this->crawler->filter('#collapseEditors tbody tr')->eq(1)->filter('img')->attr('alt')
61
        );
62
        $this->assertContains(
63
            'French Publisher',
64
            $this->crawler->filter('#collapseEditors tbody tr')->eq(1)->filter('td')->last()->text()
65
        );
66
    }
67
68
    /**
69
     * Tests the categories list
70
     */
71
    public function testCategoriesList()
72
    {
73
        $this->assertCount(2, $this->crawler->filter('#collapseTypes li'));
74
        $this->assertContains('Novel', $this->crawler->filter('#collapseTypes li')->first()->text());
75
    }
76
77
    /**
78
     * Tests the eras list
79
     */
80
    public function testErasList()
81
    {
82
        $this->assertCount(3, $this->crawler->filter('#collapseEras ul li'));
83
        $this->assertContains('Old Republic', $this->crawler->filter('#collapseEras a[href="#oldRepublic"]')->text());
84
    }
85
86
    /**
87
     * Tests the book table
88
     *
89
     * @todo Complete this test...
90
     */
91
    public function testBooksTable()
92
    {
93
        $this->assertCount(1, $this->crawler->filter('table[data-books-list]'));
94
        $this->assertGreaterThan(1, $this->crawler->filter('table[data-books-list] thead')->count());
95
        $this->assertGreaterThan(1, $this->crawler->filter('table[data-books-list] tbody')->count());
96
        $this->assertGreaterThan(1, $this->crawler->filter('table[data-books-list] tbody td')->count());
97
    }
98
}
99