AutoloaderTest.php 1.6 KB

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