protected function setUp()
 {
     $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $config = new \Magento\Framework\ObjectManager\Config\Config(new \Magento\Framework\ObjectManager\Relations\Runtime());
     $factory = new \Magento\Framework\ObjectManager\Factory\Dynamic\Developer($config);
     $this->_realObjectManager = new \Magento\Framework\ObjectManager\ObjectManager($factory, $config);
     $factory->setObjectManager($this->_realObjectManager);
 }
示例#2
0
 /**
  * Inits $_serviceConfig property with specific files or default valid configuration files
  *
  * @param array|null $files
  */
 protected function _initConfig(array $files = null)
 {
     if (null === $files) {
         $files = glob(__DIR__ . '/_files/validation/positive/*/validation.xml');
     }
     $configFiles = [];
     foreach ($files as $path) {
         $configFiles[$path] = file_get_contents($path);
     }
     $config = new \Magento\Framework\ObjectManager\Config\Config(new \Magento\Framework\ObjectManager\Relations\Runtime());
     $factory = new \Magento\Framework\ObjectManager\Factory\Dynamic\Developer($config);
     $realObjectManager = new \Magento\Framework\ObjectManager\ObjectManager($factory, $config);
     $factory->setObjectManager($realObjectManager);
     $universalFactory = $realObjectManager->get('Magento\\Framework\\Validator\\UniversalFactory');
     $this->_config = $this->_objectManager->getObject('Magento\\Framework\\Validator\\Config', ['configFiles' => $configFiles, 'builderFactory' => $universalFactory]);
 }
示例#3
0
 /**
  * Inits $_serviceConfig property with specific files or default valid configuration files
  *
  * @param array|null $files
  */
 protected function _initConfig(array $files = null)
 {
     if (null === $files) {
         $files = glob(__DIR__ . '/_files/validation/positive/*/validation.xml');
     }
     $configFiles = [];
     foreach ($files as $path) {
         $configFiles[$path] = file_get_contents($path);
     }
     $config = new \Magento\Framework\ObjectManager\Config\Config(
         new \Magento\Framework\ObjectManager\Relations\Runtime()
     );
     $factory = new \Magento\Framework\ObjectManager\Factory\Dynamic\Developer($config);
     $appObjectManager = new \Magento\Framework\ObjectManager\ObjectManager($factory, $config);
     $factory->setObjectManager($appObjectManager);
     /** @var \Magento\Framework\Validator\UniversalFactory $universalFactory */
     $universalFactory = $appObjectManager->get('Magento\Framework\Validator\UniversalFactory');
     /** @var \Magento\Framework\Config\Dom\UrnResolver $urnResolverMock */
     $urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false);
     $urnResolverMock->expects($this->any())
         ->method('getRealPath')
         ->with('urn:magento:framework:Validator/etc/validation.xsd')
         ->willReturn($this->urnResolver->getRealPath('urn:magento:framework:Validator/etc/validation.xsd'));
     $appObjectManager->configure(
         [
             'preferences' => [
                 'Magento\Framework\Config\ValidationStateInterface' =>
                     'Magento\Framework\App\Arguments\ValidationState',
             ],
             'Magento\Framework\App\Arguments\ValidationState' => [
                 'arguments' => [
                     'appMode' => 'developer',
                 ]
             ]
         ]
     );
     $this->_config = $this->_objectManager->getObject(
         'Magento\Framework\Validator\Config',
         [
             'configFiles' => $configFiles,
             'builderFactory' => $universalFactory,
             'domFactory' => new \Magento\Framework\Config\DomFactory($appObjectManager),
             'urnResolver' => $urnResolverMock
         ]
     );
 }
 public function setUpInterceptionConfig($pluginConfig)
 {
     $config = new \Magento\Framework\Interception\ObjectManager\Config\Developer();
     $factory = new \Magento\Framework\ObjectManager\Factory\Dynamic\Developer($config, null);
     $this->_configReader = $this->getMock('Magento\\Framework\\Config\\ReaderInterface');
     $this->_configReader->expects($this->any())->method('read')->will($this->returnValue($pluginConfig));
     $areaList = $this->getMock('Magento\\Framework\\App\\AreaList', [], [], '', false);
     $areaList->expects($this->any())->method('getCodes')->will($this->returnValue([]));
     $configScope = new \Magento\Framework\Config\Scope($areaList, 'global');
     $cache = $this->getMock('Magento\\Framework\\Config\\CacheInterface');
     $cache->expects($this->any())->method('load')->will($this->returnValue(false));
     $definitions = new \Magento\Framework\ObjectManager\Definition\Runtime();
     $relations = new \Magento\Framework\ObjectManager\Relations\Runtime();
     $interceptionConfig = new Config\Config($this->_configReader, $configScope, $cache, $relations, $config, $definitions);
     $interceptionDefinitions = new Definition\Runtime();
     $sharedInstances = ['Magento\\Framework\\Config\\CacheInterface' => $cache, 'Magento\\Framework\\Config\\ScopeInterface' => $configScope, 'Magento\\Framework\\Config\\ReaderInterface' => $this->_configReader, 'Magento\\Framework\\ObjectManager\\RelationsInterface' => $relations, 'Magento\\Framework\\ObjectManager\\ConfigInterface' => $config, 'Magento\\Framework\\Interception\\ObjectManager\\ConfigInterface' => $config, 'Magento\\Framework\\ObjectManager\\DefinitionInterface' => $definitions, 'Magento\\Framework\\Interception\\DefinitionInterface' => $interceptionDefinitions];
     $this->_objectManager = new \Magento\Framework\ObjectManager\ObjectManager($factory, $config, $sharedInstances);
     $factory->setObjectManager($this->_objectManager);
     $config->setInterceptionConfig($interceptionConfig);
     $config->extend(['preferences' => ['Magento\\Framework\\Interception\\PluginListInterface' => 'Magento\\Framework\\Interception\\PluginList\\PluginList', 'Magento\\Framework\\Interception\\ChainInterface' => 'Magento\\Framework\\Interception\\Chain\\Chain']]);
 }