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