|
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
|
|
|
|