public function testChangePassword(FunctionalTester $I)
 {
     $I->amGoingTo('test the change password functionality');
     // Create one user
     $user = Commons::createUser();
     $I->amGoingTo('login a user');
     $loginPage = LoginPage::openBy($I);
     $loginPage->login(Commons::TEST_EMAIL, Commons::TEST_PASSWORD);
     $changePasswordPage = ChangePasswordPage::openBy($I);
     $I->see('Change password');
     $I->seeElement('#changepasswordform-newpassword');
     $I->seeElement('#changepasswordform-newpasswordrepeat');
     $I->dontSeeElement('#changepasswordform-email');
     $I->dontSeeElement('#changepasswordform-oldpassword');
     $I->amGoingTo('try to change the password with two different passwords for the new password and the new password repeat fields');
     $changePasswordPage->changePassword('123123', '234234');
     $I->expect('the form will catch the difference');
     $I->see('The new passwords are not the same.');
     $I->amGoingTo('test adding new password with length lower than the default length');
     $changePasswordPage->changePassword('123', '123');
     $I->expect('the form will warn the user');
     $I->see('New password should contain at least 6 characters');
     $I->see('New password repeat should contain at least 6 characters');
     $I->amGoingTo('change the password of the user properly');
     $changePasswordPage->changePassword('Nik)lay!23', 'Nik)lay!23');
     $I->expect('that this time everything will be ok and the user will be redirected to the home page');
     $user->refresh();
     $I->assertNotNull($user->password_changed_at);
     $I->seeInCurrentUrl('/');
 }
 public function getNoErrorIfAssetsAreDumped(FunctionalTester $I)
 {
     $I->bootKernelWith('customized');
     $I->runCommand('maba_webpack.command.setup');
     $I->seeFileFound(__DIR__ . '/Fixtures/package.json');
     $I->seeFileFound(__DIR__ . '/Fixtures/app/config/webpack.config.js');
     $I->runCommand('maba_webpack.command.compile');
     $I->seeCommandStatusCode(0);
     $I->seeInCommandDisplay('webpack');
     $I->dontSeeInCommandDisplay('error');
     $I->amOnPage('/customized');
     $I->canSeeResponseCodeIs(200);
     $I->dontSee('Manifest file not found');
     $I->seeInSource('<link rel="stylesheet" id="css1" href="/assets/');
     $href = $I->grabAttributeFrom('link#css1', 'href');
     preg_match('#/assets/(.*)#', $href, $matches);
     $I->seeFileFound(__DIR__ . '/Fixtures/web/assets/' . $matches[1]);
     $I->openFile(__DIR__ . '/Fixtures/web/assets/' . $matches[1]);
     $I->canSeeInThisFile('.green');
     $I->canSeeInThisFile('.red');
     $I->canSeeInThisFile('-ms-fullscreen a.css');
     $I->amGoingTo('Check if less file was compiled');
     $I->canSeeInThisFile('color: #123456');
     $I->canSeeInThisFile('-ms-fullscreen a.less');
     $I->amGoingTo('Check if sass file was compiled');
     $I->canSeeInThisFile('color: #654321');
     $I->canSeeInThisFile('-ms-fullscreen a.scss');
     $I->amGoingTo('Check if cat.png was included');
     $I->canSeeInThisFile('background: url(/assets/');
     $I->seeInSource('<link rel="stylesheet" id="css2" href="/assets/');
     $href = $I->grabAttributeFrom('link#css2', 'href');
     preg_match('#/assets/(.*)#', $href, $matches);
     $I->seeFileFound(__DIR__ . '/Fixtures/web/assets/' . $matches[1]);
     $I->openFile(__DIR__ . '/Fixtures/web/assets/' . $matches[1]);
     $I->canSeeInThisFile('color: #123456');
     $I->seeInSource('<script src="/assets/');
     $src = $I->grabAttributeFrom('script', 'src');
     preg_match('#/assets/(.*)#', $src, $matches);
     $I->seeFileFound(__DIR__ . '/Fixtures/web/assets/' . $matches[1]);
     $I->openFile(__DIR__ . '/Fixtures/web/assets/' . $matches[1]);
     $I->canSeeInThisFile('additional-asset-content');
     $I->canSeeInThisFile('additional asset B');
     $I->canSeeInThisFile('app-asset-content');
     $I->dontSeeInThisFile('featureA-content');
     $I->dontSeeInThisFile('featureB-content');
     $I->seeInSource('<img src="/assets/');
     $src = $I->grabAttributeFrom('img', 'src');
     preg_match('#/assets/(.*)#', $src, $matches);
     $I->seeFileFound(__DIR__ . '/Fixtures/web/assets/' . $matches[1]);
     $I->seeFileIsSmallerThan(__DIR__ . '/Fixtures/web/assets/' . $matches[1], __DIR__ . '/Fixtures/src/Resources/assets/cat.png');
 }
