1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Contains LibrariesAdminWebTest.
|
6
|
*
|
7
|
* Simpletest automatically discovers test files using PSR-4. We cannot,
|
8
|
* however, declare a namespace for this class, as that would require PHP 5.3.
|
9
|
* To prepare the PHP 5.3 requirement and the usage of PSR-4 in 7.x-3.x, we
|
10
|
* split each test class into its own file and use the correct base name, but
|
11
|
* for now use the 'test' extension and register them explicitly in
|
12
|
* libraries.info.
|
13
|
*
|
14
|
* @see simpletest_test_get_all()
|
15
|
*/
|
16
|
|
17
|
/**
|
18
|
* Tests the administrative interface for libraries.
|
19
|
*/
|
20
|
class LibrariesAdminWebTest extends LibrariesWebTestBase {
|
21
|
|
22
|
/**
|
23
|
* Provides metadata about this test.
|
24
|
*
|
25
|
* @return array
|
26
|
* An array of test metadata with the following keys:
|
27
|
* - name: The name of the test.
|
28
|
* - description: The description of the test.
|
29
|
* - group: The group of the test.
|
30
|
*/
|
31
|
public static function getInfo() {
|
32
|
return array(
|
33
|
'name' => 'Libraries administration',
|
34
|
'description' => 'Tests the administrative interface for libraries.',
|
35
|
'group' => 'Libraries API',
|
36
|
);
|
37
|
}
|
38
|
|
39
|
/**
|
40
|
* Tests the libraries report at /admin/reports/libraries.
|
41
|
*/
|
42
|
public function testLibrariesReportOverview() {
|
43
|
$this->getWithPermissions(array('access library reports'), 'admin/reports/libraries');
|
44
|
// Assert the page title and table titles show up.
|
45
|
$this->assertText('Libraries');
|
46
|
$this->assertRaw('<h2>Installed</h2>');
|
47
|
$this->assertRaw('<h2>Uninstalled</h2>');
|
48
|
|
49
|
// Make sure the table headings show up.
|
50
|
$this->assertText('Name');
|
51
|
$this->assertText('Status');
|
52
|
$this->assertText('Version');
|
53
|
$this->assertText('Variants');
|
54
|
$this->assertText('Dependencies');
|
55
|
$this->assertText('Provider');
|
56
|
$this->assertText('Links');
|
57
|
|
58
|
// Make sure that all the libraries are listed.
|
59
|
$libraries = libraries_info();
|
60
|
$this->assertTrue($libraries);
|
61
|
foreach ($libraries as $library) {
|
62
|
$this->assertText($library['name']);
|
63
|
$this->assertLinkByHref('admin/reports/libraries/' . $library['machine name']);
|
64
|
}
|
65
|
|
66
|
// Make sure that all possible error statuses are displayed.
|
67
|
$this->assertText('Not found');
|
68
|
$this->assertText('Not detected');
|
69
|
$this->assertText('Not supported');
|
70
|
$this->assertText('Missing dependency');
|
71
|
$this->assertText('Incompatible dependency');
|
72
|
|
73
|
// Make sure that the providers are displayed.
|
74
|
$this->assertRaw('<em class="placeholder">Libraries test module</em> module');
|
75
|
$this->assertRaw('<em class="placeholder">Libraries test theme</em> theme');
|
76
|
$this->assertRaw('<em class="placeholder">example_info_file.libraries.info</em> info file');
|
77
|
|
78
|
// Make sure that homepage and download links are displayed.
|
79
|
$this->assertLinkByHref('http://example.com');
|
80
|
$this->assertLinkByHref('http://example.com/download');
|
81
|
}
|
82
|
|
83
|
/**
|
84
|
* Tests the libraries report for an installed library.
|
85
|
*/
|
86
|
public function testLibrariesReportInstalled() {
|
87
|
$this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_files');
|
88
|
$this->assertRaw('Status report for library <em class="placeholder">Example files</em>');
|
89
|
$this->assertRaw('The <em class="placeholder">Example files</em> library is installed correctly.');
|
90
|
// Check that the information in the status report is displayed.
|
91
|
$this->assertText('Example files');
|
92
|
$this->assertText('example_files');
|
93
|
$this->assertRaw('<em class="placeholder">Libraries test module</em> module');
|
94
|
$this->assertText(drupal_get_path('module', 'libraries') . '/tests/libraries/example');
|
95
|
$this->assertText('1');
|
96
|
}
|
97
|
|
98
|
/**
|
99
|
* Tests the libraries report for a missing library.
|
100
|
*/
|
101
|
public function testLibrariesReportMissing() {
|
102
|
$this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_missing');
|
103
|
$this->assertRaw('Status report for library <em class="placeholder">Example missing</em>');
|
104
|
$this->assertRaw('The <em class="placeholder">Example missing</em> library could not be found.');
|
105
|
// Check that the download link is being displayed.
|
106
|
$this->assertLinkByHref('http://example.com/download');
|
107
|
}
|
108
|
|
109
|
|
110
|
/**
|
111
|
* Tests the libraries report for a missing library.
|
112
|
*/
|
113
|
public function testLibrariesReportNotDetected() {
|
114
|
$this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_undetected_version');
|
115
|
$this->assertRaw('Status report for library <em class="placeholder">Example undetected version</em>');
|
116
|
$this->assertRaw('The version of the <em class="placeholder">Example undetected version</em> library could not be detected.');
|
117
|
}
|
118
|
|
119
|
/**
|
120
|
* Tests the libraries report for a missing library.
|
121
|
*/
|
122
|
public function testLibrariesReportNotSupported() {
|
123
|
$this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_unsupported_version');
|
124
|
$this->assertRaw('Status report for library <em class="placeholder">Example unsupported version</em>');
|
125
|
$this->assertRaw('The installed version <em class="placeholder">1</em> of the <em class="placeholder">Example unsupported version</em> library is not supported.');
|
126
|
// Check that the download link is being displayed.
|
127
|
$this->assertLinkByHref('http://example.com/download');
|
128
|
}
|
129
|
|
130
|
}
|