本文整理汇总了PHP中Magento\Framework\Filesystem::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::expects方法的具体用法?PHP Filesystem::expects怎么用?PHP Filesystem::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Filesystem
的用法示例。
在下文中一共展示了Filesystem::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNotUnlockProcessInProductionMode
public function testNotUnlockProcessInProductionMode()
{
$this->stateMock->expects(self::exactly(2))->method('getMode')->willReturn(State::MODE_PRODUCTION);
$this->filesystemMock->expects(self::never())->method('getDirectoryWrite');
$this->lockerProcess->lockProcess(self::LOCK_NAME);
$this->lockerProcess->unlockProcess();
}
示例2: testAddTrackingNumbersToShipment
/**
* @covers \Magento\Shipping\Model\Shipping\LabelGenerator
* @param array $info
* @dataProvider labelInfoDataProvider
*/
public function testAddTrackingNumbersToShipment(array $info)
{
$order = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
$order->expects(static::once())->method('getShippingMethod')->with(true)->willReturn($this->getShippingMethodMock());
/**
* @var $shipmentMock \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject
*/
$shipmentMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Shipment')->disableOriginalConstructor()->getMock();
$shipmentMock->expects(static::once())->method('getOrder')->willReturn($order);
$this->carrierFactory->expects(static::once())->method('create')->with(self::CARRIER_CODE)->willReturn($this->getCarrierMock());
$labelsMock = $this->getMockBuilder('\\Magento\\Shipping\\Model\\Shipping\\Labels')->disableOriginalConstructor()->getMock();
$labelsMock->expects(static::once())->method('requestToShipment')->with($shipmentMock)->willReturn($this->getResponseMock($info));
$this->labelsFactory->expects(static::once())->method('create')->willReturn($labelsMock);
$this->filesystem->expects(static::once())->method('getDirectoryWrite')->willReturn($this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'));
$this->scopeConfig->expects(static::once())->method('getValue')->with('carriers/' . self::CARRIER_CODE . '/title', ScopeInterface::SCOPE_STORE, null)->willReturn(self::CARRIER_TITLE);
$this->labelsFactory->expects(static::once())->method('create')->willReturn($labelsMock);
$trackMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Shipment\\Track')->setMethods(['setNumber', 'setCarrierCode', 'setTitle'])->disableOriginalConstructor()->getMock();
$i = 0;
$trackingNumbers = is_array($info['tracking_number']) ? $info['tracking_number'] : [$info['tracking_number']];
foreach ($trackingNumbers as $trackingNumber) {
$trackMock->expects(static::at($i++))->method('setNumber')->with($trackingNumber)->willReturnSelf();
$trackMock->expects(static::at($i++))->method('setCarrierCode')->with(self::CARRIER_CODE)->willReturnSelf();
$trackMock->expects(static::at($i++))->method('setTitle')->with(self::CARRIER_TITLE)->willReturnSelf();
}
$this->trackFactory->expects(static::any())->method('create')->willReturn($trackMock);
/**
* @var $requestMock \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
*/
$requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface');
$this->labelGenerator->create($shipmentMock, $requestMock);
}
示例3: setUp
protected function setUp()
{
$this->filesystemMock = $this->getMockBuilder('Magento\Framework\Filesystem')
->disableOriginalConstructor()
->getMock();
$this->fileFactoryMock = $this->getMockBuilder('Magento\Framework\View\File\Factory')
->disableOriginalConstructor()
->getMock();
$this->pathPatternHelperMock = $this->getMockBuilder('Magento\Framework\View\Helper\PathPattern')
->disableOriginalConstructor()
->getMock();
$this->directoryMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface')
->getMockForAbstractClass();
$this->themeMock = $this->getMockBuilder('Magento\Framework\View\Design\ThemeInterface')
->setMethods(['getData'])
->getMockForAbstractClass();
$this->filesystemMock->expects($this->once())
->method('getDirectoryRead')
->with(DirectoryList::MODULES)
->willReturn($this->directoryMock);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->fileCollector = $this->objectManagerHelper->getObject(
'Magento\Framework\View\File\Collector\Base',
[
'filesystem' => $this->filesystemMock,
'fileFactory' => $this->fileFactoryMock,
'pathPatternHelper' => $this->pathPatternHelperMock,
'subDir' => 'layout'
]
);
}
示例4: setUp
public function setUp()
{
$this->filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
$this->directoryRead = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\ReadInterface', [], '', false);
$this->filesystem->expects($this->once())->method('getDirectoryRead')->willReturn($this->directoryRead);
$this->reader = new Reader($this->filesystem);
}
示例5: testToHtml
public function testToHtml()
{
$fieldSet = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Fieldset', [], [], '', false);
$form = $this->getMock('Magento\\Framework\\Data\\Form', [], [], '', false);
$attributeModel = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], [], '', false);
$entityType = $this->getMock('Magento\\Eav\\Model\\Entity\\Type', [], [], '', false);
$formElement = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Text', ['setDisabled'], [], '', false);
$directoryReadInterface = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface');
$this->registry->expects($this->any())->method('registry')->with('entity_attribute')->willReturn($attributeModel);
$this->formFactory->expects($this->any())->method('create')->willReturn($form);
$form->expects($this->any())->method('addFieldset')->willReturn($fieldSet);
$form->expects($this->any())->method('getElement')->willReturn($formElement);
$fieldSet->expects($this->any())->method('addField')->willReturnSelf();
$attributeModel->expects($this->any())->method('getDefaultValue')->willReturn('default_value');
$attributeModel->expects($this->any())->method('setDisabled')->willReturnSelf();
$attributeModel->expects($this->any())->method('getId')->willReturn(1);
$attributeModel->expects($this->any())->method('getEntityType')->willReturn($entityType);
$attributeModel->expects($this->any())->method('getIsUserDefined')->willReturn(false);
$attributeModel->expects($this->any())->method('getAttributeCode')->willReturn('attribute_code');
$this->localeDate->expects($this->any())->method('getDateFormat')->willReturn('mm/dd/yy');
$entityType->expects($this->any())->method('getEntityTypeCode')->willReturn('entity_type_code');
$this->eavData->expects($this->any())->method('getFrontendClasses')->willReturn([]);
$formElement->expects($this->exactly(3))->method('setDisabled')->willReturnSelf();
$this->yesNo->expects($this->any())->method('toOptionArray')->willReturn(['yes', 'no']);
$this->filesystem->expects($this->any())->method('getDirectoryRead')->willReturn($directoryReadInterface);
$directoryReadInterface->expects($this->any())->method('getRelativePath')->willReturn('relative_path');
$this->block->setData(['action' => 'save']);
$this->block->toHtml();
}
示例6: setup
public function setup()
{
$this->filesystemMock = $this->getMockBuilder('Magento\Framework\Filesystem')
->disableOriginalConstructor()
->getMock();
$this->directoryMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface')
->getMock();
$this->fileFactoryMock = $this->getMockBuilder('Magento\Framework\View\File\Factory')
->disableOriginalConstructor()
->getMock();
$this->themeMock = $this->getMockBuilder('Magento\Framework\View\Design\ThemeInterface')
->getMock();
$this->filesystemMock->expects($this->any())
->method('getDirectoryRead')
->willReturn($this->directoryMock);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->themeFileCollector = $this->objectManagerHelper->getObject(
'Magento\Framework\View\File\Collector\Theme',
[
'filesystem' => $this->filesystemMock,
'fileFactory' => $this->fileFactoryMock
]
);
}
示例7: setUp
public function setUp()
{
$this->filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
$this->varReaderWriter = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\WriteInterface', [], '', false);
$this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($this->varReaderWriter));
$this->status = new Status($this->filesystem);
}
示例8: setUp
protected function setUp()
{
$this->requestMock = $this->getMock(
'\Magento\Framework\App\Request\Http',
['getBasePath', 'isSecure', 'getHttpHost'],
[],
'',
false,
false
);
$this->requestMock->expects($this->atLeastOnce())->method('getBasePath')->will($this->returnValue('/'));
$this->requestMock->expects($this->atLeastOnce())
->method('getHttpHost')
->will($this->returnValue('init.host'));
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->validatorFactory = $this->getMockBuilder('Magento\Framework\ValidatorFactory')
->disableOriginalConstructor()
->getMock();
$backendUrl = $this->getMock('\Magento\Backend\Model\Url', [], [], '', false);
$backendUrl->expects($this->once())->method('getBaseUrl')->will($this->returnValue('/'));
$this->backendUrlFactory = $this->getMock('Magento\Backend\Model\UrlFactory', ['create'], [], '', false);
$this->backendUrlFactory->expects($this->any())->method('create')->willReturn($backendUrl);
$this->filesystemMock = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false);
$dirMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface');
$this->filesystemMock->expects($this->any())
->method('getDirectoryWrite')
->will($this->returnValue($dirMock));
}
示例9: tearDown
/**
* Clear state file
*/
protected function tearDown()
{
$this->filesystem->expects($this->any())->method('getDirectoryWrite')->willReturn($this->writeInterface);
$this->writeInterface->expects($this->any())->method('openFile')->willReturnSelf($this->absolutePath);
$this->state->clearState();
}
示例10: testSaveAuthJson
public function testSaveAuthJson()
{
$directoryWrite = $this->getMockForAbstractClass('\\Magento\\Framework\\Filesystem\\Directory\\WriteInterface');
$this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($directoryWrite));
$directoryWrite->expects($this->once())->method('writeFile')->willReturn(true);
$this->assertTrue($this->packagesAuth->saveAuthJson("testusername", "testpassword"));
}
示例11: setUp
public function setUp()
{
$this->directoryReadMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', [], [], '', false);
$this->filesystemMock = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
$this->filesystemMock->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($this->directoryReadMock));
$this->ioMock = $this->getMock('Composer\\IO\\BufferIO', [], [], '', false);
}
示例12: setUp
public function setUp()
{
$this->directoryWriteMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
$this->filesystemMock = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
$this->filesystemMock->expects($this->any())->method('getDirectoryWrite')->will($this->returnValue($this->directoryWriteMock));
$this->directoryListMock = $this->getMock('Magento\\Framework\\App\\Filesystem\\DirectoryList', [], [], '', false);
$this->filePermissions = new FilePermissions($this->filesystemMock, $this->directoryListMock);
}
示例13: setup
public function setup()
{
$this->filesystemMock = $this->getMockBuilder('Magento\\Framework\\Filesystem')->disableOriginalConstructor()->getMock();
$this->themesDirectoryMock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->getMock();
$this->filesystemMock->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($this->themesDirectoryMock));
$this->fileFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\File\\Factory')->disableOriginalConstructor()->getMock();
$this->themeMock = $this->getMockBuilder('Magento\\Framework\\View\\Design\\ThemeInterface')->getMock();
}
示例14: testExecute
public function testExecute()
{
$dir = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
$dir->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0));
$this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($dir));
$this->processor->expects($this->once())->method('reindexAll');
$this->assertEquals('0', $this->entryPoint->launch());
}
示例15: setUp
protected function setUp()
{
$this->filesystemMock = $this->getMock('Magento\\Framework\\Filesystem', array('getDirectoryWrite'), array(), '', false);
$directoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', array(), array(), '', false);
$directoryMock->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0));
$this->filesystemMock->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($directoryMock));
$this->processorMock = $this->getMock('Magento\\Indexer\\Model\\Processor', array(), array(), '', false);
$this->entryPoint = new \Magento\Indexer\App\Indexer('reportDir', $this->filesystemMock, $this->processorMock);
}