Пример #1
0
 protected function setUp()
 {
     $this->context = $this->getMockBuilder('\\Magento\\Framework\\Model\\Resource\\Db\\Context')->disableOriginalConstructor()->getMock();
     $this->resource = $this->getMockBuilder('\\Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->once())->method('getResources')->willReturn($this->resource);
     $this->adapter = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->resource->expects($this->once())->method('getConnection')->with('core_write')->willReturn($this->adapter);
     $objectManager = new ObjectManager($this);
     $this->target = $objectManager->getObject('\\Magento\\CatalogSearch\\Model\\Resource\\Fulltext', ['context' => $this->context]);
 }
Пример #2
0
 protected function setUp()
 {
     $this->context = $this->getMockBuilder('\\Magento\\Framework\\Model\\Resource\\Db\\Context')->disableOriginalConstructor()->getMock();
     $this->resource = $resource = $this->getMockBuilder('\\Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->setMethods(['getConnection', 'getTableName'])->getMock();
     $this->context->expects($this->once())->method('getResources')->willReturn($this->resource);
     $this->connection = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->setMethods(['getIfNullSql'])->getMockForAbstractClass();
     $resource->expects($this->any())->method('getConnection')->with(\Magento\Framework\App\Resource::DEFAULT_WRITE_RESOURCE)->will($this->returnValue($this->connection));
     $objectManager = new ObjectManager($this);
     $this->target = $objectManager->getObject('\\Magento\\CatalogSearch\\Model\\Resource\\Engine', ['context' => $this->context]);
     $this->target;
 }
Пример #3
0
 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\Model\\Resource\\Db\\Context')->disableOriginalConstructor()->getMock();
     $this->scopeConfigMock = $this->getMockBuilder('Magento\\Framework\\App\\Config\\ScopeConfigInterface')->getMock();
     $this->storeManagerMock = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->getMock();
     $this->storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->connectionMock = $this->getMockBuilder('Magento\\Framework\\DB\\Adapter\\AdapterInterface')->getMock();
     $this->resourceMock = $this->getMockBuilder('Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->getMock();
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
     $this->contextMock->expects($this->any())->method('getResources')->willReturn($this->resourceMock);
     $this->event = new Event($this->contextMock, $this->scopeConfigMock, $this->storeManagerMock);
 }
Пример #4
0
 protected function setUp()
 {
     $this->selectMock = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $this->selectMock->expects($this->any())->method('from')->will($this->returnValue($this->selectMock));
     $this->selectMock->expects($this->any())->method('where')->will($this->returnValue($this->selectMock));
     $this->adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->adapterMock->expects($this->any())->method('select')->willReturn($this->selectMock);
     $this->resourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->adapterMock);
     $this->contextMock = $this->getMock('Magento\\Framework\\Model\\Resource\\Db\\Context', [], [], '', false);
     $this->contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock);
     $this->integrationResourceModel = new \Magento\Integration\Model\Resource\Integration($this->contextMock);
 }
