Beispiel #1
0
 /**
  *
  * @param \tests\codeception\frontend\FunctionalTester $I
  * @param \Codeception\Scenario $scenario
  */
 public function testUserSignup($I, $scenario)
 {
     $I->wantTo('ensure that signup works');
     $signupPage = SignupPage::openBy($I);
     $I->see('Signup', 'h1');
     $I->see('Please fill out the following fields to signup:');
     $I->amGoingTo('submit signup form with no data');
     $signupPage->submit([]);
     $I->expectTo('see validation errors');
     $I->see('Username cannot be blank.', '.help-block');
     $I->see('Email cannot be blank.', '.help-block');
     $I->see('Password cannot be blank.', '.help-block');
     $I->amGoingTo('submit signup form with not correct email');
     $signupPage->submit(['username' => 'tester', 'email' => 'tester.email', 'password' => 'tester_password']);
     $I->expectTo('see that email address is wrong');
     $I->dontSee('Username cannot be blank.', '.help-block');
     $I->dontSee('Password cannot be blank.', '.help-block');
     $I->see('Email is not a valid email address.', '.help-block');
     $I->amGoingTo('submit signup form with correct email');
     $signupPage->submit(['username' => 'tester', 'email' => '*****@*****.**', 'password' => 'tester_password']);
     $I->expectTo('see that user is created');
     $I->seeRecord('common\\models\\User', ['username' => 'tester', 'email' => '*****@*****.**']);
     $I->expectTo('see that user logged in');
     $I->seeLink('Logout (tester)');
 }
Beispiel #2
0
 /**
  * @param FunctionalTester $I
  */
 public function testProtected(FunctionalTester $I)
 {
     Media::findOne(1)->updateAttributes(['password' => 'mediapassword']);
     $I->wantTo('ensure that protected media works');
     $mediaView = MediaViewPage::openBy($I);
     $I->see('Test Media', 'h1');
     $I->amGoingTo('submit password form with incorrect password');
     $mediaView->submitPassword('wrong_password');
     $I->expectTo('not see the media');
     $I->dontSeeElement('.entry-meta');
     $I->amGoingTo('submit password form with correct password');
     $mediaView->submitPassword('mediapassword');
     $I->expectTo('see the post');
     $I->seeElement('.entry-meta');
     $I->seeLink('Test Media');
     Media::findOne(1)->updateAttributes(['password' => '']);
 }
Beispiel #3
0
 /**
  * @param FunctionalTester $I
  */
 public function testView(FunctionalTester $I)
 {
     $I->wantTo('ensure that term view page works');
     $I->amOnPage(Url::to(['/term/view', 'id' => 1]));
     $I->see('Category: Sample Category', 'h1');
     $I->seeLink('Sample Post');
     $I->amOnPage(Url::to(['/term/view', 'termslug' => 'sample-category']));
     $I->see('Category: Sample Category', 'h1');
     $I->seeLink('Sample Post');
 }
Beispiel #4
0
 /**
  * @param FunctionalTester $I
  */
 public function testView(FunctionalTester $I)
 {
     $I->wantTo('ensure that user view page works');
     $I->amOnPage(Url::to(['/user/view', 'id' => 1]));
     $I->see('All Posts By Super Administrator', 'h1');
     $I->seeLink('Sample Post');
     $I->amOnPage(Url::to(['/user/view', 'user' => 'superadmin']));
     $I->see('All Posts By Super Administrator', 'h1');
     $I->seeLink('Sample Post');
 }
 public function testArticleView(FunctionalTester $I)
 {
     $I->amOnPage(['article/view', 'slug' => 'test-article-1']);
     $I->canSee('Test Article 1', 'h1');
     $I->canSee('Lorem ipsum');
     $I->canSeeElement("//a[contains(@href,'attachment-download')]");
     $I->amOnPage(['article/view', 'slug' => 'unknown-article']);
     $I->canSee('404');
 }
