AutoloaderTest.php 968 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /*
  3. * This file is part of Mustache.php.
  4. *
  5. * (c) 2010-2016 Justin Hileman
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * @group unit
  12. */
  13. class Mustache_Test_AutoloaderTest extends PHPUnit_Framework_TestCase
  14. {
  15. public function testRegister()
  16. {
  17. $loader = Mustache_Autoloader::register();
  18. $this->assertTrue(spl_autoload_unregister(array($loader, 'autoload')));
  19. }
  20. public function testAutoloader()
  21. {
  22. $loader = new Mustache_Autoloader(dirname(__FILE__) . '/../../fixtures/autoloader');
  23. $this->assertNull($loader->autoload('NonMustacheClass'));
  24. $this->assertFalse(class_exists('NonMustacheClass'));
  25. $loader->autoload('Mustache_Foo');
  26. $this->assertTrue(class_exists('Mustache_Foo'));
  27. $loader->autoload('\Mustache_Bar');
  28. $this->assertTrue(class_exists('Mustache_Bar'));
  29. }
  30. }