/** * @expectedException \Zend_Json_Exception */ public function testGetPackageNameInvalidJson() { $this->componentRegistrar->expects($this->once())->method('getPath')->willReturn('path/to/A'); $this->dirRead->expects($this->once())->method('isExist')->willReturn(true); $this->dirRead->expects($this->once())->method('readFile')->willReturn('{"name": }'); $this->themePackageInfo->getPackageName('themeA'); }
public function setUp() { $this->componentRegistrar = $this->getMock('Magento\\Framework\\Component\\ComponentRegistrar', [], [], '', false); $this->reader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', [], [], '', false); $this->componentRegistrar->expects($this->once())->method('getPaths')->will($this->returnValue(['A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'E' => 'E'])); $composerData = ['A/composer.json' => '{"name":"a", "require":{"b":"0.1"}, "conflict":{"c":"0.1"}, "version":"0.1"}', 'B/composer.json' => '{"name":"b", "require":{"d":"0.3"}, "version":"0.2"}', 'C/composer.json' => '{"name":"c", "require":{"e":"0.1"}, "version":"0.1"}', 'D/composer.json' => '{"name":"d", "conflict":{"c":"0.1"}, "version":"0.3"}', 'E/composer.json' => '{"name":"e", "version":"0.4"}']; $fileIteratorMock = $this->getMock('Magento\\Framework\\Config\\FileIterator', [], [], '', false); $fileIteratorMock->expects($this->once())->method('toArray')->will($this->returnValue($composerData)); $this->reader->expects($this->once())->method('getComposerJsonFiles')->will($this->returnValue($fileIteratorMock)); $this->packageInfo = new PackageInfo($this->reader, $this->componentRegistrar); }
public function setUp() { $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); $objectManagerProvider = $this->getMock( 'Magento\Setup\Model\ObjectManagerProvider', [], [], '', false ); $this->objectManager = $this->getMockForAbstractClass( 'Magento\Framework\ObjectManagerInterface', [], '', false ); $this->cacheMock = $this->getMockBuilder('Magento\Framework\App\Cache') ->disableOriginalConstructor() ->getMock(); $objectManagerProvider->expects($this->once()) ->method('get') ->willReturn($this->objectManager); $this->manager = $this->getMock('Magento\Setup\Module\Di\App\Task\Manager', [], [], '', false); $this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); $this->filesystem = $this->getMockBuilder('Magento\Framework\Filesystem') ->disableOriginalConstructor() ->getMock(); $this->fileDriver = $this->getMockBuilder('Magento\Framework\Filesystem\Driver\File') ->disableOriginalConstructor() ->getMock(); $this->componentRegistrar = $this->getMock( '\Magento\Framework\Component\ComponentRegistrar', [], [], '', false ); $this->componentRegistrar->expects($this->any())->method('getPaths')->willReturnMap([ [ComponentRegistrar::MODULE, ['/path/to/module/one', '/path/to/module/two']], [ComponentRegistrar::LIBRARY, ['/path/to/library/one', '/path/to/library/two']], ]); $this->command = new DiCompileCommand( $this->deploymentConfig, $this->directoryList, $this->manager, $objectManagerProvider, $this->filesystem, $this->fileDriver, $this->componentRegistrar ); }
/** * Test Setup * * @return void */ public function setUp() { $this->_fileSystemMock = $this->getMock('\\Magento\\Framework\\Filesystem', [], [], '', false); $this->_scopeConfigMock = $this->getMock('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface'); $this->rootDirectoryMock = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface'); $this->compiledDirectoryMock = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface'); $this->_fileSystemMock->expects($this->any())->method('getDirectoryRead')->will($this->returnValueMap([[DirectoryList::ROOT, DriverPool::FILE, $this->rootDirectoryMock], [DirectoryList::TEMPLATE_MINIFICATION_DIR, DriverPool::FILE, $this->compiledDirectoryMock]])); $this->compiledDirectoryMock->expects($this->any())->method('getAbsolutePath')->will($this->returnValue('/magento/var/compiled')); $this->componentRegistrar = $this->getMock('Magento\\Framework\\Component\\ComponentRegistrar', [], [], '', false); $this->componentRegistrar->expects($this->any())->method('getPaths')->will($this->returnValueMap([[ComponentRegistrar::MODULE, ['/magento/app/code/Some/Module']], [ComponentRegistrar::THEME, ['/magento/themes/default']]])); $this->_validator = new \Magento\Framework\View\Element\Template\File\Validator($this->_fileSystemMock, $this->_scopeConfigMock, $this->componentRegistrar); }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Invalid context given: "invalid_type". */ public function testBuildPathToLocaleDirectoryByContextWithInvalidType() { $this->componentRegistrar->expects($this->any())->method('getPaths')->with(ComponentRegistrar::MODULE)->willReturn(['module' => '/path/to/module']); $this->context = new Context($this->componentRegistrar); $this->context->buildPathToLocaleDirectoryByContext('invalid_type', 'Magento_Module'); }