本文整理汇总了PHP中Magento\Framework\Module\Dir\Reader::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Reader::expects方法的具体用法?PHP Reader::expects怎么用?PHP Reader::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Module\Dir\Reader
的用法示例。
在下文中一共展示了Reader::expects方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGet
/**
* 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));
}
示例2: setUp
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);
}
示例3: setUp
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);
}
示例4: testLoadData
/**
* @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());
}
示例5: setUp
/**
* 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();
}
示例6: setUp
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);
}
示例7: getContentStep
/**
* @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);
}
}
示例8: testGetViewConfig
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));
}
示例9: setUp
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);
}
示例10: testGetGlobal
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'));
}
示例11: testGetVcl
/**
* 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);
}
示例12: testItReturnsThePathToThePerFileSchema
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());
}
示例13: setUp
/**
* 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);
}
示例14: setUp
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);
}