Ingen beskrivning

AutoloaderTest.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord 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/PHPWord/contributors.
  12. *
  13. * @link https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2014 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Tests;
  18. use PhpOffice\PhpWord\Autoloader;
  19. /**
  20. * Test class for PhpOffice\PhpWord\Autoloader
  21. *
  22. * @runTestsInSeparateProcesses
  23. */
  24. class AutoloaderTest extends \PHPUnit_Framework_TestCase
  25. {
  26. /**
  27. * Register
  28. */
  29. public function testRegister()
  30. {
  31. Autoloader::register();
  32. $this->assertContains(
  33. array('PhpOffice\\PhpWord\\Autoloader', 'autoload'),
  34. spl_autoload_functions()
  35. );
  36. }
  37. /**
  38. * Autoload
  39. */
  40. public function testAutoload()
  41. {
  42. $declaredCount = count(get_declared_classes());
  43. Autoloader::autoload('Foo');
  44. $this->assertCount(
  45. $declaredCount,
  46. get_declared_classes(),
  47. 'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load ' .
  48. 'classes outside of the PhpOffice\\PhpWord namespace'
  49. );
  50. // TODO change this class to the main PhpWord class when it is namespaced
  51. Autoloader::autoload('PhpOffice\\PhpWord\\Exception\\InvalidStyleException');
  52. $this->assertTrue(
  53. in_array('PhpOffice\\PhpWord\\Exception\\InvalidStyleException', get_declared_classes()),
  54. 'PhpOffice\\PhpWord\\Autoloader::autoload() failed to autoload the ' .
  55. 'PhpOffice\\PhpWord\\Exception\\InvalidStyleException class'
  56. );
  57. }
  58. }