Ejemplo n.º 1
0
 public function testPasswordRecoveryRequest(FunctionalTester $I)
 {
     // Create one user
     $user = Commons::createUser();
     $I->expectTo('see the recovery form when going to the recovery page');
     $passwordRecoveryRequestPage = PasswordRecoveryRequestPage::openBy($I);
     $I->seeElement('#password-recovery-form');
     $I->expectTo('see that a proper message is sent when an empty email is set');
     $passwordRecoveryRequestPage->submitRecoveryForm('');
     $I->seeElement('#password-recovery-form');
     $I->see('Email cannot be blank');
     $I->expectTo('see that a proper message is sent when a wrong email is set');
     $passwordRecoveryRequestPage->submitRecoveryForm('test@fds');
     $I->seeElement('#password-recovery-form');
     $I->see('Email is not a valid email address.');
     $I->expectTo('see that a proper message is sent when an email of unexisting user is set');
     $passwordRecoveryRequestPage->submitRecoveryForm('*****@*****.**');
     $I->seeElement('#password-recovery-form');
     $I->see('There is no user with this email address');
     $I->amGoingTo('save the form with correct data');
     $passwordRecoveryRequestPage->submitRecoveryForm(Commons::TEST_EMAIL);
     $I->expectTo('see the user is redirected to the correct page');
     $I->see('Recovery message sent');
     $I->expectTo('see that a the token is saved to the database');
     $I->seeRecord(Token::className(), ['user_id' => $user->id]);
     $I->expectTo('see that a recovery email is sent to the user');
     $I->assertNotEmpty($this->mailDir);
 }
Ejemplo n.º 2
0
 public function submitFormWithIncorrectEmail(FunctionalTester $I)
 {
     $I->submitForm('#contact-form', ['ContactForm[name]' => 'tester', 'ContactForm[email]' => 'tester.email', 'ContactForm[subject]' => 'test subject', 'ContactForm[body]' => 'test content', 'ContactForm[verifyCode]' => 'testme']);
     $I->expectTo('see that email address is wrong');
     $I->dontSee('Name cannot be blank', '.help-inline');
     $I->see('Email is not a valid email address.');
     $I->dontSee('Subject cannot be blank', '.help-inline');
     $I->dontSee('Body cannot be blank', '.help-inline');
     $I->dontSee('The verification code is incorrect', '.help-inline');
 }
Ejemplo n.º 3
0
 public function viewInvalidNote(FunctionalTester $I)
 {
     $I->am('Normal User');
     $I->expectTo('see 401 error with mismatch note route parameters.');
     $admin = $I->createUser(1, 4);
     // admin
     $project1 = $I->createProject(1, [$admin]);
     $project2 = $I->createProject(2, [$admin]);
     $note1 = $I->createNote(1, $admin, $project1);
     $I->amLoggedAs($admin);
     $I->amOnAction('ProjectController@getNotes', ['project' => $project1]);
     $uri = $I->getApplication()->url->action('ProjectController@postEditNote', ['project' => $project2, 'note' => $note1], false);
     $I->sendAjaxPostRequest($uri, ['body' => 'note one updated', '_token' => csrf_token()]);
     $I->seeResponseCodeIs(401);
 }
Ejemplo n.º 4
0
<?php

$I = new FunctionalTester($scenario);
$I->expectTo('have a usere in the database');
$I->haveRecord('users', ['username' => 'verem', 'password' => 'danverem', 'email' => '*****@*****.**', 'profile_state' => 0]);
$I->expectTo('have a logged in user');
$user = $I->grabRecord('users', ['username' => 'verem']);
$I->amLoggedAs(['username' => $user->username, 'id' => $user->id, 'password' => $user->password]);
$I->wantTo('test if chops is posting to database');
$I->amOnAction('ChopsController@create');
$I->seeInCurrentUrl('/create');
$I->see('What\'s that special meal you just ate today');
$I->fillField('name', 'edikaikong');
$I->attachFile('image', 'julia.jpeg');
$I->fillField('about', 'This food is the best dish in the country');
$I->click('submitButton');
$I->seeInCurrentUrl('/chops');
Ejemplo n.º 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']);
Ejemplo n.º 6
0
$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');
// Then
$I->seeCurrentUrlEquals('/admin/sections/1');
Ejemplo n.º 7
0
<?php

