AutoloaderTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * This file is part of PHPOffice Common
  4. *
  5. * PHPOffice Common is free software distributed under the terms of the GNU Lesser
  6. * General Public License version 3 as published by the Free Software Foundation.
  7. *
  8. * For the full copyright and license information, please read the LICENSE
  9. * file that was distributed with this source code. For the full list of
  10. * contributors, visit https://github.com/PHPOffice/Common/contributors.
  11. *
  12. * @link https://github.com/PHPOffice/Common
  13. * @copyright 2009-2016 PHPOffice Common contributors
  14. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  15. */
  16. namespace PhpOffice\Common\Tests;
  17. use PhpOffice\Common\Autoloader;
  18. /**
  19. * Test class for Autoloader
  20. */
  21. class AutoloaderTest extends \PHPUnit\Framework\TestCase
  22. {
  23. /**
  24. * Register
  25. */
  26. public function testRegister()
  27. {
  28. Autoloader::register();
  29. $this->assertContains(
  30. array('PhpOffice\\Common\\Autoloader', 'autoload'),
  31. spl_autoload_functions()
  32. );
  33. }
  34. /**
  35. * Autoload
  36. */
  37. public function testAutoload()
  38. {
  39. $declared = get_declared_classes();
  40. $declaredCount = count($declared);
  41. Autoloader::autoload('Foo');
  42. $this->assertEquals(
  43. $declaredCount,
  44. count(get_declared_classes()),
  45. 'PhpOffice\\Common\\Autoloader::autoload() is trying to load ' .
  46. 'classes outside of the PhpOffice\\Common namespace'
  47. );
  48. }
  49. }