protected function setUp() { $this->_objectManager = Mage::getObjectManager(); $this->_model = $this->_objectManager->create('Mage_Index_Model_Process_File'); /** @var $configuration Mage_Core_Model_Config */ $configuration = $this->_objectManager->get('Mage_Core_Model_Config'); $this->_fileDirectory = $configuration->getVarDir('locks'); $fullFileName = $this->_fileDirectory . DIRECTORY_SEPARATOR . self::FILE_NAME; $this->_testFileHandler = fopen($fullFileName, 'w'); }
/** * Assertion of current customer and address data * * @param array $expectedData */ protected function _assertCustomerData(array $expectedData) { /** @var $collection Mage_Customer_Model_Resource_Customer_Collection */ $collection = $this->_objectManager->create('Mage_Customer_Model_Resource_Customer_Collection'); $collection->addAttributeToSelect($this->_customerAttributes); $customers = $collection->getItems(); $this->assertSameSize($expectedData, $customers); /** @var $customer Mage_Customer_Model_Customer */ foreach ($customers as $customer) { // assert customer existence $email = strtolower($customer->getEmail()); $this->assertArrayHasKey($email, $expectedData); // assert customer data (only for required customers) if (isset($expectedData[$email]['data'])) { foreach ($expectedData[$email]['data'] as $attribute => $expectedValue) { $this->assertEquals($expectedValue, $customer->getData($attribute)); } } // assert address data $addresses = $customer->getAddresses(); $this->assertSameSize($expectedData[$email]['addresses'], $addresses); /** @var $address Mage_Customer_Model_Address */ foreach ($addresses as $address) { $this->assertContains($address->getData('postcode'), $expectedData[$email]['addresses']); } } }
/** * @return Mage_Webapi_Model_ConfigAbstract */ protected function _getApiConfig() { if (!self::$_apiConfig) { $objectManager = new Magento_Test_ObjectManager(); /** Prepare arguments for SUT constructor. */ $pathToFixtures = __DIR__ . '/../_files/autodiscovery'; /** @var Mage_Webapi_Model_Config_Reader_Soap $reader */ $reader = $objectManager->get('Mage_Webapi_Model_Config_Reader_Soap'); $reader->setDirectoryScanner(new Zend\Code\Scanner\DirectoryScanner($pathToFixtures)); /** Initialize SUT. */ self::$_apiConfig = $objectManager->create('Mage_Webapi_Model_Config_Soap', array('reader' => $reader)); } return self::$_apiConfig; }
/** * Test negative authentication with used nonce-timestamp pair. * * @expectedException Mage_Webapi_Model_Soap_Security_UsernameToken_NonceUsedException */ public function testAuthenticateWithNonceUsed() { $user = $this->_userFactory->create(); $user->load('test_username', 'api_key'); /** @var Mage_Webapi_Model_Soap_Security_UsernameToken $usernameToken */ $usernameToken = $this->_objectManager->create('Mage_Webapi_Model_Soap_Security_UsernameToken'); $created = date('c'); $nonce = mt_rand(); $password = base64_encode(hash('sha1', $nonce . $created . $user->getSecret(), true)); $nonce = base64_encode($nonce); $authenticatedUser = $usernameToken->authenticate($user->getApiKey(), $password, $created, $nonce); $this->assertEquals($user, $authenticatedUser); // Try to authenticate with the same nonce and timestamp $usernameToken->authenticate($user->getApiKey(), $password, $created, $nonce); }
/** * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category 1 * @magentoDbIsolation enabled */ public function testSaveWithFlatIndexer() { $categoryName = 'Indexer Category Name ' . uniqid(); /** @var $parentCategory Mage_Catalog_Model_Category */ $parentCategory = self::$_objectManager->create('Mage_Catalog_Model_Category'); $parentCategory->load($this->_store->getRootCategoryId()); // init category model with EAV entity resource model $resourceModel = self::$_objectManager->create('Mage_Catalog_Model_Resource_Category'); $this->_model = self::$_objectManager->create('Mage_Catalog_Model_Category', array('resource' => $resourceModel)); $this->_model->setName($categoryName)->setParentId($parentCategory->getId())->setPath($parentCategory->getPath())->setLevel(2)->setPosition(1)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->save(); // check if category record exists in flat table /** @var $collection Mage_Catalog_Model_Resource_Category_Flat_Collection */ $collection = self::$_objectManager->create('Mage_Catalog_Model_Resource_Category_Flat_Collection'); $collection->addFieldToFilter('name', $categoryName); $this->assertCount(1, $collection->getItems()); }
/** * Create resource config initialized with classes found in the specified directory. * * @param string $pathToResources * @return Mage_Webapi_Model_Config_Soap */ protected function _createResourceConfig($pathToResources) { $objectManager = new Magento_Test_ObjectManager(); /** Prepare arguments for SUT constructor. */ /** @var Mage_Core_Model_Cache $cache */ $cache = $this->getMockBuilder('Mage_Core_Model_Cache')->disableOriginalConstructor()->getMock(); /** @var Mage_Webapi_Model_Config_Reader_Soap $reader */ $reader = $objectManager->get('Mage_Webapi_Model_Config_Reader_Soap', array('cache' => $cache)); $reader->setDirectoryScanner(new Zend\Code\Scanner\DirectoryScanner($pathToResources)); /** Initialize SUT. */ $apiConfig = $objectManager->create('Mage_Webapi_Model_Config_Soap', array('reader' => $reader)); return $apiConfig; }
/** * Test for Mage_Webapi_Model_Resource_Acl_Role::getResourceIdsByRole() */ public function testGetResourceIdsByRole() { /** @var Mage_Webapi_Model_Acl_Role $role */ $role = $this->_objectManager->create('Mage_Webapi_Model_Acl_Role')->load('Test role', 'role_name'); $this->assertEquals(array('customer/get'), $this->_ruleResource->getResourceIdsByRole($role->getId())); }
/** * Initialize model */ protected function setUp() { $this->_objectManager = Mage::getObjectManager(); $this->_roleFactory = $this->_objectManager->get('Mage_Webapi_Model_Acl_Role_Factory'); $this->_model = $this->_objectManager->create('Mage_Webapi_Model_Acl_User'); }
/** * Initialize model */ protected function setUp() { $this->_objectManager = Mage::getObjectManager(); $this->_model = $this->_objectManager->create('Mage_Webapi_Model_Acl_Role'); }