当前位置: 首页>>代码示例>>PHP>>正文


PHP ObjectManagerInterface::expects方法代码示例

本文整理汇总了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();
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:7,代码来源:ThemeDependencyCheckerFactoryTest.php

示例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'));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:7,代码来源:ProxyTest.php

示例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);
 }
开发者ID:ytorbyk,项目名称:magento2-geo-store-switcher,代码行数:11,代码来源:RuleFactoryTest.php

示例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}');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:AddCommentTest.php

示例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));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:FactoryTest.php

示例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);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:FactoryTest.php

示例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);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:7,代码来源:AbstractIndexerCommandCommonSetup.php

示例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);
 }
开发者ID:nja78,项目名称:magento2,代码行数:33,代码来源:BackupCommandTest.php

示例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');
 }
开发者ID:okite11,项目名称:frames21,代码行数:7,代码来源:ModeFactoryTest.php

示例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([]);
    }
开发者ID:nja78,项目名称:magento2,代码行数:30,代码来源:DeployStaticContentCommandTest.php

示例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));
 }
开发者ID:ytorbyk,项目名称:magento2-geo-ip2,代码行数:12,代码来源:ClientFactoryTest.php

示例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());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:SaveTest.php

示例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);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:CancelTest.php

示例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));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:RequestFactoryTest.php

示例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,
            ]
        );
    }
开发者ID:nblair,项目名称:magescotch,代码行数:35,代码来源:ExportViewedCsvTest.php


注:本文中的Magento\Framework\ObjectManagerInterface::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。