/** * @param Config $configuration */ public function __construct(Config $configuration = null) { if (!isset($configuration)) { $configuration = new Config(); } $this->_scope = $configuration->getConfigParam('application/reopen_browser_on') ?: static::SCOPE_TEST_CASE; }
/** * Create Object Manager * * @param array $sharedInstances * @return ObjectManager */ public function create(array $sharedInstances = []) { if (!defined('MTF_BP')) { $basePath = str_replace('\\', '/', dirname(dirname(__DIR__))); define('MTF_BP', $basePath); } if (!defined('MTF_TESTS_PATH')) { define('MTF_TESTS_PATH', MTF_BP . '/tests/app/'); } if (!defined('MTF_STATES_PATH')) { define('MTF_STATES_PATH', MTF_BP . '/lib/Mtf/App/State/'); } $diConfig = new $this->configClassName(); $systemConfig = new SystemConfig(); $configuration = $systemConfig->getConfigParam(); $diConfig->extend($configuration); $directories = isset($arguments[\Magento\Framework\App\Filesystem::PARAM_APP_DIRS]) ? $arguments[\Magento\Framework\App\Filesystem::PARAM_APP_DIRS] : array(); $directoryList = new \Magento\Framework\App\Filesystem\DirectoryList(realpath(MTF_BP . '../../../../'), $directories); (new \Magento\Framework\Autoload\IncludePath())->addIncludePath(array($directoryList->getDir(\Magento\Framework\App\Filesystem::GENERATION_DIR))); $factory = new Factory($diConfig); $argInterpreter = $this->createArgumentInterpreter(new BooleanUtils()); $argumentMapper = new \Magento\Framework\ObjectManager\Config\Mapper\Dom($argInterpreter); $sharedInstances['Magento\\Framework\\ObjectManager\\Config\\Mapper\\Dom'] = $argumentMapper; $objectManager = new $this->locatorClassName($factory, $diConfig, $sharedInstances); $factory->setObjectManager($objectManager); ObjectManager::setInstance($objectManager); self::configure($objectManager); return $objectManager; }
/** * @param \Mtf\System\Isolation\Driver $driver * @param null|\Mtf\System\Config $configuration */ public function __construct(Driver $driver, $configuration = null) { if (!isset($configuration)) { $configuration = new Config(); } $this->_driver = $driver; $this->_lastDefaultModes = [self::SCOPE_TEST_SUITE => $configuration->getConfigParam('isolation/' . self::SCOPE_TEST_SUITE), self::SCOPE_TEST_CASE => $configuration->getConfigParam('isolation/' . self::SCOPE_TEST_CASE), self::SCOPE_TEST => $configuration->getConfigParam('isolation/' . self::SCOPE_TEST)]; }
/** * Authorize customer on backend */ protected function _authorize() { $credentials = $this->_configuration->getConfigParam('application/backend_user_credentials'); $url = $_ENV['app_backend_url'] . $this->_configuration->getConfigParam('application/backend_login_url'); $data = array('login[username]' => $credentials['login'], 'login[password]' => $credentials['password']); $this->_transport->write(CurlInterface::POST, $url, '1.0', array(), $data); $response = $this->read(); if (strpos($response, 'page-login')) { throw new \Exception('Admin user cannot be logged in by curl handler!'); } }
/** * Open new browser * This will lead to clean browser session * * @return void */ public function reopen() { $this->_eventManager->dispatchEvent(['reopen'], [__METHOD__]); $this->_driver->stop(); $this->_driver->setSessionStrategy('isolated'); $this->_init(); if ($sessionStrategy = $this->_configuration->getConfigParam('server/selenium/sessionStrategy')) { $this->_driver->setSessionStrategy($sessionStrategy); } }
/** * Get the API token for admin * * @return string|bool */ protected function getAdminToken() { $credentials = $this->configuration->getConfigParam('application/backend_user_credentials'); if (!$credentials || !isset($_ENV['app_frontend_url'])) { return false; } $url = $_ENV['app_frontend_url'] . $this->adminTokenUrl; $data = ['username' => $credentials['login'], 'password' => $credentials['password']]; $headers = ['Content-Type: application/json']; $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); if (!$response) { return $response; } return json_decode($response); }
/** * Constructor * * @param Config $config * @param null $customLogDirectory */ public function __construct(\Mtf\System\Config $config, $customLogDirectory = null) { $logDirectoryFallback = [$customLogDirectory, $config->getEnvironmentValue(static::LOG_DIR_PARAM), $this->getRootPath()]; $this->resolveLogDirectory($logDirectoryFallback); }
/** * Constructor * * @constructor * @param Config $config * @param EventManager $eventManager */ public function __construct(Config $config, EventManager $eventManager) { $this->timeout = $config->getConfigParam('server/selenium/seleniumServerRequestsTimeout', 10) * 1000; $this->eventManager = $eventManager; }
/** * Constructor * * @constructor */ public function __construct() { $config = new Config(); $this->_resetUrl = $_ENV['app_frontend_url'] . $config->getConfigParam('isolation/reset_url_path'); }