Example #1
0
 public function testHttpAuth()
 {
     $this->module->amOnPage('/auth');
     $this->module->see('Unauthorized');
     $this->module->amHttpAuthenticated('davert', 'password');
     $this->module->amOnPage('/auth');
     $this->module->dontSee('Unauthorized');
     $this->module->see("Welcome, davert");
     $this->module->amHttpAuthenticated('davert', '123456');
     $this->module->amOnPage('/auth');
     $this->module->see('Forbidden');
 }
 public function testMoveBackThrowsExceptionIfNumberOfStepsIsInvalid()
 {
     $this->module->amOnPage('/iframe');
     $this->module->switchToIframe('content');
     $this->module->seeCurrentUrlEquals('/info');
     $this->module->click('Ссылочка');
     $this->module->seeCurrentUrlEquals('/');
     $invalidValues = [0, -5, 1.5, 'a', 3];
     foreach ($invalidValues as $invalidValue) {
         try {
             $this->module->moveBack($invalidValue);
             $this->fail('Expected to get exception here');
         } catch (\InvalidArgumentException $e) {
             codecept_debug('Exception: ' . $e->getMessage());
         }
     }
 }
Example #3
0
 /**
  * Converting $page to valid Yii 2 URL
  * 
  * Allows input like:
  * 
  * ```php
  * $I->amOnPage(['site/view','page'=>'about']);
  * $I->amOnPage('index-test.php?site/index');
  * $I->amOnPage('http://localhost/index-test.php?site/index');
  * ```
  * 
  * @param $page string|array parameter for \yii\web\UrlManager::createUrl()
  */
 public function amOnPage($page)
 {
     if (is_array($page)) {
         $page = Yii::$app->getUrlManager()->createUrl($page);
     }
     parent::amOnPage($page);
 }
Example #4
0
 public function testExceptionIsThrownOnRedirectToExternalUrl()
 {
     $this->setExpectedException('\\Codeception\\Exception\\ExternalUrlException');
     $this->module->amOnPage('/external_url');
     $this->module->click('Next');
 }