|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Application\Tests\Functional; |
|
4
|
|
|
|
|
5
|
|
|
use Gnutix\Kernel\Tests\Functional\WebTestCase; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Books List Tests |
|
9
|
|
|
* |
|
10
|
|
|
* @group functional |
|
11
|
|
|
*/ |
|
12
|
|
|
final class BooksListTest extends WebTestCase |
|
13
|
|
|
{ |
|
14
|
|
|
/** @var \Symfony\Component\DomCrawler\Crawler */ |
|
15
|
|
|
protected $crawler; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Set up the test client |
|
19
|
|
|
*/ |
|
20
|
|
|
protected function setUp(): void |
|
21
|
|
|
{ |
|
22
|
|
|
parent::setUp(); |
|
23
|
|
|
|
|
24
|
|
|
$this->crawler = $this->httpKernelBrowser->request('GET', '/'); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Test the page status code |
|
29
|
|
|
*/ |
|
30
|
|
|
public function testPageStatusCode(): void |
|
31
|
|
|
{ |
|
32
|
|
|
$this->assertSame(200, $this->httpKernelBrowser->getResponse()->getStatusCode()); |
|
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Tests the page title and description |
|
37
|
|
|
*/ |
|
38
|
|
|
public function testPageHeader(): void |
|
39
|
|
|
{ |
|
40
|
|
|
$this->assertStringContainsString('Star Wars', $this->crawler->filter('h1')->text()); |
|
|
|
|
|
|
41
|
|
|
$this->assertStringContainsString('list of Star Wars books', $this->crawler->filter('p')->text()); |
|
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Tests the editors list |
|
46
|
|
|
*/ |
|
47
|
|
|
public function testEditorsList(): void |
|
48
|
|
|
{ |
|
49
|
|
|
$this->assertCount(3, $this->crawler->filter('#collapseEditors tbody tr')); |
|
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
$this->assertSame( |
|
|
|
|
|
|
52
|
|
|
'EN', |
|
53
|
|
|
$this->crawler->filter('#collapseEditors tbody tr')->first()->filter('img')->attr('alt') |
|
54
|
|
|
); |
|
55
|
|
|
$this->assertStringContainsString( |
|
|
|
|
|
|
56
|
|
|
'English Publisher', |
|
57
|
|
|
$this->crawler->filter('#collapseEditors tbody tr')->first()->filter('td')->last()->text() |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
$this->assertSame( |
|
|
|
|
|
|
61
|
|
|
'FR', |
|
62
|
|
|
$this->crawler->filter('#collapseEditors tbody tr')->eq(1)->filter('img')->attr('alt') |
|
63
|
|
|
); |
|
64
|
|
|
$this->assertStringContainsString( |
|
|
|
|
|
|
65
|
|
|
'French Publisher', |
|
66
|
|
|
$this->crawler->filter('#collapseEditors tbody tr')->eq(1)->filter('td')->last()->text() |
|
67
|
|
|
); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Tests the categories list |
|
72
|
|
|
*/ |
|
73
|
|
|
public function testCategoriesList(): void |
|
74
|
|
|
{ |
|
75
|
|
|
$this->assertCount(2, $this->crawler->filter('#collapseTypes li')); |
|
|
|
|
|
|
76
|
|
|
$this->assertStringContainsString('Novel', $this->crawler->filter('#collapseTypes li')->first()->text()); |
|
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Tests the eras list |
|
81
|
|
|
*/ |
|
82
|
|
|
public function testErasList(): void |
|
83
|
|
|
{ |
|
84
|
|
|
$this->assertCount(3, $this->crawler->filter('#collapseEras ul li')); |
|
|
|
|
|
|
85
|
|
|
$this->assertStringContainsString( |
|
|
|
|
|
|
86
|
|
|
'Old Republic', |
|
87
|
|
|
$this->crawler->filter('#collapseEras a[href="#oldRepublic"]')->text() |
|
88
|
|
|
); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Tests the book table |
|
93
|
|
|
* |
|
94
|
|
|
* @todo Complete this test... |
|
95
|
|
|
*/ |
|
96
|
|
|
public function testBooksTable(): void |
|
97
|
|
|
{ |
|
98
|
|
|
$this->assertCount(1, $this->crawler->filter('table[data-books-list]')); |
|
|
|
|
|
|
99
|
|
|
$this->assertGreaterThan(1, $this->crawler->filter('table[data-books-list] thead')->count()); |
|
|
|
|
|
|
100
|
|
|
$this->assertGreaterThan(1, $this->crawler->filter('table[data-books-list] tbody')->count()); |
|
|
|
|
|
|
101
|
|
|
$this->assertGreaterThan(1, $this->crawler->filter('table[data-books-list] tbody td')->count()); |
|
|
|
|
|
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.