LibrariesAdminWebTest.test 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 library reports'), 'admin/reports/libraries');
  40. // Assert the page title and table titles show up.
  41. $this->assertText('Libraries');
  42. $this->assertRaw('<h2>Installed</h2>');
  43. $this->assertRaw('<h2>Uninstalled</h2>');
  44. // Make sure the table headings show up.
  45. $this->assertText('Name');
  46. $this->assertText('Status');
  47. $this->assertText('Version');
  48. $this->assertText('Variants');
  49. $this->assertText('Dependencies');
  50. $this->assertText('Provider');
  51. $this->assertText('Links');
  52. // Make sure that all the libraries are listed.
  53. $libraries = libraries_info();
  54. $this->assertTrue($libraries);
  55. foreach ($libraries as $library) {
  56. $this->assertText($library['name']);
  57. $this->assertLinkByHref('admin/reports/libraries/' . $library['machine name']);
  58. }
  59. // Make sure that all possible error statuses are displayed.
  60. $this->assertText('Not found');
  61. $this->assertText('Not detected');
  62. $this->assertText('Not supported');
  63. $this->assertText('Missing dependency');
  64. $this->assertText('Incompatible dependency');
  65. // Make sure that the providers are displayed.
  66. $this->assertRaw('<em class="placeholder">Libraries test module</em> module');
  67. $this->assertRaw('<em class="placeholder">Libraries test theme</em> theme');
  68. $this->assertRaw('<em class="placeholder">example_info_file.libraries.info</em> info file');
  69. // Make sure that homepage and download links are displayed.
  70. $this->assertLinkByHref('http://example.com');
  71. $this->assertLinkByHref('http://example.com/download');
  72. }
  73. /**
  74. * Tests the libraries report for an installed library.
  75. */
  76. public function testLibrariesReportInstalled() {
  77. $this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_files');
  78. $this->assertRaw('Status report for library <em class="placeholder">Example files</em>');
  79. $this->assertRaw('The <em class="placeholder">Example files</em> library is installed correctly.');
  80. // Check that the information in the status report is displayed.
  81. $this->assertText('Example files');
  82. $this->assertText('example_files');
  83. $this->assertRaw('<em class="placeholder">Libraries test module</em> module');
  84. $this->assertText(drupal_get_path('module', 'libraries') . '/tests/libraries/example');
  85. $this->assertText('1');
  86. }
  87. /**
  88. * Tests the libraries report for a missing library.
  89. */
  90. public function testLibrariesReportMissing() {
  91. $this->getWithPermissions(array('access library 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. * Tests the libraries report for a missing library.
  99. */
  100. public function testLibrariesReportNotDetected() {
  101. $this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_undetected_version');
  102. $this->assertRaw('Status report for library <em class="placeholder">Example undetected version</em>');
  103. $this->assertRaw('The version of the <em class="placeholder">Example undetected version</em> library could not be detected.');
  104. }
  105. /**
  106. * Tests the libraries report for a missing library.
  107. */
  108. public function testLibrariesReportNotSupported() {
  109. $this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_unsupported_version');
  110. $this->assertRaw('Status report for library <em class="placeholder">Example unsupported version</em>');
  111. $this->assertRaw('The installed version <em class="placeholder">1</em> of the <em class="placeholder">Example unsupported version</em> library is not supported.');
  112. // Check that the download link is being displayed.
  113. $this->assertLinkByHref('http://example.com/download');
  114. }
  115. }