ExamplesTest.php
2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* @file
* SimpleTests for examples module.
*/
namespace Drupal\examples\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Minimal test case for the examples module.
*
* @group examples
*
* @ingroup examples
*/
class ExamplesTest extends WebTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = array('examples', 'toolbar');
/**
* Test whether the module was installed.
*/
public function testExamples() {
// Verify that the toolbar tab and tray are showing and functioning.
$user = $this->drupalCreateUser(array('access toolbar'));
$this->drupalLogin($user);
// Check for the 'Examples' tab.
$this->drupalGet('');
// Assert that the toolbar tab registered by examples is present.
$this->assertLink('Examples');
// Assert that the toolbar tab registered by examples is present.
$this->assertEqual(
\count($this->xpath('//nav/div/a[@data-toolbar-tray="toolbar-item-examples-tray"]')),
1,
'Found the Examples toolbar tab.'
);
// Assert that the toolbar tray registered by examples is present.
$this->assertEqual(
\count($this->xpath('//nav/div/div[@data-toolbar-tray="toolbar-item-examples-tray"]')),
1,
'Found the Examples toolbar tray.'
);
// Assert that PHPUnit link does not appears in the tray.
$this->assertNoLink('PHPUnit example');
$this->assertNoRaw('<li class="phpunit-example">');
// Install phpunit_example and see if it appears in the toolbar. We use
// phpunit_example because it's very light-weight.
$this->container->get('module_installer')->install(array('phpunit_example'), TRUE);
// SimpleTest needs for us to reset all the caches.
$this->resetAll();
// Verify that PHPUnit appears in the tray.
$this->drupalGet('');
$this->assertLink('PHPUnit example');
// Assert that the PHPUnit tray item is present.
$this->assertEqual(
\count($this->xpath('//nav/div/div/nav/ul/li[@class="phpunit-example"]')),
1,
'Found the PHPUnit Example tray item.'
);
}
}