/** * Get all test helper class names * @return array */ public function getTestHelperClassNames() { if (!empty($this->_testHelperClassNames)) { return $this->_testHelperClassNames; } //Get initial path to test helpers $frameworkConfig = $this->_configHelper->getConfigFramework(); $initialPath = SELENIUM_TESTS_BASEDIR . DIRECTORY_SEPARATOR . $frameworkConfig['testsuite_base_path']; //Get test helpers sequence $fallbackOrderHelper = $this->_configHelper->getHelpersFallbackOrder(); $facade = new File_Iterator_Facade(); foreach ($fallbackOrderHelper as $codePoolName) { $projectPath = $initialPath . DIRECTORY_SEPARATOR . $codePoolName; if (!is_dir($projectPath)) { continue; } $files = $facade->getFilesAsArray($projectPath, 'Helper.php'); foreach ($files as $file) { $className = str_replace($initialPath . DIRECTORY_SEPARATOR, '', $file); $className = str_replace(DIRECTORY_SEPARATOR, '_', str_replace('.php', '', $className)); $array = explode('_', str_replace('_Helper', '', $className)); $helperName = end($array); $this->_testHelperClassNames[$helperName] = $className; } } return $this->_testHelperClassNames; }
/** * Initializes new driver connection with specific configuration * * @param array $browser * * @return Mage_Selenium_Driver * @throws InvalidArgumentException */ public function addDriverConnection(array $browser) { if (!isset($browser['name'])) { $browser['name'] = ''; } if (!isset($browser['browser'])) { $browser['browser'] = ''; } if (!isset($browser['host'])) { $browser['host'] = 'localhost'; } if (!isset($browser['port'])) { $browser['port'] = 4444; } if (!isset($browser['timeout'])) { $browser['timeout'] = 30; } if (!isset($browser['httpTimeout'])) { $browser['httpTimeout'] = 45; } if (!isset($browser['restartBrowser'])) { $browser['restartBrowser'] = true; } $driver = new Mage_Selenium_Driver(); $driver->setLogHandle($this->getHelper('config')->getLogDir()); $driver->setName($browser['name']); $driver->setBrowser($browser['browser']); $driver->setHost($browser['host']); $driver->setPort($browser['port']); $driver->setTimeout($browser['timeout']); $driver->setHttpTimeout($browser['httpTimeout']); $driver->setContiguousSession($browser['restartBrowser']); $driver->setBrowserUrl($this->_configHelper->getBaseUrl()); return $driver; }
/** * Logs in as a default admin user on back-end * @return Mage_Selenium_TestCase */ public function loginAdminUser() { $this->admin('log_in_to_admin', false); $loginData = array('user_name' => $this->_configHelper->getDefaultLogin(), 'password' => $this->_configHelper->getDefaultPassword()); if ($this->_findCurrentPageFromUrl() != $this->_firstPageAfterAdminLogin) { $this->validatePage('log_in_to_admin'); $dashboardLogo = $this->_getControlXpath('pageelement', 'admin_logo'); // $closeButton = $this->_getControlXpath('button', 'close'); $this->fillFieldset($loginData, 'log_in'); $this->clickButton('login', false); $this->waitForElement(array($dashboardLogo, $this->_getMessageXpath('general_error'), $this->_getMessageXpath('general_validation'))); // if ($this->controlIsPresent('link', 'go_to_notifications') && $this->waitForElement($closeButton, 5)) { // $this->click($closeButton); // } } $this->validatePage($this->_firstPageAfterAdminLogin); return $this; }
/** * Logs in as a default admin user on back-end * @return Mage_Selenium_TestCase */ public function loginAdminUser() { $this->admin('log_in_to_admin', false); $loginData = array('user_name' => $this->_configHelper->getDefaultLogin(), 'password' => $this->_configHelper->getDefaultPassword()); $currentPage = $this->_findCurrentPageFromUrl($this->getLocation()); if ($currentPage != $this->_firstPageAfterAdminLogin) { $this->validatePage('log_in_to_admin'); $this->fillForm($loginData); $this->clickButton('login', false); $this->waitForElement(array(self::$xpathAdminLogo, self::$xpathErrorMessage, self::$xpathValidationMessage)); if ($this->_findCurrentPageFromUrl($this->getLocation()) != $this->_firstPageAfterAdminLogin) { $this->fail('Admin was not logged in'); } if ($this->isElementPresent(self::$xpathGoToNotifications) && $this->waitForElement(self::$xpathIncomingMessageClose, 5)) { $this->click(self::$xpathIncomingMessageClose); } $this->validatePage($this->_firstPageAfterAdminLogin); } return $this; }
/** * @covers Mage_Selenium_Helper_Config::setLogDir * @depends testGetSetLogDir */ public function testSetLogDirInvalidParameterException() { $configHelper = new Mage_Selenium_Helper_Config($this->_config); $this->setExpectedException('PHPUnit_Framework_Error_Warning', 'mkdir():'); $configHelper->setLogDir(null); }