Beispiel #3
0
 public function testResetPassword(FunctionalTester $I)
 {
     $user = Commons::createUnconfirmedUser();
     $token = Commons::createTokenForUser($user->id);
     $I->amGoingTo('test that the reset password functionality is working properly');
     $I->amGoingTo('to confirm the email for the user');
     PasswordResetPage::openBy($I, ['code' => $token->code]);
     $I->expectTo('see successful reset');
     $I->dontSeeRecord(Token::className(), ['user_id' => $user->id]);
     $I->expectTo('see the user is sent to the change password form');
     $I->see('Change password');
     $I->seeElement('#changepasswordform-newpassword');
     $I->seeElement('#changepasswordform-newpasswordrepeat');
 }
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('I am Admin and Update Company Mau');
$I->dontSeeAuthentication();
$I->amLoggedAs(['email' => '*****@*****.**', 'password' => 'admin']);
$I->seeAuthentication();
//When
$id = $I->haveRecord('companys', ['name' => 'Maur', 'partner_id' => '2', 'currency_id' => '3', 'fiscalRegimen_id' => '2']);
//And
$I->amOnPage('/settings/company/' . $id);
//then
$I->see('Edit');
//When
$I->click('Edit');
$I->seeCurrentUrlEquals('/settings/company/' . $id . '/edit');
$I->seeInField('name', 'Maur');
$I->seeInField('partner_id', '2');
$I->seeInField('currency_id', '3');
$I->seeInField('fiscalRegimen_id', '2');
//And
$I->amGoingTo('Change name of Maur to Association_Mau');
$form = ['name' => 'Association_Mau', 'partner_id' => '3', 'currency_id' => '2', 'fiscalRegimen_id' => '1'];
Beispiel #5
0
<?php

