LibrariesAdminWebTest.test 4.8 KB

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