/** * Run test for get method * * @return void */ public function testGet() { $filename = 'test-filename'; $expected = ['file1', 'file2']; $this->readerMock->expects($this->once())->method('getConfigurationFiles')->with($filename)->willReturn($expected); $this->assertEquals($expected, $this->fileResolver->get($filename, null)); }
protected function setUp() { $this->_xsdFile = $this->_xsdDir . '/address_formats.xsd'; $this->_moduleReader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', ['getModuleDir'], [], '', false); $this->_moduleReader->expects($this->once())->method('getModuleDir')->with('etc', 'Magento_Customer')->will($this->returnValue($this->_xsdDir)); $this->_model = new \Magento\Customer\Model\Address\Config\SchemaLocator($this->_moduleReader); }
protected function setUp() { $this->moduleDir = 'moduleDirectory'; $this->moduleReader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', [], [], '', false); $this->moduleReader->expects($this->any())->method('getModuleDir')->willReturn($this->moduleDir); $this->schemaLocator = new SchemaLocator($this->moduleReader); }
/** * @param string $area * @param bool $forceReload * @param array $cachedData * @dataProvider dataProviderForTestLoadData * @SuppressWarnings(PHPMD.NPathComplexity) */ public function testLoadData($area, $forceReload, $cachedData) { $this->expectsSetConfig('themeId'); $this->cache->expects($this->exactly($forceReload ? 0 : 1))->method('load')->will($this->returnValue(serialize($cachedData))); if (!$forceReload && $cachedData !== false) { $this->translate->loadData($area, $forceReload); $this->assertEquals($cachedData, $this->translate->getData()); return; } $this->directory->expects($this->any())->method('isExist')->will($this->returnValue(true)); // _loadModuleTranslation() $this->moduleList->expects($this->once())->method('getNames')->will($this->returnValue(['name'])); $moduleData = ['module original' => 'module translated', 'module theme' => 'module-theme original translated', 'module pack' => 'module-pack original translated', 'module db' => 'module-db original translated']; $this->modulesReader->expects($this->any())->method('getModuleDir')->will($this->returnValue('/app/module')); $themeData = ['theme original' => 'theme translated', 'module theme' => 'theme translated overwrite', 'module pack' => 'theme-pack translated overwrite', 'module db' => 'theme-db translated overwrite']; $this->csvParser->expects($this->any())->method('getDataPairs')->will($this->returnValueMap([['/app/module/en_US.csv', 0, 1, $moduleData], ['/app/module/en_GB.csv', 0, 1, $moduleData], ['/theme.csv', 0, 1, $themeData]])); // _loadThemeTranslation() $this->viewFileSystem->expects($this->any())->method('getLocaleFileName')->will($this->returnValue('/theme.csv')); // _loadPackTranslation $packData = ['pack original' => 'pack translated', 'module pack' => 'pack translated overwrite', 'module db' => 'pack-db translated overwrite']; $this->packDictionary->expects($this->once())->method('getDictionary')->will($this->returnValue($packData)); // _loadDbTranslation() $dbData = ['db original' => 'db translated', 'module db' => 'db translated overwrite']; $this->resource->expects($this->any())->method('getTranslationArray')->will($this->returnValue($dbData)); $this->cache->expects($this->exactly(1))->method('save'); $this->translate->loadData($area, $forceReload); $expected = ['module original' => 'module translated', 'module theme' => 'theme translated overwrite', 'module pack' => 'pack translated overwrite', 'module db' => 'db translated overwrite', 'theme original' => 'theme translated', 'pack original' => 'pack translated', 'db original' => 'db translated']; $this->assertEquals($expected, $this->translate->getData()); }
/** * Save default translator */ protected function setUp() { $this->_defaultTranslator = \Magento\Framework\Validator\AbstractValidator::getDefaultTranslator(); $this->_objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); $this->_validatorConfig = $this->getMockBuilder( 'Magento\Framework\Validator\Config' )->setMethods( ['createValidatorBuilder', 'createValidator'] )->disableOriginalConstructor()->getMock(); $this->_objectManager->expects( $this->at(0) )->method( 'create' )->with( 'Magento\Framework\Translate\Adapter' )->will( $this->returnValue(new \Magento\Framework\Translate\Adapter()) ); $this->_objectManager->expects( $this->at(1) )->method( 'create' )->with( 'Magento\Framework\Validator\Config', ['configFiles' => ['/tmp/moduleOne/etc/validation.xml']] )->will( $this->returnValue($this->_validatorConfig) ); // Config mock $this->_config = $this->getMockBuilder( 'Magento\Framework\Module\Dir\Reader' )->setMethods( ['getConfigurationFiles'] )->disableOriginalConstructor()->getMock(); $this->_config->expects( $this->once() )->method( 'getConfigurationFiles' )->with( 'validation.xml' )->will( $this->returnValue(['/tmp/moduleOne/etc/validation.xml']) ); // Translate adapter mock $this->_translateAdapter = $this->getMockBuilder( 'Magento\Framework\TranslateInterface' )->disableOriginalConstructor()->getMock(); $this->cache = $this->getMockBuilder(\Magento\Framework\Cache\FrontendInterface::class) ->getMockForAbstractClass(); }
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); }
/** * @param bool $check */ protected function getContentStep($check = true) { $resultPath = 'adminhtml/path/to/file.xml'; $includeXmlContent = '<config><item id="1"><test/></item><item id="2"></item></config>'; $modulesDirectoryMock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->getMockForAbstractClass(); $this->readFactoryMock->expects($this->once())->method('create')->willReturn($modulesDirectoryMock); $this->moduleReaderMock->expects($this->once())->method('getModuleDir')->with('etc', 'Module_Name')->willReturn('path/in/application/module'); $modulesDirectoryMock->expects($this->once())->method('isExist')->with($resultPath)->willReturn($check); if ($check) { $modulesDirectoryMock->expects($this->once())->method('isFile')->with($resultPath)->willReturn($check); $modulesDirectoryMock->expects($this->once())->method('readFile')->with($resultPath)->willReturn($includeXmlContent); } }
public function testGetViewConfig() { $themeMock = $this->getMock('Magento\\Theme\\Model\\Theme', ['getId', 'getCustomization', 'getCustomViewConfigPath'], [], '', false); $themeMock->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(2)); $themeMock->expects($this->once())->method('getCustomization')->will($this->returnSelf()); $themeMock->expects($this->once())->method('getCustomViewConfigPath')->will($this->returnValue('')); $params = ['themeModel' => $themeMock]; $configFile = 'config.xml'; $this->repositoryMock->expects($this->atLeastOnce())->method('updateDesignParams')->with($this->equalTo($params))->will($this->returnSelf()); $iterator = $this->getMock('Magento\\Framework\\Config\\FileIterator', [], [], '', false); $iterator->expects($this->once())->method('toArray')->will($this->returnValue([])); $this->readerMock->expects($this->once())->method('getConfigurationFiles')->with($this->equalTo(basename(\Magento\Framework\View\ConfigInterface::CONFIG_FILE_NAME)))->will($this->returnValue($iterator)); $this->directoryReadMock->expects($this->once())->method('isExist')->with($this->anything())->will($this->returnValue(true)); $this->fileSystemMock->expects($this->once())->method('getFilename')->with($this->equalTo(\Magento\Framework\View\ConfigInterface::CONFIG_FILE_NAME), $params)->will($this->returnValue($configFile)); $this->directoryReadMock->expects($this->any())->method('getRelativePath')->with($this->equalTo($configFile))->will($this->returnArgument(0)); $xmlData = '<view><vars module="Magento_Catalog"><var name="test">1</var></vars></view>'; $this->directoryReadMock->expects($this->once())->method('readFile')->with($this->equalTo($configFile))->will($this->returnValue($xmlData)); $this->assertInstanceOf('Magento\\Framework\\Config\\View', $this->config->getViewConfig($params)); // lazy load test $this->assertInstanceOf('Magento\\Framework\\Config\\View', $this->config->getViewConfig($params)); }
public function testGetPersistentConfigFilePath() { $this->_modulesReader->expects($this->once())->method('getModuleDir')->with('etc', 'Magento_Persistent')->will($this->returnValue('path123')); $this->assertEquals('path123/persistent.xml', $this->_helper->getPersistentConfigFilePath()); }
/** * Test for get method with default scope * * @dataProvider providerGet * @param string $filename * @param array $fileList */ public function testGetDefault($filename, $fileList) { $scope = 'some_scope'; $this->moduleReader->expects($this->once())->method('getConfigurationFiles')->with($scope . '/' . $filename)->will($this->returnValue($fileList)); $this->assertEquals($fileList, $this->model->get($filename, $scope)); }
protected function setUp() { $this->_moduleReader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', ['getModuleDir'], [], '', false); $this->_moduleReader->expects($this->once())->method('getModuleDir')->with('etc', 'Magento_Sales')->will($this->returnValue($this->_xsdDir)); $this->_model = new \Magento\Sales\Model\Order\Pdf\Config\SchemaLocator($this->_moduleReader); }
protected function setUp() { $this->_moduleReader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', array('getModuleDir'), array(), '', false); $this->_moduleReader->expects($this->once())->method('getModuleDir')->with('etc', 'Magento_Email')->will($this->returnValue('fixture_dir')); $this->_model = new \Magento\Email\Model\Template\Config\SchemaLocator($this->_moduleReader); }
public function testGetGlobal() { $expected = new \StdClass(); $this->moduleReader->expects($this->once())->method('getConfigurationFiles')->with('file')->willReturn($expected); $this->assertSame($expected, $this->object->get('file', 'global')); }
/** * test for getVcl method */ public function testGetVcl() { $this->moduleReader->expects($this->once())->method('getModuleDir')->willReturn('/magento/app/code/Magento/PageCache'); $test = $this->_model->getVclFile(Config::VARNISH_3_CONFIGURATION_PATH); $this->assertEquals(file_get_contents(__DIR__ . '/_files/result.vcl'), $test); }
public function testItReturnsThePathToThePerFileSchema() { $this->moduleReaderMock->expects($this->any())->method('getModuleDir')->willReturn('....'); $schemaLocator = $this->createNewSchemaLocatorInstance($this->moduleReaderMock, 'Test_ModuleName', 'some other file name', $this->testSchemaFileName); $this->assertSame('..../' . $this->testSchemaFileName, $schemaLocator->getPerFileSchema()); }
public function testGetTemplateFilename() { $this->_moduleReader->expects($this->once())->method('getModuleDir')->with('view', 'Fixture_ModuleOne')->will($this->returnValue('_files/Fixture/ModuleOne/view')); $actualResult = $this->_model->getTemplateFilename('template_one'); $this->assertEquals('_files/Fixture/ModuleOne/view/email/one.html', $actualResult); }
/** * Set up * * @return void */ protected function setUp() { $this->readerMock = $this->getMockBuilder('Magento\\Framework\\Module\\Dir\\Reader')->disableOriginalConstructor()->getMock(); $this->readerMock->expects($this->once())->method('getModuleDir')->with('etc', 'Magento_Paypal')->willReturn('magento/path'); $this->schemaLocator = new \Magento\Paypal\Model\Config\Rules\SchemaLocator($this->readerMock); }
protected function setUp() { $this->_moduleReader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', ['getModuleDir'], [], '', false); $this->_moduleReader->expects($this->once())->method('getModuleDir')->with('etc', 'Magento_Catalog')->will($this->returnValue('fixture_dir')); $this->_model = new \Magento\Catalog\Model\Attribute\Config\SchemaLocator($this->_moduleReader); }