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();
 }
Esempio n. 2
0
 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'));
 }
 /**
  * @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);
 }
 /**
  * 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}');
 }
Esempio n. 5
0
 public function testExceptingClonedObject()
 {
     $origin = new \stdClass();
     $this->objectManagerMock->expects($this->once())->method('create')->with('clone')->willReturn($origin);
     $cloned = $this->conditionFactory->create('clone');
     $this->assertNotSame($cloned, $origin);
 }
 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));
 }
Esempio n. 7
0
 public function testCreate()
 {
     $type = '1';
     $data = ['data2', 'data3'];
     $this->objectManagerMock->expects($this->once())->method('create')->with($type, $data);
     $this->actionFactory->create($type, $data);
 }
 /**
  * @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);
 }
 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);
 }
Esempio n. 10
0
 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);
 }
Esempio n. 11
0
 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');
 }
    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([]);
    }
 /**
  * @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));
 }
Esempio n. 14
0
 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());
 }
Esempio n. 15
0
 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);
 }
 /**
  * @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));
 }
Esempio n. 17
0
    /**
     * {@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,
            ]
        );
    }
Esempio n. 18
0
 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage WrongClass class doesn't implement \Magento\Payment\Model\MethodInterface
  */
 public function testWrongTypeException()
 {
     $className = 'WrongClass';
     $methodMock = $this->getMock($className, [], [], '', false);
     $this->_objectManagerMock->expects($this->once())->method('create')->with($className, [])->will($this->returnValue($methodMock));
     $this->_factory->create($className);
 }
Esempio n. 19
0
    /**
     * @covers \Magento\Setup\Controller\Session::testUnloginAction
     */
    public function testUnloginAction()
    {
        $deployConfigMock = $this->getMock('Magento\Framework\App\DeploymentConfig', ['isAvailable'], [], '', false);
        $deployConfigMock->expects($this->once())->method('isAvailable')->will($this->returnValue(true));

        $stateMock = $this->getMock('Magento\Framework\App\State', ['setAreaCode'], [], '', false);
        $stateMock->expects($this->once())->method('setAreaCode');

        $sessionConfigMock =
            $this->getMock('Magento\Backend\Model\Session\AdminConfig', ['setCookiePath'], [], '', false);
        $sessionConfigMock->expects($this->once())->method('setCookiePath');

        $returnValueMap = [
            ['Magento\Framework\App\DeploymentConfig', $deployConfigMock],
            ['Magento\Framework\App\State', $stateMock],
            ['Magento\Backend\Model\Session\AdminConfig', $sessionConfigMock]
        ];

        $this->objectManager->expects($this->atLeastOnce())
            ->method('get')
            ->will($this->returnValueMap($returnValueMap));

        $sessionMock = $this->getMock('Magento\Backend\Model\Auth\Session', ['prolong'], [], '', false);
        $this->objectManager->expects($this->once())
            ->method('create')
            ->will($this->returnValue($sessionMock));
        $controller = new Session($this->objectManagerProvider);
        $controller->prolongAction();
    }
 public function testGet()
 {
     $actionInterfaceMock = $this->getMockForAbstractClass('Magento\\Indexer\\Model\\ActionInterface', [], '', false);
     $this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Indexer\\Model\\ActionInterface')->will($this->returnValue($actionInterfaceMock));
     $this->model->get('Magento\\Indexer\\Model\\ActionInterface');
     $this->assertInstanceOf('Magento\\Indexer\\Model\\ActionInterface', $actionInterfaceMock);
 }
 public function testCreate()
 {
     $actionInterfaceMock = $this->getMockForAbstractClass('Magento\\Framework\\Indexer\\ActionInterface', [], '', false);
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\Indexer\\ActionInterface', [])->willReturn($actionInterfaceMock);
     $this->model->create('Magento\\Framework\\Indexer\\ActionInterface');
     $this->assertInstanceOf('Magento\\Framework\\Indexer\\ActionInterface', $actionInterfaceMock);
 }
 public function testCreate()
 {
     $this->objectManagerProvider->expects($this->once())->method('get')->willReturn($this->objectManager);
     $this->objectManager->expects($this->once())->method('get')->with('Magento\\Framework\\Module\\Status');
     $this->moduleStatusFactory = new ModuleStatusFactory($this->objectManagerProvider);
     $this->moduleStatusFactory->create();
 }
