|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Overwatch\UserBundle\Tests\E2E; |
|
4
|
|
|
|
|
5
|
|
|
use Facebook\WebDriver\WebDriverBy; |
|
6
|
|
|
use Overwatch\TestBundle\DataFixtures\ORM\TestFixtures; |
|
7
|
|
|
use Overwatch\TestBundle\DataFixtures\ORM\TestGroupFixtures; |
|
8
|
|
|
use Overwatch\UserBundle\DataFixtures\ORM\UserFixtures; |
|
9
|
|
|
use Overwatch\UserBundle\Tests\Base\WebDriverTestCase; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* MyAccountTest |
|
13
|
|
|
* |
|
14
|
|
|
* @author Zac Sturgess <[email protected]> |
|
15
|
|
|
*/ |
|
16
|
|
|
class AppNavigationTest extends WebDriverTestCase |
|
17
|
|
|
{ |
|
18
|
|
|
private $pages = [ |
|
19
|
|
|
'#/', |
|
20
|
|
|
'#/users', |
|
21
|
|
|
'#/alerts', |
|
22
|
|
|
'#/my-account' |
|
23
|
|
|
]; |
|
24
|
|
|
|
|
25
|
|
|
public function setUp() |
|
26
|
|
|
{ |
|
27
|
|
|
parent::setUp(); |
|
28
|
|
|
|
|
29
|
|
|
$groupId = TestGroupFixtures::$groups['group-1']->getId(); |
|
30
|
|
|
if (!in_array("#/group/$groupId", $this->pages)) { |
|
|
|
|
|
|
31
|
|
|
$this->pages[] = "#/group/$groupId"; |
|
|
|
|
|
|
32
|
|
|
} |
|
33
|
|
|
if (!in_array("#/group/$groupId/add-test", $this->pages)) { |
|
|
|
|
|
|
34
|
|
|
$this->pages[] = "#/group/$groupId/add-test"; |
|
|
|
|
|
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
$testId = TestFixtures::$tests['test-1']->getId(); |
|
38
|
|
|
if (!in_array("#/test/$testId", $this->pages)) { |
|
|
|
|
|
|
39
|
|
|
$this->pages[] = "#/test/$testId"; |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$this->logInAsUser('user-1'); |
|
43
|
|
|
$this->waitForLoadingAnimation(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
// public function testFirstBreadcrumbLinksHome() |
|
|
|
|
|
|
47
|
|
|
// { |
|
48
|
|
|
// foreach ($this->pages as $page) { |
|
|
|
|
|
|
49
|
|
|
// $this->webDriver->get('http://127.0.0.1:8000/' . $page); |
|
|
|
|
|
|
50
|
|
|
// $this->waitForLoadingAnimation(); |
|
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
// $this->assertEquals('Overwatch', $this->getBreadcrumbs()[0]->getText(), "The breadcrumb text on $page does not equal 'Overwatch'"); |
|
|
|
|
|
|
53
|
|
|
// $this->assertEquals( |
|
54
|
|
|
// 'http://127.0.0.1:8000/#/', |
|
55
|
|
|
// $this->getBreadcrumbs()[0]->findElement( |
|
|
|
|
|
|
56
|
|
|
// WebDriverBy::cssSelector('a') |
|
|
|
|
|
|
57
|
|
|
// )->getAttribute('href'), |
|
|
|
|
|
|
58
|
|
|
// "The breadcrumb link on $page does not equal '#/'" |
|
59
|
|
|
// ); |
|
60
|
|
|
// } |
|
61
|
|
|
// } |
|
62
|
|
|
|
|
63
|
|
|
// public function testCountBreadcrumbs() |
|
|
|
|
|
|
64
|
|
|
// { |
|
65
|
|
|
// foreach ($this->pages as $page) { |
|
|
|
|
|
|
66
|
|
|
// $this->webDriver->get('http://127.0.0.1:8000/' . $page); |
|
|
|
|
|
|
67
|
|
|
// $this->waitForLoadingAnimation(); |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
// $this->assertEquals(2, count($this->getBreadcrumbs()), "Breadcrumb count on $page does not equal 2"); |
|
|
|
|
|
|
70
|
|
|
// } |
|
71
|
|
|
// } |
|
72
|
|
|
|
|
73
|
|
|
// public function testLastBreadcrumbMatchesPageTitle() |
|
|
|
|
|
|
74
|
|
|
// { |
|
75
|
|
|
// foreach ($this->pages as $page) { |
|
|
|
|
|
|
76
|
|
|
// $this->webDriver->get('http://127.0.0.1:8000/' . $page); |
|
|
|
|
|
|
77
|
|
|
// $this->waitForLoadingAnimation(); |
|
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
// $breadcrumbs = $this->getBreadcrumbs(); |
|
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
// $this->assertContains( |
|
82
|
|
|
// $this->webDriver->findElement( |
|
|
|
|
|
|
83
|
|
|
// WebDriverBy::cssSelector('#page h1') |
|
|
|
|
|
|
84
|
|
|
// )->getText(), |
|
|
|
|
|
|
85
|
|
|
// end($breadcrumbs)->getText(), |
|
|
|
|
|
|
86
|
|
|
// "Final breadcrumb text on $page does not match the page's title" |
|
87
|
|
|
// ); |
|
88
|
|
|
// } |
|
89
|
|
|
// } |
|
90
|
|
|
|
|
91
|
|
|
// private function getBreadcrumbs() |
|
|
|
|
|
|
92
|
|
|
// { |
|
93
|
|
|
// return $this->webDriver->findElements( |
|
|
|
|
|
|
94
|
|
|
// WebDriverBy::cssSelector('ul.breadcrumbs li:not(.ng-hide)') |
|
|
|
|
|
|
95
|
|
|
// ); |
|
96
|
|
|
// } |
|
97
|
|
|
} |
|
98
|
|
|
|
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.