예제 #1
0
 /**
  * Creates click test instance.
  * @return ClickTest click test instance.
  */
 public function getClickTest()
 {
     // init clicktest with required base url param.
     $cookieFile = '/tmp/campmanClickTest';
     @unlink($cookieFile);
     $params = Yii::$app->params;
     $clickTest = new ClickTest($params['baseUrl'], ['formOptions' => [], 'groupUrls' => true, 'createExcepts' => [[['(.*\\/)', false], ['(\\d+)', true]]], 'curlOptions' => ['cookieFile' => $cookieFile, 'unique' => true], 'pageCallback' => [$this, 'checkPage']]);
     $clickTest->selector = 'a:not([href=""])';
     $clickTest->except = array_merge($clickTest->except, ['/log/', '/storage/']);
     // login to your login page with your access data.
     $clickTest->request('/index-test.php/user/default/logout')->login('/index-test.php/user/default/login', ['LoginForm[username]' => $params['auth']['username'], 'LoginForm[password]' => $params['auth']['password']]);
     return $clickTest;
 }
 /**
  * Clicks all app links.
  */
 public function testLinks()
 {
     $params = Yii::$app->params;
     $clickTest = new ClickTest($params['domainName'], ['formOptions' => [], 'groupUrls' => true, 'createExcepts' => [[['(.*\\/)', false], ['(\\d+)', true]]], 'curlOptions' => ['cookieFile' => $params['curlCookieFile']]]);
     $clickTest->selector = 'a:not([href=""])';
     // phpQuery selector for searching urls on pages.
     $clickTest->except[] = '/storage/';
     // exclude url.
     // login to your login page with your access data.
     $clickTest->request('/index/logout')->login('/index/login', ['LoginForm[username]' => $params['auth']['username'], 'LoginForm[password]' => $params['auth']['password'], 'LoginForm[language]' => 'en']);
     $clickTest->clickAllLinks('/');
     // this is the main action - clicking all found urls.
     $clickTest->result();
     // returning result.
 }