ClassCollectionLoaderTest.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\ClassLoader;
  11. use Symfony\Component\ClassLoader\ClassCollectionLoader;
  12. class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testFixNamespaceDeclarations()
  15. {
  16. $source = <<<EOF
  17. <?php
  18. namespace Foo;
  19. class Foo {}
  20. namespace Bar ;
  21. class Foo {}
  22. namespace Foo\Bar;
  23. class Foo {}
  24. namespace Foo\Bar\Bar
  25. {
  26. class Foo {}
  27. }
  28. namespace
  29. {
  30. class Foo {}
  31. }
  32. EOF;
  33. $expected = <<<EOF
  34. <?php
  35. namespace Foo
  36. {
  37. class Foo {}
  38. }
  39. namespace Bar
  40. {
  41. class Foo {}
  42. }
  43. namespace Foo\Bar
  44. {
  45. class Foo {}
  46. }
  47. namespace Foo\Bar\Bar
  48. {
  49. class Foo {}
  50. }
  51. namespace
  52. {
  53. class Foo {}
  54. }
  55. EOF;
  56. $this->assertEquals($expected, ClassCollectionLoader::fixNamespaceDeclarations($source));
  57. }
  58. /**
  59. * @expectedException InvalidArgumentException
  60. */
  61. public function testUnableToLoadClassException()
  62. {
  63. ClassCollectionLoader::load(array('SomeNotExistingClass'), '', 'foo', false);
  64. }
  65. }