ObjectManagerFactoryTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\App\Test\Unit;
  7. use Magento\Framework\App\Bootstrap;
  8. /**
  9. * @covers \Magento\Framework\App\ObjectManagerFactory
  10. */
  11. class ObjectManagerFactoryTest extends \PHPUnit\Framework\TestCase
  12. {
  13. /** @var callable[] */
  14. protected static $originalAutoloadFunctions;
  15. /** @var string */
  16. protected static $originalIncludePath;
  17. public static function setUpBeforeClass()
  18. {
  19. self::$originalAutoloadFunctions = spl_autoload_functions();
  20. self::$originalIncludePath = get_include_path();
  21. }
  22. /**
  23. * Avoid impact of initialized \Magento\Framework\Code\Generator\Autoloader on other tests
  24. */
  25. public static function tearDownAfterClass()
  26. {
  27. foreach (spl_autoload_functions() as $autoloadFunction) {
  28. spl_autoload_unregister($autoloadFunction);
  29. }
  30. foreach (self::$originalAutoloadFunctions as $autoloadFunction) {
  31. spl_autoload_register($autoloadFunction);
  32. }
  33. set_include_path(self::$originalIncludePath);
  34. \Magento\Framework\Filesystem\Io\File::rmdirRecursive(__DIR__ . '/_files/var/');
  35. }
  36. /**
  37. * @expectedException \BadMethodCallException
  38. * @expectedExceptionMessage Magento\Framework\App\Test\Unit\ObjectManager\FactoryStub::__construct
  39. */
  40. public function testCreateObjectManagerFactoryCouldBeOverridden()
  41. {
  42. $rootPath = __DIR__ . '/_files/';
  43. $factory = Bootstrap::createObjectManagerFactory($rootPath, []);
  44. $factory->create([], false);
  45. }
  46. }