本文整理汇总了PHP中Magento\Framework\ObjectManagerInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManagerInterface::expects方法的具体用法?PHP ObjectManagerInterface::expects怎么用?PHP ObjectManagerInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\ObjectManagerInterface
的用法示例。
在下文中一共展示了ObjectManagerInterface::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreate
public function testCreate()
{
$this->objectManagerProvider->expects($this->once())->method('get')->willReturn($this->objectManager);
$this->objectManager->expects($this->once())->method('get')->with('Magento\\Theme\\Model\\Theme\\ThemeDependencyChecker');
$this->themeDependencyCheckerFactory = new ThemeDependencyCheckerFactory($this->objectManagerProvider);
$this->themeDependencyCheckerFactory->create();
}
示例2: testGetNonShared
public function testGetNonShared()
{
$this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\Mview\\Config\\Data')->will($this->returnValue($this->dataMock));
$this->dataMock->expects($this->once())->method('get')->with('some_path', 'default')->will($this->returnValue('some_value'));
$this->model = new Proxy($this->objectManagerMock, 'Magento\\Framework\\Mview\\Config\\Data', false);
$this->assertEquals('some_value', $this->model->get('some_path', 'default'));
}
示例3: testCreateWrongClass
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage WrongClassName doesn't implement \Tobai\GeoStoreSwitcher\Model\Store\Switcher\RuleInterface
*/
public function testCreateWrongClass()
{
$className = 'WrongClassName';
$rule = $this->getMockBuilder('WrongClassName')->disableOriginalConstructor()->getMock();
$this->objectManager->expects($this->once())->method('create')->with($className)->willReturn($rule);
$this->ruleFactory->create($className);
}
示例4: exceptionResponse
/**
* Processing section runtime errors
*
* @return void
*/
protected function exceptionResponse()
{
$dataMock = $this->getMock('Magento\\Framework\\Json\\Helper\\Data', ['jsonEncode'], [], '', false);
$this->objectManagerMock->expects($this->once())->method('get')->will($this->returnValue($dataMock));
$dataMock->expects($this->once())->method('jsonEncode')->will($this->returnValue('{json-data}'));
$this->responseMock->expects($this->once())->method('representJson')->with('{json-data}');
}
示例5: testCreateCheckout
public function testCreateCheckout()
{
$checkoutMock = $this->getMockBuilder('Magento\\Checkout\\Model\\Session')->disableOriginalConstructor()->setMethods([])->getMock();
$instance = $this->getMockBuilder('Magento\\Paypal\\Helper\\Shortcut\\ValidatorInterface')->getMock();
$this->objectManagerMock->expects($this->once())->method('create')->with(Factory::CHECKOUT_VALIDATOR)->will($this->returnValue($instance));
$this->assertInstanceOf('Magento\\Paypal\\Helper\\Shortcut\\ValidatorInterface', $this->factory->create($checkoutMock));
}
示例6: testCreate
/**
* @param mixed $class
* @param array $arguments
* @param string $expectedClassName
* @dataProvider createDataProvider
*/
public function testCreate($class, $arguments, $expectedClassName)
{
$createdModel = $this->getMock('Magento\\Sales\\Model\\Order\\Pdf\\Total\\DefaultTotal', [], [], (string) $class, false);
$this->_objectManager->expects($this->once())->method('create')->with($expectedClassName, $arguments)->will($this->returnValue($createdModel));
$actual = $this->_factory->create($class, $arguments);
$this->assertSame($createdModel, $actual);
}
示例7: configureAdminArea
protected function configureAdminArea()
{
$config = ['test config'];
$this->configLoaderMock->expects($this->once())->method('load')->with(FrontNameResolver::AREA_CODE)->will($this->returnValue($config));
$this->objectManager->expects($this->once())->method('configure')->with($config);
$this->stateMock->expects($this->once())->method('setAreaCode')->with(FrontNameResolver::AREA_CODE);
}
示例8: setUp
public function setUp()
{
$maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false);
$objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false);
$this->objectManager = $this->getMockForAbstractClass(
'Magento\Framework\ObjectManagerInterface',
[],
'',
false
);
$objectManagerProvider->expects($this->any())->method('get')->willReturn($this->objectManager);
$this->backupRollback = $this->getMock('Magento\Framework\Setup\BackupRollback', [], [], '', false);
$this->backupRollbackFactory = $this->getMock(
'Magento\Framework\Setup\BackupRollbackFactory',
[],
[],
'',
false
);
$this->backupRollbackFactory->expects($this->any())
->method('create')
->willReturn($this->backupRollback);
$this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false);
$this->objectManager->expects($this->any())
->method('get')
->will($this->returnValue($this->backupRollbackFactory));
$command = new BackupCommand(
$objectManagerProvider,
$maintenanceMode,
$this->deploymentConfig
);
$this->tester = new CommandTester($command);
}
示例9: testCreateStepWithException2
public function testCreateStepWithException2()
{
$mode = $this->getMock('Migration\\Mode\\Unknown', [], [], '', false);
$this->objectManager->expects($this->once())->method('create')->will($this->returnValue($mode));
$this->setExpectedException('\\Migration\\Exception', 'Mode class must implement ModeInterface.');
$this->modeFactory->create('unknown');
}
示例10: testExecute
public function testExecute()
{
$omFactory = $this->getMock('Magento\Framework\App\ObjectManagerFactory', [], [], '', false);
$this->objectManagerProvider->expects($this->any())
->method('get')
->will($this->returnValue($this->objectManager));
$this->objectManagerProvider->expects($this->once())
->method('getObjectManagerFactory')
->with([])
->willReturn($omFactory);
$this->deployer->expects($this->once())->method('deploy');
$this->objectManager->expects($this->at(0))
->method('create')
->willReturn($this->filesUtil);
$this->objectManager->expects($this->at(1))
->method('create')
->willReturn($this->deployer);
$this->validator->expects($this->once())->method('isValid')->with('en_US')->willReturn(true);
$this->deploymentConfig->expects($this->once())
->method('isAvailable')
->will($this->returnValue(true));
$tester = new CommandTester($this->command);
$tester->execute([]);
}
示例11: testCreate
/**
* @param array|string $options
* @param array $data
* @dataProvider createDataProvider
*/
public function testCreate($options, $data)
{
$this->configureConfigMethods('config user id', 'config license key', 'config host');
$client = $this->getMockBuilder('GeoIp2\\WebService\\Client')->disableOriginalConstructor()->getMock();
$this->objectManager->expects($this->once())->method('create')->with($this->instanceName, $data)->willReturn($client);
$this->assertSame($client, $this->clientFactory->create($options));
}
示例12: testTryToSaveInvalidDataShouldFailWithErrors
public function testTryToSaveInvalidDataShouldFailWithErrors()
{
$validatorClass = 'Magento\\MediaStorage\\Model\\File\\Validator\\AvailablePath';
$helperClass = 'Magento\\Sitemap\\Helper\\Data';
$validPaths = [];
$messages = ['message1', 'message2'];
$sessionClass = 'Magento\\Backend\\Model\\Session';
$data = ['sitemap_filename' => 'sitemap_filename', 'sitemap_path' => '/sitemap_path'];
$siteMapId = 1;
$this->requestMock->expects($this->once())->method('getPostValue')->willReturn($data);
$this->requestMock->expects($this->once())->method('getParam')->with('sitemap_id')->willReturn($siteMapId);
$validator = $this->getMock($validatorClass, [], [], '', false);
$validator->expects($this->once())->method('setPaths')->with($validPaths)->willReturnSelf();
$validator->expects($this->once())->method('isValid')->with('/sitemap_path/sitemap_filename')->willReturn(false);
$validator->expects($this->once())->method('getMessages')->willReturn($messages);
$helper = $this->getMock($helperClass, [], [], '', false);
$helper->expects($this->once())->method('getValidPaths')->willReturn($validPaths);
$session = $this->getMock($sessionClass, ['setFormData'], [], '', false);
$session->expects($this->once())->method('setFormData')->with($data)->willReturnSelf();
$this->objectManagerMock->expects($this->once())->method('create')->with($validatorClass)->willReturn($validator);
$this->objectManagerMock->expects($this->any())->method('get')->willReturnMap([[$helperClass, $helper], [$sessionClass, $session]]);
$this->messageManagerMock->expects($this->at(0))->method('addError')->withConsecutive([$messages[0]], [$messages[1]])->willReturnSelf();
$this->resultRedirectMock->expects($this->once())->method('setPath')->with('adminhtml/*/edit', ['sitemap_id' => $siteMapId])->willReturnSelf();
$this->assertSame($this->resultRedirectMock, $this->saveController->execute());
}
示例13: setUp
protected function setUp()
{
$this->_session = $this->getMock('Magento\\Customer\\Model\\Session', [], [], '', false);
$this->_agreement = $this->getMock('Magento\\Paypal\\Model\\Billing\\Agreement', ['load', 'getId', 'getCustomerId', 'getReferenceId', 'canCancel', 'cancel', '__wakeup'], [], '', false);
$this->_agreement->expects($this->once())->method('load')->with(15)->will($this->returnSelf());
$this->_agreement->expects($this->once())->method('getId')->will($this->returnValue(15));
$this->_agreement->expects($this->once())->method('getCustomerId')->will($this->returnValue(871));
$this->_objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
$this->_objectManager->expects($this->atLeastOnce())->method('get')->will($this->returnValueMap([['Magento\\Customer\\Model\\Session', $this->_session]]));
$this->_objectManager->expects($this->once())->method('create')->with('Magento\\Paypal\\Model\\Billing\\Agreement')->will($this->returnValue($this->_agreement));
$this->_request = $this->getMock('Magento\\Framework\\App\\RequestInterface');
$this->_request->expects($this->once())->method('getParam')->with('agreement')->will($this->returnValue(15));
$response = $this->getMock('Magento\\Framework\\App\\ResponseInterface');
$redirect = $this->getMock('Magento\\Framework\\App\\Response\\RedirectInterface');
$this->_messageManager = $this->getMock('Magento\\Framework\\Message\\ManagerInterface');
$context = $this->getMock('Magento\\Framework\\App\\Action\\Context', [], [], '', false);
$context->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->_objectManager));
$context->expects($this->any())->method('getRequest')->will($this->returnValue($this->_request));
$context->expects($this->any())->method('getResponse')->will($this->returnValue($response));
$context->expects($this->any())->method('getRedirect')->will($this->returnValue($redirect));
$context->expects($this->any())->method('getMessageManager')->will($this->returnValue($this->_messageManager));
$this->_registry = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
$title = $this->getMock('Magento\\Framework\\App\\Action\\Title', [], [], '', false);
$this->_controller = new \Magento\Paypal\Controller\Billing\Agreement\Cancel($context, $this->_registry, $title);
}
示例14: testCreate
/**
* @covers \Magento\Framework\App\RequestFactory::__construct
* @covers \Magento\Framework\App\RequestFactory::create
*/
public function testCreate()
{
$arguments = ['some_key' => 'same_value'];
$appRequest = $this->getMock('Magento\\Framework\\App\\RequestInterface');
$this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\App\\RequestInterface', $arguments)->will($this->returnValue($appRequest));
$this->assertEquals($appRequest, $this->model->create($arguments));
}
示例15: setUp
/**
* {@inheritDoc}
*/
protected function setUp()
{
parent::setUp();
$this->dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Filter\Date')
->disableOriginalConstructor()
->getMock();
$this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data')
->disableOriginalConstructor()
->getMock();
$this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface')
->disableOriginalConstructor()
->getMock();
$this->objectManagerMock
->expects($this->any())
->method('get')
->willReturn($this->helperMock);
$this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock);
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->exportViewedCsv = $objectManager->getObject(
'Magento\Reports\Controller\Adminhtml\Report\Product\ExportViewedCsv',
[
'context' => $this->contextMock,
'fileFactory' => $this->fileFactoryMock,
'dateFilter' => $this->dateMock,
]
);
}