Пример #5
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  * @return void
  */
 protected function setUp()
 {
     $this->zendDbMock = $this->getMockBuilder('Zend_Db_Statement_Interface')->getMock();
     $this->zendDbMock->expects($this->any())->method('fetchColumn')->willReturn([]);
     $this->selectMock = $this->getMockBuilder('Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->setMethods(['from', 'where', 'joinInner', 'joinLeft', 'having', 'useStraightJoin', 'insertFromSelect', '__toString'])->getMock();
     $this->selectMock->expects($this->any())->method('from')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('where')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('joinInner')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('joinLeft')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('having')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('useStraightJoin')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('insertFromSelect')->willReturnSelf();
     $this->selectMock->expects($this->any())->method('__toString')->willReturn('string');
     $this->connectionMock = $this->getMockBuilder('Magento\\Framework\\DB\\Adapter\\AdapterInterface')->getMock();
     $this->connectionMock->expects($this->any())->method('select')->willReturn($this->selectMock);
     $this->connectionMock->expects($this->any())->method('query')->willReturn($this->zendDbMock);
     $this->resourceMock = $this->getMockBuilder('Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->getMock();
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
     $this->resourceMock->expects($this->any())->method('getTableName')->will($this->returnCallback(function ($arg) {
         return $arg;
     }));
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\Model\\Resource\\Db\\Context')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getResources')->willReturn($this->resourceMock);
     $this->loggerMock = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
     $dateTime = $this->getMockBuilder('DateTime')->getMock();
     $this->timezoneMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface')->getMock();
     $this->timezoneMock->expects($this->any())->method('scopeDate')->willReturn($dateTime);
     $this->dateTimeMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\DateTime')->getMock();
     $this->flagMock = $this->getMockBuilder('Magento\\Reports\\Model\\Flag')->disableOriginalConstructor()->setMethods(['setReportFlagCode', 'unsetData', 'loadSelf', 'setFlagData', 'setLastUpdate', 'save'])->getMock();
     $this->flagFactoryMock = $this->getMockBuilder('Magento\\Reports\\Model\\FlagFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->flagFactoryMock->expects($this->any())->method('create')->willReturn($this->flagMock);
     $this->validatorMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\DateTime\\Timezone\\Validator')->disableOriginalConstructor()->getMock();
     $this->backendMock = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\AbstractBackend')->disableOriginalConstructor()->getMock();
     $this->attributeMock = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute')->disableOriginalConstructor()->getMock();
     $this->attributeMock->expects($this->any())->method('getBackend')->willReturn($this->backendMock);
     $this->productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Resource\\Product')->disableOriginalConstructor()->getMock();
     $this->productMock->expects($this->any())->method('getAttribute')->willReturn($this->attributeMock);
     $this->helperMock = $this->getMockBuilder('Magento\\Reports\\Model\\Resource\\Helper')->disableOriginalConstructor()->getMock();
     $this->viewed = new Viewed($this->contextMock, $this->loggerMock, $this->timezoneMock, $this->flagFactoryMock, $this->dateTimeMock, $this->validatorMock, $this->productMock, $this->helperMock);
 }
Пример #6
0
 /**
  * Class constructor
  *
  * @param \Magento\Framework\Model\Resource\Db\Context $context
  * @param string|null $resourcePrefix
  */
 public function __construct(\Magento\Framework\Model\Resource\Db\Context $context, $resourcePrefix = null)
 {
     $this->transactionManager = $context->getTransactionManager();
     $this->_resources = $context->getResources();
     $this->objectRelationProcessor = $context->getObjectRelationProcessor();
     if ($resourcePrefix !== null) {
         $this->_resourcePrefix = $resourcePrefix;
     }
     parent::__construct();
 }
Пример #7
0
    public function testInstall()
    {
        $request = [
            SetupConfigOptionsList::INPUT_KEY_DB_HOST => '127.0.0.1',
            SetupConfigOptionsList::INPUT_KEY_DB_NAME => 'magento',
            SetupConfigOptionsList::INPUT_KEY_DB_USER => 'magento',
            SetupConfigOptionsList::INPUT_KEY_ENCRYPTION_KEY => 'encryption_key',
            BackendConfigOptionsList::INPUT_KEY_BACKEND_FRONTNAME => 'backend',
        ];
        $this->config->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true);
        $allModules = ['Foo_One' => [], 'Bar_Two' => []];
        $this->moduleLoader->expects($this->any())->method('load')->willReturn($allModules);
        $setup = $this->getMock('Magento\Setup\Module\Setup', [], [], '', false);
        $table = $this->getMock('Magento\Framework\DB\Ddl\Table', [], [], '', false);
        $connection = $this->getMockForAbstractClass('Magento\Framework\DB\Adapter\AdapterInterface');
        $setup->expects($this->any())->method('getConnection')->willReturn($connection);
        $table->expects($this->any())->method('addColumn')->willReturn($table);
        $table->expects($this->any())->method('setComment')->willReturn($table);
        $table->expects($this->any())->method('addIndex')->willReturn($table);
        $connection->expects($this->any())->method('newTable')->willReturn($table);
        $resource = $this->getMock('Magento\Framework\App\Resource', [], [], '', false);
        $this->contextMock->expects($this->any())->method('getResources')->willReturn($resource);
        $resource->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
        $dataSetup = $this->getMock('Magento\Setup\Module\DataSetup', [], [], '', false);
        $cacheManager = $this->getMock('Magento\Framework\App\Cache\Manager', [], [], '', false);
        $cacheManager->expects($this->once())->method('getAvailableTypes')->willReturn(['foo', 'bar']);
        $cacheManager->expects($this->once())->method('setEnabled')->willReturn(['foo', 'bar']);
        $appState = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject(
            'Magento\Framework\App\State'
        );
        $this->objectManager->expects($this->any())
            ->method('create')
            ->will($this->returnValueMap([
                ['Magento\Setup\Module\Setup', ['resource' => $resource], $setup],
                ['Magento\Setup\Module\DataSetup', [], $dataSetup],
                ['Magento\Framework\App\Cache\Manager', [], $cacheManager],
                ['Magento\Framework\App\State', [], $appState],
            ]));
        $this->objectManager->expects($this->any())
            ->method('get')
            ->will($this->returnValueMap([
                ['Magento\Framework\App\State', $appState],
            ]));
        $this->adminFactory->expects($this->once())->method('create')->willReturn(
            $this->getMock('Magento\Setup\Model\AdminAccount', [], [], '', false)
        );

        $this->logger->expects($this->at(0))->method('log')->with('Starting Magento installation:');
        $this->logger->expects($this->at(1))->method('log')->with('File permissions check...');
        // at(2) invokes logMeta()
        $this->logger->expects($this->at(3))->method('log')->with('Enabling Maintenance Mode...');
        // at(4) - logMeta and so on...
        $this->logger->expects($this->at(5))->method('log')->with('Installing deployment configuration...');
        $this->logger->expects($this->at(7))->method('log')->with('Installing database schema:');
        $this->logger->expects($this->at(9))->method('log')->with("Module 'Foo_One':");
        $this->logger->expects($this->at(11))->method('log')->with("Module 'Bar_Two':");
        $this->logger->expects($this->at(13))->method('log')->with('Schema post-updates:');
        $this->logger->expects($this->at(14))->method('log')->with("Module 'Foo_One':");
        $this->logger->expects($this->at(16))->method('log')->with("Module 'Bar_Two':");
        $this->logger->expects($this->at(19))->method('log')->with('Installing user configuration...');
        $this->logger->expects($this->at(21))->method('log')->with('Installing data...');
        $this->logger->expects($this->at(22))->method('log')->with('Data install/update:');
        $this->logger->expects($this->at(23))->method('log')->with("Module 'Foo_One':");
        $this->logger->expects($this->at(25))->method('log')->with("Module 'Bar_Two':");
        $this->logger->expects($this->at(28))->method('log')->with('Installing admin user...');
        $this->logger->expects($this->at(30))->method('log')->with('Enabling caches:');
        $this->logger->expects($this->at(31))->method('log')->with('Current status:');
        $this->logger->expects($this->at(34))->method('log')->with('Disabling Maintenance Mode:');
        $this->logger->expects($this->at(36))->method('log')->with('Post installation file permissions check...');
        $this->logger->expects($this->at(38))->method('logSuccess')->with('Magento installation complete.');
        $this->object->install($request);
    }
Пример #8
0
 /**
  * Creates admin account
  *
  * @param \ArrayObject|array $data
  * @return void
  */
 public function installAdminUser($data)
 {
     $this->assertDeploymentConfigExists();
     $setup = $this->objectManagerProvider->get()->create('Magento\\Setup\\Module\\Setup', ['resource' => $this->context->getResources()]);
     $adminAccount = $this->adminAccountFactory->create($setup, (array) $data);
     $adminAccount->save();
 }
Пример #9
0
 protected function getTableName()
 {
     return $this->dbContext->getResources()->getTableName('cotya_queue');
 }