Beispiel #6
0
 public function testArticleView(FunctionalTester $I)
 {
     $I->amOnPage(['article/view', 'slug' => 'test-article-1']);
     $I->canSee('Test Article 1', 'h1');
     $I->canSee('Lorem ipsum');
     $I->canSeeLink('Test File', 'http://example.org/test-file.png');
     $I->amOnPage(['article/view', 'slug' => 'unknown-article']);
     $I->canSee('404');
 }
<?php

use tests\codeception\frontend\FunctionalTester;
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that home page works');
$I->amOnPage(Yii::$app->homeUrl);
$I->see('My Company');
$I->seeLink('About');
$I->click('About');
$I->see('This is the About page.');
Beispiel #8
0
<?php

use tests\codeception\frontend\FunctionalTester;
use tests\codeception\frontend\_pages\AboutPage;
/* @var $scenario Codeception\Scenario */
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that about works');
AboutPage::openBy($I);
$I->see('About', 'h1');
Beispiel #9
0
<?php

use tests\codeception\frontend\FunctionalTester;
use tests\codeception\frontend\_pages\SiteLoginPage;
$I = new FunctionalTester($scenario);
$I->wantTo('Войти на страницу входа пользователя.');
SiteLoginPage::openBy($I);
$I->seeElement('.main-login');
Beispiel #10
0
<?php

use tests\codeception\frontend\FunctionalTester;
use tests\codeception\frontend\_pages\UserListPage;
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that reading the user-list works');
$I->amGoingTo('not filter the list of users');
$userListPage = UserListPage::openBy($I, ['term' => '']);
$I->expectTo('see all users');
$I->see('HSINC');
$I->see('bwoester');
$I->amGoingTo('filter the list of users');
$userListPage = UserListPage::openBy($I, ['term' => 'b']);
$I->expectTo('not see HSINC');
$I->expectTo('see bwoester');
$I->dontSee('HSINC');
$I->see('bwoester');
Beispiel #11
0
<?php

use tests\codeception\frontend\FunctionalTester;
use tests\codeception\common\_pages\AccesoPage;
/* @var $scenario Codeception\Scenario */
$I = new FunctionalTester($scenario);
$I->wantTo('asegurar que la pagina inicio de sesión funciona');
$loginPage = AccesoPage::openBy($I);
$I->amGoingTo('intentar acceder sin datos');
$loginPage->login('', '');
$I->expectTo('ver errores validacion');
$I->see('Correo no puede estar vacio', '.error-block');
$I->see('Clave no puede estar vacio', '.error-block');
$I->amGoingTo('intentar acceder con credenciales incorrectas');
$I->expectTo('ver errores validacion');
$loginPage->login('admin', 'wrong');
$I->expectTo('ver errores validacion');
$I->see('Usuario o clave es incorrecto.', '.error-block');
$I->amGoingTo('acceder con credenciales correctas');
$loginPage->login('erau', 'password_0');
$I->expectTo('ver que el usuario accede');
//$I->seeLink('Logout (erau)');
$I->dontSeeLink('Crear cuenta');
$I->dontSeeLink('Iniciar sesión');
<?php

use tests\codeception\frontend\FunctionalTester;
/* @var $scenario Codeception\Scenario */
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that home page works');
$I->amOnPage(Yii::$app->homeUrl);
$I->see('My Yii Application');
$I->seeLink('Sing in');
$I->click('Sing in');
$I->see('Sign in to start your session');
Beispiel #13
0
 /**
  * @param FunctionalTester $I
  */
 public function testSearch(FunctionalTester $I)
 {
     $I->wantTo('ensure that search page works');
     $I->amOnPage(\Yii::$app->homeUrl);
     $I->submitForm('#sidebar .form-search', ['s' => 'test12345qwerty']);
     if (method_exists($I, 'wait')) {
         $I->wait(3);
     }
     $I->see('Not Found (#404)', 'h1');
     $I->submitForm('#sidebar .form-search', ['s' => 'sample post']);
     if (method_exists($I, 'wait')) {
         $I->wait(3);
     }
     $I->seeLink('Sample Post');
 }
