registry_autoload.test 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * @file
  4. * registry_autoload tests.
  5. */
  6. /**
  7. * Test basics.
  8. */
  9. class RegistryAutoloadTestCase extends DrupalWebTestCase {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Registry Autoload',
  13. 'description' => 'Tests loading classes inserted with registry autoload into the registry.',
  14. 'group' => 'Registry',
  15. );
  16. }
  17. function setUp() {
  18. parent::setUp('registry_autoload', 'registry_autoload_test');
  19. }
  20. /**
  21. * Tests that class loading works properly.
  22. */
  23. function testClassLoading() {
  24. ob_start();
  25. registry_autoload_test_class_loading();
  26. $buffer = ob_get_clean();
  27. $this->drupalSetContent($buffer);
  28. $this->assertText('Hello Core', 'PSR-0 class loading works.');
  29. $this->assertText('Hello Render_Cache', 'PSR-4 class loading works.');
  30. $this->assertText('Implements x', 'Interface loading works.');
  31. $this->assertText('Hello No Namespace', 'No namespace class loading works.');
  32. $this->assertText('Hello custom some namespace', 'Custom namespace class loading works.');
  33. $this->assertText('Hello test-library: SomeVendor\SomeComponent', 'Arbitrary directory class loading works.');
  34. $this->assertText('Hello global test-library: SomeOtherVendor\SomeComponent', 'Arbitrary directory class loading with DRUPAL_ROOT works. For this test to succeed registry_autoload must be in sites/all/modules.');
  35. $supports_traits = !version_compare(PHP_VERSION, '5.4', '<');
  36. if ($supports_traits) {
  37. $this->assertText('Hello Class using trait.', 'Trait loading works.');
  38. $this->assertText('Hello Trait.', 'Trait loading works.');
  39. }
  40. }
  41. }