$I = new FunctionalTester($scenario);
$I->am('a CMS admin');
$I->wantTo('See section details');
// When
$id = $I->haveSection();
$I->amOnPage('admin/sections/' . $id);
// Then
//$I->seeCurrentUrlEquals('/admin/sections/1');
$I->expectTo('see the section details');
$I->see('Our company', 'h1');
$I->see('our-company', '.slug-url');
$I->see('2', '.menu-order');
$I->see('Show in menu', '.menu');
$I->see('Draft', '.published');
Ejemplo n.º 8
0
 public function loginWithWrongCredentials(\FunctionalTester $I)
 {
     $I->submitForm('#login-form', ['LoginForm[username]' => 'admin', 'LoginForm[password]' => 'wrong']);
     $I->expectTo('see validations errors');
     $I->see('Incorrect username or password.');
 }
Ejemplo n.º 9
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');
Ejemplo n.º 10
0
 public function access_to_the_leading_team_page(FunctionalTester $I)
 {
     $I->am('Anybody');
     $I->wantTo('access to the leading team page');
     $I->expectTo('see that the user shown in the category they belong');
     /***************************************************************************************************************
      * settings
      **************************************************************************************************************/
     // we create a member of the student leading board
     $credentials = ['last_name' => 'Student', 'first_name' => 'President', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.student_president'), 'board_id' => config('user.board_key.student_leading_board'), 'password' => 'test'];
     Sentinel::register($credentials, true);
     // we create a member of the student leading board
     $credentials = ['last_name' => 'Deactivated', 'first_name' => 'Student vice-president', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.user'), 'board_id' => config('user.board_key.student_leading_board'), 'password' => 'test'];
     Sentinel::register($credentials);
     // we create a member of the leading board
     $credentials = ['last_name' => 'Regular', 'first_name' => 'President', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.president'), 'board_id' => config('user.board_key.leading_board'), 'password' => 'test'];
     Sentinel::register($credentials, true);
     // we create a member of the executive committee
     $credentials = ['last_name' => 'Communication', 'first_name' => 'Responsible', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.communication_commission'), 'board_id' => config('user.board_key.executive_committee'), 'password' => 'test'];
     Sentinel::register($credentials, true);
     // we create an employee
     $credentials = ['last_name' => 'Coach', 'first_name' => 'Employee', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.employee'), 'password' => 'test'];
     Sentinel::register($credentials, true);
     /***************************************************************************************************************
      * run test
      **************************************************************************************************************/
     $I->amOnPage('/');
     $I->seeCurrentRouteIs('home');
     $I->click(trans('template.front.header.leading_team'));
     $I->see('Student', '.student_leading_board');
     $I->see('President', '.student_leading_board');
     $I->see(trans('users.config.status.student_president'), '.student_leading_board');
     $I->dontSee('Deactivated', '.student_leading_board');
     $I->dontSee('Student vice-president', '.student_leading_board');
     $I->dontSee(trans('users.config.status.user'), '.student_leading_board');
     $I->see('Regular', '.leading_board');
     $I->see('President', '.leading_board');
     $I->see(trans('users.config.status.president'), '.leading_board');
     $I->see('Communication', '.executive_committee');
     $I->see('Responsible', '.executive_committee');
     $I->see(trans('users.config.status.communication_commission'), '.executive_committee');
     $I->see('Coach', '.employee');
     $I->see('Employee', '.employee');
     $I->see(trans('users.config.status.employee'), '.employee');
 }
Ejemplo n.º 11
0
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('register a user from index page');
$I->expectTo('have a users in the database');
$I->amOnPage('/');
$I->haveRecord('users', ['email' => '*****@*****.**', 'username' => 'andelabendozy', 'password' => bcrypt('password'), 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'status' => TRUE, 'profile_state' => FALSE]);
$I->submitForm('form#register', ['name' => 'prosper', 'email' => '*****@*****.**', 'password' => '12345678', 'password_confirmation' => '12345678']);
$I->seeAuthentication();
$I->seeCurrentUrlEquals('');
$I->seeRecord('users', ['email' => '*****@*****.**']);
$I->seeAuthentication();
$I->wantTo('logout');
$I->logout();
$I->dontSeeAuthentication();
Ejemplo n.º 12
0
<?php

$I = new FunctionalTester($scenario);
$I->am('a CMS admin');
$I->wantTo('filter and paginate the section list');
// When
$sections = $I->haveSections(90);
// Random sections
// And
$I->amOnPage('admin/sections');
$I->selectOption('published', '1');
$I->click('Filter sections');
$I->click('2', '.pagination a');
// Then
$I->expectTo('see published sections');
$I->see('Published', 'td');
$I->expect('not to see draft sections');
$I->dontSee('Draft', 'td');
Ejemplo n.º 13
0
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('test if chops can be displayed on the home page after posting');
$I->expectTo('have a registered user in the database');
$user_id = $I->haveRecord('users', ['username' => 'John Doe', 'password' => 'johndope', 'email' => '*****@*****.**', 'profile_state' => 0]);
$I->expectTo('have a chops record in the database');
$I->haveRecord('chops', ['chops_name' => 'A new name', 'about' => 'About this chops', 'user_id' => $user_id, 'likes' => 0]);
$I->expectTo('have the action take place in the controller');
$I->amOnAction('ChopsController@index');
$I->seeInCurrentUrl('/chops');
$I->see('About this chops');
$I->see('A new name');
Ejemplo n.º 14
0
 public function activate_account_from_email(FunctionalTester $I)
 {
     $I->am('Unlogged user with a not activated account');
     $I->wantTo('activate my account');
     $I->expectTo('see a success confirmation message explaining that my account is activated');
     /***************************************************************************************************************
      * settings
      **************************************************************************************************************/
     // we create a user
     $this->_credentials = ['last_name' => 'NOM', 'first_name' => 'Prénom', 'email' => '*****@*****.**', 'password' => 'password'];
     $user = \Sentinel::register($this->_credentials);
     // we create an activation
     $activation = \Activation::create($user);
     /***************************************************************************************************************
      * run test
      **************************************************************************************************************/
     $I->sendAjaxRequest('GET', route('account.activate', ['email' => $user->email, 'token' => $activation->code]));
     $I->see(trans('global.modal.alert.title.success'));
     $I->see(strip_tags(trans('auth.message.activation.success', ['name' => $user->first_name . ' ' . $user->last_name])));
 }
Ejemplo n.º 15
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');
Ejemplo n.º 16
0
 public function checkHomePageContainsDataSetInAdmin(FunctionalTester $I)
 {
     $I->am('Admin');
     $I->wantTo('check on the home page that the data saved from the admin panel are shown');
     $I->expectTo('see the saved data on the home page');
     /***************************************************************************************************************
      * settings
      **************************************************************************************************************/
     // we create the admin role
     $admin_role = $this->_createAdminRole();
     // we attach it to the logged user
     $admin_role->users()->attach($this->_user);
     // we create a slide
     $this->_createSlide();
     /***************************************************************************************************************
      * run test
      **************************************************************************************************************/
     $I->amOnPage('/');
     $I->seeCurrentRouteIs('home');
     $I->see($this->_slide->title, 'h2');
     $I->see($this->_slide->quote, '.quote');
     $I->seeElement('//img[@src="' . url('img/slides/' . $this->_slide->picto) . '"]');
     $I->seeElement('//div[@data-background-image="' . url('img/slides/' . $this->_slide->background_image) . '"]');
     $I->see(json_decode(file_get_contents(storage_path('app/home/content.json')))->title, 'h2');
     $I->see(json_decode(file_get_contents(storage_path('app/home/content.json')))->description);
     $I->seeElement('//a[@href="' . json_decode(file_get_contents(storage_path('app/home/content.json')))->video_link . '"]');
 }
// 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
$I->seeCurrentUrlEquals('');
$I->see('You have arrived.', 'h1');
$I->see('Log out', 'a');
$I->seeAuthentication();
$I->amGoingTo('log out');
Ejemplo n.º 18
0
 public function delete_current_role_denied(FunctionalTester $I)
 {
     $I->am('Admin');
     $I->wantTo('delete the Admin role');
     $I->expectTo('see an error message explaining that deleting the role we use is not possible');
     $admin = $this->_createAdminRole();
     $admin->users()->attach($this->_user);
     $I->amOnRoute('permissions.index');
     $I->submitForm('#delete_' . $admin->id, []);
     $I->seeCurrentRouteIs('permissions.index');
     $I->see(trans('global.modal.alert.title.error'), 'h3');
     $I->see(strip_tags(trans('permissions.message.delete.denied', ['name' => $admin->name])));
     $I->see($admin->name, '.table-list');
 }
Ejemplo n.º 19
0
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('register a user');
$I->amOnPage('/register');
$I->fillField('name', 'Jo');
$I->fillField('email', 'example');
$I->fillField('password', 'pass');
$I->fillField('password_confirmation', 'pass');
$I->click('button[type=submit]');
$I->seeFormHasErrors();
$I->seeCurrentUrlEquals('/register');
$I->seeFormErrorMessages(array('email' => 'The email must be a valid email address.', 'name' => 'The name must be at least 3 characters.', 'password' => 'The password must be at least 8 characters.'));
$I->dontSeeRecord('users', ['email' => 'example']);
$I->expectTo('register a user with a mismatching password');
$I->fillField('name', 'Johndoe');
$I->fillField('email', '*****@*****.**');
$I->fillField('password', 'passee');
$I->fillField('password_confirmation', 'pass');
$I->click('button[type=submit]');
$I->seeFormHasErrors();
$I->seeCurrentUrlEquals('/register');
$I->seeFormErrorMessage('password', 'The password confirmation does not match.');
$I->dontSeeRecord('users', ['email' => '*****@*****.**']);
$I->expectTo('register a user with existing username and email');
$I->haveRecord('users', ['email' => '*****@*****.**', 'username' => 'andelabendozy', 'password' => bcrypt('password'), 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'status' => TRUE, 'profile_state' => FALSE]);
$I->fillField('name', 'andelabendozy');
$I->fillField('email', '*****@*****.**');
$I->fillField('password', 'password');
$I->fillField('password_confirmation', 'password');
$I->click('button[type=submit]');
Ejemplo n.º 20
0
// 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
$I->click('Update section');
// Then
$I->expectTo('see the section details with the new changes');
$I->seeCurrentUrlEquals('/admin/sections/' . $id);
$I->see('Who we are', 'h1');
$I->seeRecord('sections', ['id' => $id, 'name' => 'Who we are', 'published' => 1, 'slug_url' => 'our-company', 'type' => 'page', 'menu_order' => 2, 'menu' => 1]);
 /**
  * @param FunctionalTester $I
  * @param string|array     $action
  * @param string           $expectTo
  *
  * @return void
  */
 protected function _cantAccessPage(FunctionalTester $I, $action, $expectTo)
 {
     $action = is_array($action) ? $action : [$action];
     $I->am('Developer User');
     $I->expectTo('not be able to ' . $expectTo);
     $I->amLoggedAs($I->createUser(1, 2));
     call_user_func_array([$I, 'amOnAction'], $action);
     $I->seeResponseCodeIs(401);
 }
Ejemplo n.º 22
0
 /**
  * @param \FunctionalTester $I
  *
  * @actor FunctionalTester
  *
  * @return void
  */
 public function cantCreateUser(FunctionalTester $I)
 {
     $I->am('Manager User');
     $I->expectTo('not be able to create new user');
     $I->amLoggedAs($I->createUser(1, 3));
     $I->amOnAction('Administration\\UsersController@getAdd');
     $I->seeResponseCodeIs(401);
 }
Ejemplo n.º 23
0
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('login as a user from index page with invalid details');
$I->expectTo('fail to login');
$I->amOnPage('/');
$I->submitForm('form#login', ['email' => 'andelabendo', 'password' => 'password']);
$I->seeInCurrentUrl('/login');
$I->dontSeeAuthentication();
$I->seeFormHasErrors();
$I->see('These credentials do not match our records.');
$I->wantTo('login as a user from index page with correct details');
$I->expectTo('have a users in the database');
$I->amOnPage('/');
$I->haveRecord('users', ['email' => '*****@*****.**', 'username' => 'andelabendozy', 'password' => bcrypt('password'), 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'status' => TRUE, 'profile_state' => FALSE]);
$I->submitForm('form#login', ['email' => 'andelabendozy', 'password' => 'password']);
$I->seeCurrentUrlEquals('');
$I->amOnPage('/');
$I->seeAuthentication();
$I->wantTo('logout');
$I->logout();
$I->dontSeeAuthentication();