<?php

use tests\codeception\frontend\FunctionalTester;
/* @var $scenario Codeception\Scenario */
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that home page works');
$I->amOnPage(Yii::$app->homeUrl);
$I->see('Yii2 Starter Kit');
$I->seeLink('About');
$I->click('About');
$I->see('Lorem ipsum');
Beispiel #15
0
<?php

use tests\codeception\frontend\FunctionalTester;
/* @var $scenario Codeception\Scenario */
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that home page works');
$I->amOnPage(Yii::$app->homeUrl);
$I->see('Реклама');
$I->seeLink('Вход');
$I->click('Вход');
$I->see('Авторизация');
<?php

use tests\codeception\frontend\FunctionalTester;
use tests\codeception\frontend\_pages\ContactPage;
/* @var $scenario Codeception\Scenario */
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that contact works');
$contactPage = ContactPage::openBy($I);
$I->see('Contact', 'h1');
$I->amGoingTo('submit contact form with no data');
$contactPage->submit([]);
$I->expectTo('see validations errors');
$I->see('Contact', 'h1');
$I->see('Name cannot be blank', '.help-block');
$I->see('Email cannot be blank', '.help-block');
$I->see('Subject cannot be blank', '.help-block');
$I->see('Body cannot be blank', '.help-block');
$I->see('The verification code is incorrect', '.help-block');
$I->amGoingTo('submit contact form with not correct email');
$contactPage->submit(['name' => 'tester', 'email' => 'tester.email', 'subject' => 'test subject', 'body' => 'test content', 'verifyCode' => 'testme']);
$I->expectTo('see that email address is wrong');
$I->dontSee('Name cannot be blank', '.help-block');
$I->see('Email is not a valid email address.', '.help-block');
$I->dontSee('Subject cannot be blank', '.help-block');
$I->dontSee('Body cannot be blank', '.help-block');
$I->dontSee('The verification code is incorrect', '.help-block');
$I->amGoingTo('submit contact form with correct data');
$contactPage->submit(['name' => 'tester', 'email' => '*****@*****.**', 'subject' => 'test subject', 'body' => 'test content', 'verifyCode' => 'testme']);
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
Beispiel #17
0
<?php

use tests\codeception\frontend\FunctionalTester;
use tests\codeception\common\_pages\LoginPage;
/* @var $scenario Codeception\Scenario */
$I = new FunctionalTester($scenario);
$I->wantTo('ensure login page works');
$loginPage = LoginPage::openBy($I);
$I->amGoingTo('submit login form with no data');
$loginPage->login('', '');
$I->expectTo('see validations errors');
$I->see('Username cannot be blank.', '.help-block');
$I->see('Password cannot be blank.', '.help-block');
$I->amGoingTo('try to login with wrong credentials');
$I->expectTo('see validations errors');
$loginPage->login('admin', 'wrong');
$I->expectTo('see validations errors');
$I->see('Incorrect username or password.', '.help-block');
$I->amGoingTo('try to login with correct credentials');
$loginPage->login('erau', 'password_0');
$I->expectTo('see that user is logged');
$I->seeLink('Logout (erau)');
$I->dontSeeLink('Login');
$I->dontSeeLink('Signup');
Beispiel #18
0
 /**
  * @param FunctionalTester $I
  */
 public function testProtected(FunctionalTester $I)
 {
     Post::findOne(1)->updateAttributes(['password' => 'postpassword']);
     $I->wantTo('ensure that protected post works');
     $postView = PostViewPage::openBy($I);
     $I->see('Sample Post', 'h1');
     $I->amGoingTo('submit password form with incorrect password');
     $postView->submitPassword('wrong_password');
     $I->expectTo('not see the post');
     $I->dontSeeElement('.entry-meta');
     $I->amGoingTo('submit password form with correct password');
     $postView->submitPassword('postpassword');
     $I->expectTo('see the post');
     $I->seeElement('.entry-meta');
     Post::findOne(1)->updateAttributes(['password' => '']);
 }