Projet

Général

Profil

Paste
Télécharger (4,75 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / libraries / tests / LibrariesAdminWebTest.test @ 0ccfec7f

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 site reports'), 'admin/reports/libraries');
44
    $this->assertRaw('Libraries');
45

    
46
    // Make sure that all the libraries are listed.
47
    $libraries = libraries_info();
48
    $this->assertTrue($libraries);
49
    foreach ($libraries as $library) {
50
      $this->assertText($library['name']);
51
      $this->assertLinkByHref('admin/reports/libraries/' . $library['machine name']);
52
    }
53

    
54
    // Make sure that all possible statuses are displayed.
55
    $this->assertText('OK');
56
    $this->assertText('Not found');
57
    $this->assertText('Not detected');
58
    $this->assertText('Not supported');
59
    $this->assertText('Missing dependency');
60
    $this->assertText('Incompatible dependency');
61

    
62
    // Make sure that the providers are displayed.
63
    $this->assertRaw('<em class="placeholder">Libraries test module</em> module');
64
    $this->assertRaw('<em class="placeholder">Libraries test theme</em> theme');
65
    $this->assertRaw('<em class="placeholder">example_info_file.libraries.info</em> info file');
66

    
67
    // Make sure that homepage and download links are displayed.
68
    $this->assertLinkByHref('http://example.com');
69
    $this->assertLinkByHref('http://example.com/download');
70
  }
71

    
72
  /**
73
   * Tests the libraries report for an installed library.
74
   */
75
  public function testLibrariesReportInstalled() {
76
    $this->getWithPermissions(array('access site reports'), 'admin/reports/libraries/example_files');
77
    $this->assertRaw('Status report for library <em class="placeholder">Example files</em>');
78
    $this->assertRaw('The <em class="placeholder">Example files</em> library is installed correctly.');
79
    // Check that the information in the status report is displayed.
80
    $this->assertText('Example files');
81
    $this->assertText('example_files');
82
    $this->assertRaw('<em class="placeholder">Libraries test module</em> module');
83
    $this->assertText(drupal_get_path('module', 'libraries') . '/tests/libraries/example');
84
    $this->assertText('1');
85
  }
86

    
87
  /**
88
   * Tests the libraries report for a missing library.
89
   */
90
  public function testLibrariesReportMissing() {
91
    $this->getWithPermissions(array('access site reports'), 'admin/reports/libraries/example_missing');
92
    $this->assertRaw('Status report for library <em class="placeholder">Example missing</em>');
93
    $this->assertRaw('The <em class="placeholder">Example missing</em> library could not be found.');
94
    // Check that the download link is being displayed.
95
    $this->assertLinkByHref('http://example.com/download');
96
  }
97

    
98

    
99
  /**
100
   * Tests the libraries report for a missing library.
101
   */
102
  public function testLibrariesReportNotDetected() {
103
    $this->getWithPermissions(array('access site reports'), 'admin/reports/libraries/example_undetected_version');
104
    $this->assertRaw('Status report for library <em class="placeholder">Example undetected version</em>');
105
    $this->assertRaw('The version of the <em class="placeholder">Example undetected version</em> library could not be detected.');
106
  }
107

    
108
  /**
109
   * Tests the libraries report for a missing library.
110
   */
111
  public function testLibrariesReportNotSupported() {
112
    $this->getWithPermissions(array('access site reports'), 'admin/reports/libraries/example_unsupported_version');
113
    $this->assertRaw('Status report for library <em class="placeholder">Example unsupported version</em>');
114
    $this->assertRaw('The installed version <em class="placeholder">1</em> of the <em class="placeholder">Example unsupported version</em> library is not supported.');
115
    // Check that the download link is being displayed.
116
    $this->assertLinkByHref('http://example.com/download');
117
  }
118

    
119
}