コード例 #1
0
 /**
  * @param \Magento\Tools\Di\Code\Reader\ClassesScanner $classesScanner
  * @param \Magento\Framework\Code\Reader\ClassReader $classReader
  * @param \Magento\Framework\Code\Validator $validator
  * @param \Magento\Framework\Code\Validator\ConstructorIntegrity $constructorIntegrityValidator
  * @param \Magento\Framework\Code\Validator\ContextAggregation $contextAggregationValidator
  * @param Log $log
  */
 public function __construct(\Magento\Tools\Di\Code\Reader\ClassesScanner $classesScanner, \Magento\Framework\Code\Reader\ClassReader $classReader, \Magento\Framework\Code\Validator $validator, \Magento\Framework\Code\Validator\ConstructorIntegrity $constructorIntegrityValidator, \Magento\Framework\Code\Validator\ContextAggregation $contextAggregationValidator, Log $log)
 {
     $this->classReader = $classReader;
     $this->classesScanner = $classesScanner;
     $this->validator = $validator;
     $this->log = $log;
     $this->validator->add($constructorIntegrityValidator);
     $this->validator->add($contextAggregationValidator);
 }
コード例 #2
0
ファイル: ValidatorTest.php プロジェクト: tingyeeh/magento2
 public function testValidate()
 {
     $className = 'Same\\Class\\Name';
     $validator1 = $this->getMock('Magento\\Framework\\Code\\ValidatorInterface');
     $validator1->expects($this->once())->method('validate')->with($className);
     $validator2 = $this->getMock('Magento\\Framework\\Code\\ValidatorInterface');
     $validator2->expects($this->once())->method('validate')->with($className);
     $this->model->add($validator1);
     $this->model->add($validator2);
     $this->model->validate($className);
 }
コード例 #3
0
 protected function setUp()
 {
     $this->_shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer());
     $basePath = Files::init()->getPathToSource();
     $basePath = str_replace('\\', '/', $basePath);
     $this->_tmpDir = realpath(__DIR__) . '/tmp';
     $this->_generationDir = $this->_tmpDir . '/generation';
     if (!file_exists($this->_generationDir)) {
         mkdir($this->_generationDir, 0770, true);
     }
     $this->_compilationDir = $this->_tmpDir . '/di';
     if (!file_exists($this->_compilationDir)) {
         mkdir($this->_compilationDir, 0770, true);
     }
     $this->_command = 'php ' . $basePath . '/bin/magento setup:di:compile-multi-tenant --generation=%s --di=%s';
     $booleanUtils = new \Magento\Framework\Stdlib\BooleanUtils();
     $constInterpreter = new \Magento\Framework\Data\Argument\Interpreter\Constant();
     $argumentInterpreter = new \Magento\Framework\Data\Argument\Interpreter\Composite(['boolean' => new \Magento\Framework\Data\Argument\Interpreter\Boolean($booleanUtils), 'string' => new \Magento\Framework\Data\Argument\Interpreter\StringUtils($booleanUtils), 'number' => new \Magento\Framework\Data\Argument\Interpreter\Number(), 'null' => new \Magento\Framework\Data\Argument\Interpreter\NullType(), 'object' => new \Magento\Framework\Data\Argument\Interpreter\DataObject($booleanUtils), 'const' => $constInterpreter, 'init_parameter' => new \Magento\Framework\App\Arguments\ArgumentInterpreter($constInterpreter)], \Magento\Framework\ObjectManager\Config\Reader\Dom::TYPE_ATTRIBUTE);
     // Add interpreters that reference the composite
     $argumentInterpreter->addInterpreter('array', new \Magento\Framework\Data\Argument\Interpreter\ArrayType($argumentInterpreter));
     $this->_mapper = new \Magento\Framework\ObjectManager\Config\Mapper\Dom($argumentInterpreter, $booleanUtils, new \Magento\Framework\ObjectManager\Config\Mapper\ArgumentParser());
     $this->_validator = new \Magento\Framework\Code\Validator();
     $this->_validator->add(new \Magento\Framework\Code\Validator\ConstructorIntegrity());
     $this->_validator->add(new \Magento\Framework\Code\Validator\ContextAggregation());
     $this->_validator->add(new \Magento\Framework\Code\Validator\TypeDuplication());
     $this->_validator->add(new \Magento\Framework\Code\Validator\ArgumentSequence());
     $this->_validator->add(new \Magento\Framework\Code\Validator\ConstructorArgumentTypes());
     $this->pluginValidator = new \Magento\Framework\Interception\Code\InterfaceValidator();
 }
