BooksListTest::testCategoriesList()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tests\Functional\Application;
6
7
use Symfony\Component\DomCrawler\Crawler;
8
use Tests\Functional\WebTestCase;
9
10
final class BooksListTest extends WebTestCase
11
{
12
    protected Crawler $crawler;
13
14
    protected function setUp(): void
15
    {
16
        parent::setUp();
17
18
        $this->crawler = $this->httpKernelBrowser->request('GET', '/');
19
    }
20
21
    public function testPageStatusCode(): void
22
    {
23
        $this->assertSame(200, $this->httpKernelBrowser->getResponse()->getStatusCode());
24
    }
25
26
    public function testPageHeader(): void
27
    {
28
        $this->assertStringContainsString('Star Wars', $this->crawler->filter('h1')->text());
29
        $this->assertStringContainsString('list of Star Wars books', $this->crawler->filter('p')->text());
30
    }
31
32
    public function testEditorsList(): void
33
    {
34
        $this->assertCount(3, $this->crawler->filter('#collapseEditors tbody tr'));
35
36
        $this->assertSame(
37
            'EN',
38
            $this->crawler->filter('#collapseEditors tbody tr')->first()->filter('img')->attr('alt')
39
        );
40
        $this->assertStringContainsString(
41
            'English Publisher',
42
            $this->crawler->filter('#collapseEditors tbody tr')->first()->filter('td')->last()->text()
43
        );
44
45
        $this->assertSame(
46
            'FR',
47
            $this->crawler->filter('#collapseEditors tbody tr')->eq(1)->filter('img')->attr('alt')
48
        );
49
        $this->assertStringContainsString(
50
            'French Publisher',
51
            $this->crawler->filter('#collapseEditors tbody tr')->eq(1)->filter('td')->last()->text()
52
        );
53
    }
54
55
    public function testCategoriesList(): void
56
    {
57
        $this->assertCount(2, $this->crawler->filter('#collapseTypes li'));
58
        $this->assertStringContainsString('Novel', $this->crawler->filter('#collapseTypes li')->first()->text());
59
    }
60
61
    public function testErasList(): void
62
    {
63
        $this->assertCount(3, $this->crawler->filter('#collapseEras ul li'));
64
        $this->assertStringContainsString(
65
            'Old Republic',
66
            $this->crawler->filter('#collapseEras a[href="#oldRepublic"]')->text()
67
        );
68
    }
69
70
    public function testBooksTable(): void
71
    {
72
        $this->assertCount(1, $this->crawler->filter('table[data-books-list]'));
73
        $this->assertGreaterThan(1, $this->crawler->filter('table[data-books-list] thead')->count());
74
        $this->assertGreaterThan(1, $this->crawler->filter('table[data-books-list] tbody')->count());
75
        $this->assertGreaterThan(1, $this->crawler->filter('table[data-books-list] tbody td')->count());
76
77
        $this->markTestIncomplete('Should be completed with further checks');
78
    }
79
}
80