/* @var $scenario Codeception\Scenario */
$I = new FunctionalTester($scenario);
/* TESTING CREATE EMPLOYEE */
$I->wantTo('Memastikan "Create Employee" bekerja');
$I->amOnPage(['employee/create']);
$I->amGoingTo('submit form dengan data input kosong');
$I->click('button[type="submit"]');
$I->expectTo('Validasi eror muncul!');
$I->see('Name cannot be blank.');
$I->see('Age cannot be blank.');
$I->amGoingTo('submit form dengan data');
$I->fillField('input[name="Employee[name]"]', 'Hafid');
$I->fillField('input[name="Employee[age]"]', '30');
$I->click('button[type="submit"]');
$I->expectTo('ada data Hafid di tabel employee');
$I->seeRecord('\\app\\models\\Employee', ['name' => 'Hafid']);
Beispiel #6
0
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('visit all pages');
$I->amGoingTo('visit the home page');
$I->amOnPage('/');
$I->seeResponseCodeIs(200);
$I->see('Nope');
$I->amGoingTo('visit the getting started page');
$I->amOnPage('/getting-started');
$I->seeResponseCodeIs(200);
$I->see('Introduction');
$I->see('Installation');
$I->amGoingTo('visit the statistics page');
$I->amOnPage('/stats');
$I->seeResponseCodeIs(200);
$I->see('Total Pokes');
$I->see('Total Devices');
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('I am Admin and Update partner Mario');
$I->dontSeeAuthentication();
$I->amLoggedAs(['email' => '*****@*****.**', 'password' => 'admin']);
$I->seeAuthentication();
//When
$id = $I->haveRecord('partners', ['name' => 'Mario', 'country_id' => 1, 'state_id' => 1, 'city_id' => 1]);
//And
$I->amOnPage('/partners/' . $id);
//then
$I->see('Edit');
//When
$I->click('Edit');
$I->seeCurrentUrlEquals('/partners/' . $id . '/edit');
$I->seeInField('name', 'Mario');
$I->seeInField('country_id', 1);
$I->seeInField('state_id', 1);
$I->seeInField('city_id', 1);
//And
$I->amGoingTo('Change name of Mario to Mariano');
$form = ['name' => 'Mariano', 'country_id' => 1, 'state_id' => 1, 'city_id' => 1];
$I->submitForm('//form', $form, 'Save');
<?php

use yii\helpers\Url;
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that confirmation works');
$I->amGoingTo('check that error is showed when token expired');
$token = $I->getFixture('token')->getModel('expired_confirmation');
$I->amOnPage(Url::toRoute(['/user/registration/confirm', 'id' => $token->user_id, 'code' => $token->code]));
$I->see('We are sorry but your confirmation token is out of date');
$I->amGoingTo('check that user get confirmed');
$token = $I->getFixture('token')->getModel('confirmation');
$I->amOnPage(Url::toRoute(['/user/registration/confirm', 'id' => $token->user_id, 'code' => $token->code]));
$I->see('You have successfully confirmed your email address. You may sign in using your credentials now');
$I->see('Logout');
Beispiel #9
0
<?php

$I = new FunctionalTester($scenario);
$I->am('a CMS admin');
$I->wantTo('create a new section');
// When
$I->amOnPage('admin/sections');
// And
$I->click('Add a new section');
// Then
$I->seeCurrentUrlEquals('/admin/sections/create');
$I->see('New section', 'h1');
$I->amGoingTo('Omit the name field in order to submit an invalid form');
// When
$I->fillField('Slug URL', 'our-company');
$I->click('Create section');
// Then
$I->expectTo('See the form again with the errors');
$I->seeCurrentUrlEquals('/admin/sections/create');
$I->seeInField('slug_url', 'our-company');
$I->see('The name field is required', '.error');
$I->amGoingTo('Fill a valid form');
// When
$I->fillField('Name', 'Our company');
$I->fillField('Slug URL', 'our-company');
$I->selectOption('type', 'blog');
$I->selectOption('menu', 1);
$I->fillField('menu_order', 2);
$I->selectOption('published', 0);
// And
$I->click('Create section');
Beispiel #10
0
<?php