コード例 #4
0
 protected function setUp()
 {
     $this->_shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer());
     $basePath = \Magento\TestFramework\Utility\Files::init()->getPathToSource();
     $basePath = str_replace('\\', '/', $basePath);
     $this->_tmpDir = realpath(__DIR__) . '/tmp';
     $this->_generationDir = $this->_tmpDir . '/generation';
     $this->_compilationDir = $this->_tmpDir . '/di';
     (new \Magento\Framework\Autoload\IncludePath())->addIncludePath(array($basePath . '/app/code', $basePath . '/lib/internal', $this->_generationDir));
     $this->_command = 'php ' . $basePath . '/dev/tools/Magento/Tools/Di/compiler.php --generation=%s --di=%s';
     $booleanUtils = new \Magento\Framework\Stdlib\BooleanUtils();
     $constInterpreter = new \Magento\Framework\Data\Argument\Interpreter\Constant();
     $argumentInterpreter = new \Magento\Framework\Data\Argument\Interpreter\Composite(['boolean' => new \Magento\Framework\Data\Argument\Interpreter\Boolean($booleanUtils), 'string' => new \Magento\Framework\Data\Argument\Interpreter\String($booleanUtils), 'number' => new \Magento\Framework\Data\Argument\Interpreter\Number(), 'null' => new \Magento\Framework\Data\Argument\Interpreter\NullType(), 'object' => new \Magento\Framework\Data\Argument\Interpreter\Object($booleanUtils), 'const' => $constInterpreter, 'init_parameter' => new \Magento\Framework\App\Arguments\ArgumentInterpreter($constInterpreter)], \Magento\Framework\ObjectManager\Config\Reader\Dom::TYPE_ATTRIBUTE);
     // Add interpreters that reference the composite
     $argumentInterpreter->addInterpreter('array', new \Magento\Framework\Data\Argument\Interpreter\ArrayType($argumentInterpreter));
     $this->_mapper = new \Magento\Framework\ObjectManager\Config\Mapper\Dom($argumentInterpreter, $booleanUtils, new \Magento\Framework\ObjectManager\Config\Mapper\ArgumentParser());
     $this->_validator = new \Magento\Framework\Code\Validator();
     $this->_validator->add(new \Magento\Framework\Code\Validator\ConstructorIntegrity());
     $this->_validator->add(new \Magento\Framework\Code\Validator\ContextAggregation());
     $this->_validator->add(new \Magento\Framework\Code\Validator\TypeDuplication());
     $this->_validator->add(new \Magento\Framework\Code\Validator\ArgumentSequence());
     $this->pluginValidator = new \Magento\Framework\Interception\Code\InterfaceValidator();
 }
コード例 #5
0
ファイル: CompilerTest.php プロジェクト: rafaelstz/magento2
 protected function setUp()
 {
     $this->_shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer());
     $basePath = BP;
     $basePath = str_replace('\\', '/', $basePath);
     $directoryList = new DirectoryList($basePath);
     $this->_generationDir = $directoryList->getPath(DirectoryList::GENERATION);
     $this->_compilationDir = $directoryList->getPath(DirectoryList::DI);
     $this->_command = 'php ' . $basePath . '/bin/magento setup:di:compile';
     $booleanUtils = new \Magento\Framework\Stdlib\BooleanUtils();
     $constInterpreter = new \Magento\Framework\Data\Argument\Interpreter\Constant();
     $argumentInterpreter = new \Magento\Framework\Data\Argument\Interpreter\Composite(['boolean' => new \Magento\Framework\Data\Argument\Interpreter\Boolean($booleanUtils), 'string' => new \Magento\Framework\Data\Argument\Interpreter\StringUtils($booleanUtils), 'number' => new \Magento\Framework\Data\Argument\Interpreter\Number(), 'null' => new \Magento\Framework\Data\Argument\Interpreter\NullType(), 'object' => new \Magento\Framework\Data\Argument\Interpreter\DataObject($booleanUtils), 'const' => $constInterpreter, 'init_parameter' => new \Magento\Framework\App\Arguments\ArgumentInterpreter($constInterpreter)], \Magento\Framework\ObjectManager\Config\Reader\Dom::TYPE_ATTRIBUTE);
     // Add interpreters that reference the composite
     $argumentInterpreter->addInterpreter('array', new \Magento\Framework\Data\Argument\Interpreter\ArrayType($argumentInterpreter));
     $this->_mapper = new \Magento\Framework\ObjectManager\Config\Mapper\Dom($argumentInterpreter, $booleanUtils, new \Magento\Framework\ObjectManager\Config\Mapper\ArgumentParser());
     $this->_validator = new \Magento\Framework\Code\Validator();
     $this->_validator->add(new \Magento\Framework\Code\Validator\ConstructorIntegrity());
     $this->_validator->add(new \Magento\Framework\Code\Validator\ContextAggregation());
     $this->_validator->add(new \Magento\Framework\Code\Validator\TypeDuplication());
     $this->_validator->add(new \Magento\Framework\Code\Validator\ArgumentSequence());
     $this->_validator->add(new \Magento\Framework\Code\Validator\ConstructorArgumentTypes());
     $this->pluginValidator = new \Magento\Framework\Interception\Code\InterfaceValidator();
 }