/** * @expectedException Mollie_API_Exception * @expectedExceptionMessage You have not set an API key. Please use setApiKey() to set the API key. */ public function testNotSettingApiKeyGivesException() { $this->api = $this->getMock("Mollie_API_Client", array('getCompatibilityChecker'), array(), '', FALSE); $this->api->expects($this->any())->method("getCompatibilityChecker")->will($this->returnValue($this->compatibilityChecker)); $this->api->__construct(); $this->api->payments->all(); }
/** * @test */ public function constructorRemovesExpiredLockFiles() { $this->mockLockFlagFile->lastModified(time() - (LockManager::LOCKFILE_MAXIMUM_AGE + 1)); $this->assertFileExists($this->mockLockFile->url()); $this->assertFileExists($this->mockLockFlagFile->url()); $this->lockManager->__construct(); $this->assertFileNotExists($this->mockLockFile->url()); $this->assertFileNotExists($this->mockLockFlagFile->url()); }
/** * @test */ public function getCacheIdentifierReturnsValidIdentifierWithCommasInMountPointParameter() { /** @var \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend $cacheFrontendMock */ $cacheFrontendMock = $this->getMockForAbstractClass(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class, array(), '', false); $this->pageContextMock->sys_language_uid = 8; $this->pageContextMock->versioningWorkspaceId = 15; $this->pageContextMock->versioningPreview = true; $this->subject->__construct(42, '47-11,48-12', $this->pageContextMock); $this->assertTrue($cacheFrontendMock->isValidEntryIdentifier($this->subject->getCacheIdentifier())); }
/** * @param array $fixtureSettings * @return \Magento\TestFramework\Application|PHPUnit_Framework_MockObject_MockObject */ protected function _injectApplicationMock(array $fixtureSettings = array()) { $fixtureSettings += $this->_requiredSettings; $application = $this->getMock('Magento\\TestFramework\\Application', array('cleanup', 'isInstalled', 'initialize', 'install'), array(), '', false); $settings = new \Magento\TestFramework\Bootstrap\Settings($this->_integrationTestsDir, $fixtureSettings); // prevent calling the constructor because of mocking the method it invokes $this->_object = $this->getMock('Magento\\TestFramework\\Bootstrap', array('_createApplication', '_createMemoryBootstrap'), array(), '', false); $this->_object->expects($this->any())->method('_createApplication')->will($this->returnValue($application)); // invoke the constructor explicitly $this->_object->__construct($settings, $this->_envBootstrap, $this->_docBlockBootstrap, $this->_profilerBootstrap, $this->_shell, __DIR__); $this->_object->expects($this->any())->method('_createMemoryBootstrap')->will($this->returnValue($this->_memoryBootstrap)); return $application; }
/** * @dataProvider accessCheckDataProvider * @param $checkArray * @test */ public function accessChecksWorksAsExpected($checkArray) { $this->fixture->expects($this->any())->method('getExtensionConfiguration')->will($this->returnValue(array('enableGroupCheck' => '1', 'groupCheckDirs' => $checkArray['groupCheckDirs'], 'excludeGroups' => $checkArray['excludedGroups']))); $fakeUser = new \stdClass(); $fakeUser->groupData['uid'] = $checkArray['actualGroups']; $fakeUser->user['uid'] = $checkArray['actualUser']; $this->fixture->_set('feUserObj', $fakeUser); $this->fixture->_set('file', $checkArray['file']); $this->fixture->_set('userGroups', $checkArray['transmittedGroups']); $this->fixture->_set('userId', $checkArray['transmittedUser']); $_GET['g'] = $checkArray['transmittedGroups']; $_GET['u'] = $checkArray['transmittedUser']; $this->fixture->expects($this->once())->method('exitScript')->with('Access denied for User!'); $this->fixture->__construct(); }
/** * Explicitly call the constructor method of the underlying bootstrap object * * @param string|null $localXmlFile * @param string $cleanupAction */ protected function _callBootstrapConstructor($localXmlFile = null, $cleanupAction = Magento_Test_Bootstrap::CLEANUP_NONE) { $this->_bootstrap->__construct(self::$_magentoDir, $localXmlFile ? $localXmlFile : self::$_localXmlFile, self::$_globalEtcFiles, self::$_moduleEtcFiles, '', self::$_tmpDir, $cleanupAction); }
/** * Set Up */ protected function setUp() { $this->localeDate = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\Timezone', [], [], '', false); $this->config = $this->getMock('Magento\\Eav\\Model\\Config', ['getEntityType'], [], '', false); $type = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Type', [], [], '', false); $this->config->expects($this->once())->method('getEntityType')->willReturn($type); $this->resource = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false); $this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false); $this->logger = $this->getMock('Magento\\Framework\\Logger\\Monolog', [], [], '', false); $this->collection = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product\\CollectionFactory', [], [], '', false); $this->abstractCollection = $this->getMockForAbstractClass('\\Magento\\Eav\\Model\\Entity\\Collection\\AbstractCollection', [], '', false, true, true, ['count', 'setOrder', 'setStoreId', 'getCurPage', 'getLastPageNumber']); $this->exportConfig = $this->getMock('Magento\\ImportExport\\Model\\Export\\Config', [], [], '', false); $this->productFactory = $this->getMock('Magento\\Catalog\\Model\\Resource\\ProductFactory', ['create', 'getTypeId'], [], '', false); $this->attrSetColFactory = $this->getMock('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\CollectionFactory', ['create', 'setEntityTypeFilter'], [], '', false); $this->categoryColFactory = $this->getMock('Magento\\Catalog\\Model\\Resource\\Category\\CollectionFactory', ['create', 'addNameToResult'], [], '', false); $this->itemFactory = $this->getMock('Magento\\CatalogInventory\\Model\\Resource\\Stock\\ItemFactory', [], [], '', false); $this->optionColFactory = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Option\\CollectionFactory', [], [], '', false); $this->attributeColFactory = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Attribute\\CollectionFactory', [], [], '', false); $this->typeFactory = $this->getMock('Magento\\CatalogImportExport\\Model\\Export\\Product\\Type\\Factory', [], [], '', false); $this->linkTypeProvider = $this->getMock('Magento\\Catalog\\Model\\Product\\LinkTypeProvider', [], [], '', false); $this->rowCustomizer = $this->getMock('Magento\\CatalogImportExport\\Model\\Export\\RowCustomizer\\Composite', [], [], '', false); $this->storeResolver = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\StoreResolver', [], [], '', false); $this->groupRepository = $this->getMock('\\Magento\\Customer\\Api\\GroupRepositoryInterface', [], [], '', false); $this->writer = $this->getMock('Magento\\ImportExport\\Model\\Export\\Adapter\\AbstractAdapter', ['setHeaderCols', 'writeRow', 'getContents'], [], '', false); $constructorMethods = ['initTypeModels', 'initAttributes', '_initStores', 'initAttributeSets', 'initWebsites', 'initCategories']; $mockMethods = array_merge($constructorMethods, ['_customHeadersMapping', '_prepareEntityCollection', '_getEntityCollection', 'getWriter', 'getExportData', '_headerColumns', '_customFieldsMapping', 'getItemsPerPage', 'paginateCollection', '_getHeaderColumns']); $this->advancedPricing = $this->getMock('Magento\\AdvancedPricingImportExport\\Model\\Export\\AdvancedPricing', $mockMethods, [], '', false); foreach ($constructorMethods as $method) { $this->advancedPricing->expects($this->once())->method($method)->will($this->returnSelf()); } $this->advancedPricing->__construct($this->localeDate, $this->config, $this->resource, $this->storeManager, $this->logger, $this->collection, $this->exportConfig, $this->productFactory, $this->attrSetColFactory, $this->categoryColFactory, $this->itemFactory, $this->optionColFactory, $this->attributeColFactory, $this->typeFactory, $this->linkTypeProvider, $this->rowCustomizer, $this->storeResolver, $this->groupRepository); }
/** * @dataProvider getTimersDataProvider */ public function testGetTimers($filter, $expectedTimers) { $this->_object->__construct($filter); $actualTimers = $this->_timersGetter->invoke($this->_object); $this->assertEquals($expectedTimers, $actualTimers); }
/** * @test override getTimeout set default option value */ public function setTimeout() { $this->command->expects($this->any())->method('getDefaultTimeout')->will($this->returnValue(10)); $this->command->__construct('dispatch'); $this->assertEquals(10, $this->command->getDefinition()->getOption('timeout')->getDefault()); }
/** * Test that only valid resource instance can be passed to the constructor * * @expectedException InvalidArgumentException */ public function testConstructorException() { $this->_model->__construct(array('resource' => new stdClass())); }
public function testConstructor() { $this->_shell->expects($this->once())->method('execute')->with('php --version'); $this->_object->__construct($this->_shell); }
/** * Explicitly call the constructor method of the underlying bootstrap object * * @param string|null $localXmlFile * @param bool $isCleanupEnabled */ protected function _callBootstrapConstructor($localXmlFile = null, $isCleanupEnabled = false) { $this->_bootstrap->__construct(self::$_magentoDir, self::$_testsDir, $localXmlFile ? $localXmlFile : self::$_localXmlFile, self::$_globalEtcFiles, self::$_moduleEtcFiles, '', self::$_tmpDir, $this->_shell, $isCleanupEnabled); }