$I = new FunctionalTester($scenario);
$I->am('a CMS admin');
$I->wantTo('paginate the sections results');
$I->amGoingTo('Go to page 1');
// When
$sections = $I->haveSections(16);
// And
$I->amOnPage('/admin/sections');
// Then
$I->see('There are 16 sections, showing page 1 of 2');
$I->expectTo('see the first section');
$I->see($sections->first()->name, 'tbody tr:first-child td.name');
$I->expect('not to see the last section');
$I->dontSee($sections->last()->name);
$I->expectTo('see the page 2 link');
$I->see('2', '.pagination a');
$I->amGoingTo('go to page 2');
// When
$I->click('2', '.pagination a');
// Then
$I->expectTo('see the pagination parameter in the URL');
$I->seeCurrentUrlEquals('/admin/sections?page=2');
$I->expect('not to see the first section');
$I->dontSee($sections->first()->name);
$I->expectTo('see the last section');
$I->see($sections->last()->name);
$I->expectTo('See the section #15 as first item on page 2');
$I->see($sections->get(15)->name, 'tbody tr:first-child td.name');
$I->amGoingTo('go back to page 1');
Beispiel #11
0
// And
$I->amOnPage('admin/sections/' . $id);
// Then
$I->see('Edit section', '.btn-edit');
// When
$I->click('Edit section');
// Then
$I->seeCurrentUrlEquals('/admin/sections/' . $id . '/edit');
$I->see('Edit section "Our company"', 'h1');
$I->seeInField('name', 'Our company');
$I->seeInField('slug_url', 'our-company');
$I->seeInField('menu_order', 2);
$I->seeOptionIsSelected('published', 0);
$I->seeOptionIsSelected('menu', 1);
$I->seeOptionIsSelected('type', 'Page');
$I->amGoingTo('Submit an invalid form');
// When
$I->fillField('name', '');
// And
$I->click('Update section');
// Then
$I->expectTo('see the form back with data and errors');
$I->seeCurrentUrlEquals('/admin/sections/' . $id . '/edit');
$I->seeInField('name', '');
$I->seeInField('slug_url', 'our-company');
$I->see('The name field is required', '.error');
$I->amGoingTo('Submit a valid form');
// When
$I->fillField('name', 'Who we are');
$I->selectOption('published', 1);
// And
Beispiel #12
0
/**
 * Created by PhpStorm.
 * User: bill
 * Date: 26.01.15
 * Time: 11:31
 */
use app\tests\codeception\_pages\mobile\number\CreatePage;
use app\modules\mobile\models\Number;
use app\modules\mobile\models\Document;
use app\modules\directory\models\Employee;
$I = new FunctionalTester($scenario);
$I->wantTo("ensure that creation Number model works");
$owner = $I->grabRecord(Employee::className(), ['id' => 1]);
$newDocument = 'file1.jpg';
$number = '9876543210';
$I->amGoingTo("prepare database.");
Document::deleteAll(['filename' => $newDocument]);
Number::deleteAll(['number' => $number]);
$page = CreatePage::openBy($I);
$I->dontSeeElement("input[type=file]");
$I->dontSeeElement("#documents-panel-body");
$I->dontSeeElement("#history-panel-body");
$page->submit(['number' => $number, 'ownerName' => $owner->fullName, 'ownerPost' => $owner->post, 'operatorId' => 'operator2', 'destination' => Number::DESTINATION_MODEM, 'limit' => "1000", 'options' => [Number::OPTION_ACCOUNTING, Number::OPTION_DIRECTORY], 'comment' => 'This is comment of testing number.']);
$I->SeeRecord(Number::className(), ['number' => $number, 'ownerId' => 1, 'operatorId' => 'operator2', 'destination' => Number::DESTINATION_MODEM, 'limit' => 1000, 'options' => [Number::OPTION_ACCOUNTING, Number::OPTION_DIRECTORY], 'history' => [['ownerId' => 'employee1', 'rentDate' => time()]], 'comment' => 'This is comment of testing number.']);
$I->see("Номер успешно создан", '.alert-success');
$I->seeInField($page->fieldSelector('ownerName'), $owner->fullName);
$I->seeInField($page->fieldSelector('ownerPost'), $owner->posts[1]);
$I->seeOptionIsSelected($page->fieldSelector('operatorId'), "Оператор 2");
$I->seeOptionIsSelected($page->fieldSelector('destination'), Number::DESTINATION_MODEM);
$I->seeCheckboxIsChecked($page->fieldSelector(Number::OPTION_ACCOUNTING));
$I->seeCheckboxIsChecked($page->fieldSelector(Number::OPTION_DIRECTORY));
Beispiel #13
0
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('check application versioning');
$I->dontSeeFileFound('src/version');
$I->seeFileFound('version');
$I->openFile('version');
$I->dontSeeInThisFile('dev');
$I->dontSeeInThisFile('dirty');
$version = file_get_contents('version');
$I->amGoingTo('check version visiblity in modal');
$I->expectTo('see application version ' . $version);
$I->amOnPage('/user/security/login');
$I->see($version, '.modal-body');
<?php