Esempio n. 23
0
    public function testExecute()
    {
        $this->objectManager->expects($this->once())
            ->method('get')
            ->with('Magento\Framework\App\Cache')
            ->willReturn($this->cacheMock);
        $this->cacheMock->expects($this->once())->method('clean');
        $writeDirectory = $this->getMock('Magento\Framework\Filesystem\Directory\WriteInterface');
        $writeDirectory->expects($this->atLeastOnce())->method('delete');
        $this->filesystem->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($writeDirectory);

        $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true);
        $progressBar = $this->getMockBuilder(
            'Symfony\Component\Console\Helper\ProgressBar'
        )
            ->disableOriginalConstructor()
            ->getMock();

        $this->objectManager->expects($this->once())->method('configure');
        $this->objectManager
            ->expects($this->once())
            ->method('create')
            ->with('Symfony\Component\Console\Helper\ProgressBar')
            ->willReturn($progressBar);
        $this->manager->expects($this->exactly(6))->method('addOperation');
        $this->manager->expects($this->once())->method('process');
        $tester = new CommandTester($this->command);
        $tester->execute([]);
        $this->assertContains(
            'Generated code and dependency injection configuration successfully.',
            explode(PHP_EOL, $tester->getDisplay())
        );
    }
Esempio n. 24
0
 public function testCreateBlock()
 {
     $className = 'Magento\\Framework\\View\\Element\\Template';
     $argumentsResult = ['arg1', 'arg2'];
     $templateMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\Template')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock->expects($this->once())->method('create')->with($className, $argumentsResult)->will($this->returnValue($templateMock));
     $this->assertInstanceOf('Magento\\Framework\\View\\Element\\BlockInterface', $this->blockFactory->createBlock($className, $argumentsResult));
 }
Esempio n. 25
0
 public function testCreateWithArguments()
 {
     $className = 'SomeModel';
     $data = ['param1', 'param2'];
     $classMock = $this->getMock('SomeModel');
     $this->_objectManagerMock->expects($this->once())->method('create')->with($className, $data)->will($this->returnValue($classMock));
     $this->assertEquals($classMock, $this->_factory->create($className, $data));
 }
Esempio n. 26
0
 protected function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->responseMock = $this->getMock('Magento\\Authorizenet\\Model\\Response', [], [], '', false);
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface', [], [], '', false);
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Authorizenet\\Model\\Response', [])->willReturn($this->responseMock);
     $this->responseFactory = $objectManager->getObject('Magento\\Authorizenet\\Model\\Response\\Factory', ['objectManager' => $this->objectManagerMock]);
 }
 protected function setUp()
 {
     $this->objectManagerMock = $this->getMockForAbstractClass('Magento\\Framework\\ObjectManagerInterface');
     $this->modeMock = $this->getMock('Magento\\Deploy\\Model\\Mode', [], [], '', false);
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->command = $objectManager->getObject('Magento\\Deploy\\Console\\Command\\SetModeCommand', ['objectManager' => $this->objectManagerMock]);
     $this->objectManagerMock->expects($this->once())->method('create')->willReturn($this->modeMock);
 }
Esempio n. 28
0
 /**
  * @param $index
  * @param $id
  * @return \Magento\Search\Model\Query|\PHPUnit_Framework_MockObject_MockObject
  */
 private function createQuery($index, $id)
 {
     $query = $this->getMockBuilder('Magento\\Search\\Model\\Query')->disableOriginalConstructor()->setMethods(['load', 'delete'])->getMock();
     $query->expects($this->at(0))->method('delete')->will($this->returnSelf());
     $query->expects($this->at(0))->method('load')->with($id)->will($this->returnSelf());
     $this->objectManager->expects($this->at($index))->method('create')->with('Magento\\Search\\Model\\Query')->will($this->returnValue($query));
     return $query;
 }
Esempio n. 29
0
 public function testInitInvalidHandler()
 {
     $handlerConfig = ['class' => 'Migration\\Migration', 'params' => ['value' => '12']];
     $invalidHandler = $this->getMock('Migration\\Migration', [], [], '', false);
     $this->objectManager->expects($this->once())->method('create')->will($this->returnValue($invalidHandler));
     $this->setExpectedException('\\Exception', "'Migration\\Migration' is not correct handler.");
     $this->manager->initHandler('somefield', $handlerConfig);
 }
 public function testCreateByPath()
 {
     $path = 'design/head/default_title';
     $backendModelType = 'Magento\\Theme\\Model\\Design\\Backend\\Exceptions';
     $backendModel = $this->getMockBuilder($backendModelType)->disableOriginalConstructor()->getMock();
     $this->metadataProviderMock->expects($this->once())->method('get')->willReturn(['head_default_title' => ['path' => $path, 'backend_model' => $backendModelType]]);
     $this->objectManagerMock->expects($this->once())->method('create')->with($backendModelType, ['data' => []])->willReturn($backendModel);
     $this->assertEquals($backendModel, $this->model->createByPath($path));
 }