$I = new FunctionalTester($scenario);
$I->am('registered common user');
$I->wantTo('perform authentication actions');
// When
$I->amOnPage('login');
// Then
$I->see('Log in', 'h2');
$I->see('Username', 'label');
$I->see('Password', 'label');
$I->see('Remember me', 'label');
$I->seeElement('input', ['value' => 'Log in', 'class' => 'btn btn-primary btn-block']);
$I->amGoingTo('fill an invalid user in order to see the errors');
// When
$I->fillField('username', 'admin');
$I->fillField('password', '12345');
// And
$I->click('Log in', 'input[type=submit]');
// Then
$I->expectTo('see an error message');
$I->seeCurrentUrlEquals('/login');
$I->seeInField('username', 'admin');
$I->see('Invalid data', '.alert-danger');
$I->haveRecord('users', ['first_name' => 'System', 'last_name' => 'Administrator', 'username' => 'admin', 'password' => Hash::make('secret'), 'email' => '*****@*****.**', 'remember_token' => null]);
$I->amGoingTo('full a valid user and see the result');
// When
$I->fillField('password', 'secret');
// And
$I->click('Log in', 'input[type=submit]');
// Then
<?php

$I = new FunctionalTester($scenario);
$I->amGoingTo('check version visiblity');
$I->seeFileFound('/app/version');
$version = file_get_contents('/app/version');
$I->expectTo('see application version ' . $version);
$I->amOnPage('/en-us');
$I->see($version);
Beispiel #16
0
<?php

use tests\codeception\_pages\LoginPage;
/* @var $scenario Codeception\Scenario */
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that login works');
//$loginPage = LoginPage::openBy($I);
$I->amGoingTo('Exist record with id=1');
$category = $I->seeRecord('app\\models\\User', array('id' => '1'));
Beispiel #17
0
<?php

$I = new FunctionalTester($scenario);
$I->am('a CMS admin');
$I->wantTo('filter the section list');
$I->amGoingTo('check an empty section list');
// When
$I->amOnPage('/admin/sections');
// Then
$I->see('There are no sections, please create the first one');
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('create a category');
$I->am('knowledge admin');
$I->amOnPage('/categories/create');
$I->seeInTitle('Create category');
// form empty
$I->amGoingTo('test validation');
$I->click('Create');
$I->dontSeeRecord('categories', []);
$I->seeCurrentUrlEquals('/categories/create');
$I->see('The name field is required');
$I->see('The slug field is required');
// only empty name
$I->amGoingTo('test name validation');
$I->fillField('slug', 'libro');
$I->fillField('active', 1);
$I->click('Create');
$I->dontSeeRecord('categories', ['slug' => 'libro', 'active' => 1]);
$I->seeCurrentUrlEquals('/categories/create');
$I->see('The name field is required', '.error');
$I->seeInField('slug', 'libro');
$I->dontSee('The slug field is required');
// all form filled
$I->fillField('name', 'Libro');
$I->fillField('slug', 'libro');
$I->fillField('active', 1);
$I->click('Create');
$I->haveRecord('categories', ['name' => 'Libro', 'slug' => 'libro', 'active' => 1]);
$I->seeCurrentUrlEquals('/categories');
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('I am Admin and Update Currency Mau');
$I->dontSeeAuthentication();
$I->amLoggedAs(['email' => '*****@*****.**', 'password' => 'admin']);
$I->seeAuthentication();
//When
$id = $I->haveRecord('currencys', ['name' => 'Mau', 'symbol' => '@']);
//And
$I->amOnPage('/settings/currency/' . $id);
//then
$I->see('Edit');
//When
$I->click('Edit');
$I->seeCurrentUrlEquals('/settings/currency/' . $id . '/edit');
$I->seeInField('name', 'Mau');
$I->seeInField('symbol', '@');
//And
$I->amGoingTo('Change name of Mau to Yen');
$form = ['name' => 'Yen', 'symbol' => '@'];
//$I->submitForm('//form', $form, 'Save');
/*$I->amOnPage('/settings/users/'.$id);
$I->seeCurrentUrlEquals('/settings/users/'.$id);
$I->see('Macrio');
$I->see('*****@*****.**');*/
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('I am Admin and Update CertificateSats Mau');
$I->dontSeeAuthentication();
$I->amLoggedAs(['email' => '*****@*****.**', 'password' => 'admin']);
$I->seeAuthentication();
//When
$id = $I->haveRecord('certificatesats', ['name' => 'Benny', 'noSerie' => '123456', 'startDate' => '0000-00-00', 'endDate' => '0000-00-00']);
//And
$I->amOnPage('/settings/certificatesats/' . $id);
//then
$I->see('Edit');
//When
$I->click('Edit');
$I->seeCurrentUrlEquals('/settings/certificatesats/' . $id . '/edit');
$I->seeInField('name', 'Benny');
$I->seeInField('noSerie', '123456');
$I->seeInField('startDate', '0000-00-00');
$I->seeInField('endDate', '0000-00-00');
//And
$I->amGoingTo('Change name of Benny to Iggy2');
$form = ['name' => 'Iggy2', 'noSerie' => '1234567', 'startDate' => '2010-02-01', 'endDate' => '2019-04-01'];
<?php

use schmunk42\giiant\tests\_pages\LoginPage;
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that crud works with access rules');
$I->amOnPage('/crud/actor');
$I->dontSee('Actor', 'h2');
$I->see('Sign in', 'h3');
$I->amGoingTo('try to login with correct credentials');
// TODO: use LoginPage class
$username = '******';
$password = '******';
$I->fillField('input[name="login-form[login]"]', $username);
$I->fillField('input[name="login-form[password]"]', $password);
$I->click('Sign in');
$I->see('Actor', 'h2');
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('I am Admin and Update product Fresca');
$I->dontSeeAuthentication();
$I->amLoggedAs(['email' => '*****@*****.**', 'password' => 'admin']);
$I->seeAuthentication();
//When
$id = $I->haveRecord('products', ['name' => 'Fresca', 'description' => 'Fresca de 600 ml', 'purchasePrice' => 7, 'salePrice' => 9, 'qtyAvailable' => 20, 'incomingQty' => 12, 'virtualAvailable' => 32, 'ean13' => 'Fresca Coca-cola company', 'uom_id' => 4, 'partner_id' => 2]);
//And
$I->amOnPage('/products/' . $id);
//then
$I->see('Edit');
//When
$I->click('Edit');
$I->seeCurrentUrlEquals('/products/' . $id . '/edit');
$I->seeInField('name', 'Fresca');
$I->seeInField('description', 'Fresca de 600 ml');
$I->seeInField('purchasePrice', 7);
$I->seeInField('salePrice', 9);
$I->seeInField('qtyAvailable', 20);
$I->seeInField('incomingQty', 12);
$I->seeInField('virtualAvailable', 32);
$I->seeInField('ean13', 'Fresca Coca-cola company');
$I->seeInField('uom_id', 4);
$I->seeInField('partner_id', 2);
//And
$I->amGoingTo('Change name and description of Fresca to Fanta');
$form = ['name' => 'Fanta', 'description' => 'Fanta de 600 ml', 'purchasePrice' => 7, 'salePrice' => 9, 'qtyAvailable' => 20, 'incomingQty' => 12, 'virtualAvailable' => 32, 'ean13' => 'Fresca Coca-cola company', 'uom_id' => 4, 'partner_id' => 2];
$I->submitForm('//form', $form, 'Save');