public function it_successfully_sends_password_reset_mail_link(FunctionalTester $I) { $I->amOnRoute(PasswordResetPage::$ROUTE); $I->fillField('email', '*****@*****.**'); $I->submitForm(PasswordResetPage::$formId, [], PasswordResetPage::$submit); $I->see('Reset link was successfully sent. Please check your email.'); $I->seeRecord('password_resets', ['email' => '*****@*****.**']); }
public function createUser(FunctionalTester $I) { $I->amOnRoute('site/login'); $I->submitForm($this->loginFormId, $this->loginFormParams('*****@*****.**', '123123')); $I->amOnRoute('/admin/user/create'); $I->see('Create User'); $I->submitForm($this->createUserFormId, $this->createUserFormParams('created-user', '*****@*****.**', '123123')); $I->seeRecord('app\\models\\UserModel', ['username' => 'created-user', 'email' => '*****@*****.**']); }
public function testValidRegistration(FunctionalTester $I) { $I->fillField('name', $this->tester['name']); $I->fillField('email', $this->tester['email']); $I->fillField('password', $this->tester['password']); $I->fillField('password_confirmation', $this->tester['password']); $I->click('Register', 'button'); $I->dontSeeFormErrors(); $I->seeRecord('users', ['name' => $this->tester['name'], 'email' => $this->tester['email']]); $I->seeAuthentication(); }
/** * @param FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function addTag(FunctionalTester $I) { $I->am('Admin User'); $I->wantTo('add new tag'); $tag = new Tag(); $group = $tag->getGroups()->random(1); $data = ['name' => 'tag1', 'group' => $group->id, 'bgcolor' => 'red']; $I->amLoggedAs($I->createUser(1, 4)); $I->amOnAction('Administration\\TagsController@getNew'); $I->submitForm('form', $data); $I->seeCurrentActionIs('Administration\\TagsController@getIndex'); $I->seeRecord($tag->getTable(), $data); }
public function tryToResetPasswordWithValidToken(FunctionalTester $I) { $I->seeRecord('password_resets', ['email' => '*****@*****.**']); $I->wantTo('Reset my password invalid token'); $I->amOnPage('/password/reset/reset-token'); $I->fillField('email', '*****@*****.**'); $I->fillField('password', '123456'); $I->fillField('password_confirmation', '123456'); $I->click('button[type=submit]'); $I->dontSeeRecord('password_resets', ['email' => '*****@*****.**']); $I->seeAuthentication(); $I->seeCurrentUrlEquals('/admin/dashboard'); }
public function tryRegisterDesiredInputWithDefaultRole(FunctionalTester $I) { $I->haveRecord('roles', ['id' => 2, 'name' => 'Spectator', 'slug' => 'spectator', 'landing' => 'admin/profile', 'is_default' => true, 'created_at' => new DateTime(), 'updated_at' => new DateTime()]); $I->wantTo('Register a user with desired input'); $I->amOnPage('/register'); $I->fillField('username', 'usertest'); $I->fillField('email', '*****@*****.**'); $I->fillField('password', '123456'); $I->fillField('password_confirmation', '123456'); $I->click('button[type=submit]'); $I->seeRecord('users', ['username' => 'usertest']); $I->seeCurrentUrlEquals('/login'); }
public function it_successfully_detaches_permission(FunctionalTester $I) { $user = $this->userActor->create(); $permission = 'accessDashboard'; $permissionId = Permission::where('name', '=', $permission)->firstOrFail()->id; $user->setRole('admin'); $I->assertTrue($user->attachPermission($permission)); $I->seeRecord($this->UPT, ['user_id' => $user->id, 'permission_id' => $permissionId]); $user->detachPermission($permission); $I->dontSeeRecord($this->UPT, ['user_id' => $user->id, 'permission_id' => $permissionId]); }
<?php $I = new FunctionalTester($scenario); $I->wantTo('manually shorten a url'); $I->amOnPage('/'); $I->fillField('.shortInput', 'http://www.example.com'); $I->click('Go'); $I->amOnPage('/'); $I->see('http://localhost', '.result'); $hash = $I->grabTextFrom('~http://localhost/([^\\<]+)~'); $I->seeRecord('urls', ['url' => 'http://www.example.com', 'hash' => $hash]);
<?php $I = new FunctionalTester($scenario); $I->am('a Administrator user'); $I->dontSeeAuthentication(); $I->amLoggedAs(['email' => '*****@*****.**', 'password' => 'admin']); $I->seeAuthentication(); //When $I->amOnPage('/settings/users'); //And $I->click('Create'); //Then $I->seeCurrentUrlEquals('/settings/users/create'); //when $form = ['name' => 'Mario', 'email' => '*****@*****.**']; //And $I->submitForm('//form', $form, 'Save'); //Then $I->seeFormErrorMessage('password', 'The Password field is required.'); //When $form = ['name' => 'Mario', 'email' => '*****@*****.**', 'password' => '123456', 'password_confirmation' => '123456']; //and $I->submitForm('//form', $form, 'Save'); //then $I->seeCurrentUrlEquals('/settings/users'); $I->see('Mario'); $I->seeRecord('users', ['name' => 'Mario', 'email' => '*****@*****.**']);
<?php $I = new FunctionalTester($scenario); //setup $I->am('a guest'); $I->wantTo('register an account'); //action $I->amOnPage('/register'); $I->see('Inscription'); $I->fillField(['name' => 'firstname'], 'John'); $I->fillField(['name' => 'lastname'], 'Doe'); $I->fillField(['name' => 'email'], '*****@*****.**'); $I->fillField(['name' => 'password'], 'password'); $I->fillField(['name' => 'password_confirmation'], 'password'); $I->click('submit-register'); //verify $I->canSeeAuthentication(); $I->seeRecord('users', array('email' => '*****@*****.**'));
$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]);
<?php /** * ------------------------------------ * Testing User Show * ------------------------------------ */ $I = new FunctionalTester($scenario); $I->am('as a visitor'); $I->wantTo('See a user profile.'); $user = $I->have('User', ['name' => 'SuperMeOriganal2', 'created_at' => Carbon::now()->toDateTimeString()]); $I->seeRecord('users', ['id' => $user->id]); $I->amOnRoute('users.show', $user->id); $I->see('SuperMeOriganal2');
<?php $I = new FunctionalTester($scenario); $I->wantTo('Sign up for a larabook account'); $I->amOnPage('/'); $I->click('Sign Up!'); $I->seeCurrentUrlEquals('/register'); $I->fillField('username', 'JohnDoe'); $I->fillField('email', '*****@*****.**'); $I->fillField('password', 'demo'); $I->fillField('password_confirmation', 'demo'); $I->click('Sign Up'); $I->seeCurrentUrlEquals(''); $I->see('Welcome to Larabook!'); $I->seeRecord('users', [ 'username' => 'JohnDoe', 'email' => '*****@*****.**' ]);
public function get_forgotten_password_email_with_recorded_email(FunctionalTester $I) { $I->am('Unlogged user'); $I->wantTo('receive my password reset email by using the forgotten password feature'); $I->expectTo('see a success confirmation message explaining that the e-mail has been sent'); /*************************************************************************************************************** * settings **************************************************************************************************************/ $I->resetEmails(); /*************************************************************************************************************** * run test **************************************************************************************************************/ $I->amOnPage('/'); $I->seeCurrentRouteIs('home'); $I->click(trans('template.front.header.my_account')); $I->seeCurrentRouteIs('login.index'); $I->fillField('email', $this->_user->email); $I->fillField('password', 'truc'); $I->click(trans('auth.login.action.login')); $I->seeCurrentRouteIs('login.index'); $I->see(trans('global.modal.alert.title.error')); $I->click(trans('auth.login.label.forgotten_password')); $I->seeCurrentRouteIs('password.index'); $I->seeInField('email', $this->_user->email); $I->click(trans('auth.password.forgotten.action.send')); $I->see(trans('global.modal.alert.title.success'), 'h3'); $I->see(strip_tags(trans('auth.message.password_reset.email.success', ['email' => '*****@*****.**']))); $I->seeCurrentRouteIs('login.index'); $I->seeRecord('reminders', ['user_id' => $this->_user->id, 'completed' => false]); $I->seeInLastEmailTo($this->_user->email, htmlentities(trans('emails.password_reset.title')), 'h3'); $I->seeInLastEmailTo($this->_user->email, htmlentities(trans('emails.password_reset.hello', ['name' => $this->_user->first_name . ' ' . $this->_user->last_name])), 'p'); $I->seeInLastEmailTo($this->_user->email, trans('emails.password_reset.content'), 'p'); $I->seeInLastEmailTo($this->_user->email, htmlentities(trans('emails.password_reset.button')), 'button'); }
<?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();
<?php $I = new FunctionalTester($scenario); $I->resetEmails(); //setup $I->am('a user'); $I->wantTo('activate my email adress'); $I->amAuthenticatedWithCredentials(); $I->canSeeAuthentication(); $I->amOnPage('/confirmation'); //action //step1 $I->click('#submit-mail-code'); //step2 $I->seeInLastEmail('*****@*****.**'); $I->seeInLastEmail('Confirmation Code'); //step3 $I->seeRecord('users_confirmations', ['user_id' => 1, 'type' => 'mail']); //step4 $code = $I->grabRecord('users_confirmations', ['user_id' => 1, 'type' => 'mail']); $I->amOnPage('/confirmation/mail/' . $code->confirmation_code); $I->dontSee('#submit-mail-code'); $I->seeRecord('users_profiles', ['user_id' => 1, 'mail_confirmed' => 1]);
public function activate_user(FunctionalTester $I) { $I->am('Admin'); $I->wantTo('activate a user'); $I->expectTo('see that the user has been activated'); /*************************************************************************************************************** * settings **************************************************************************************************************/ // we create the admin role $admin_role = $this->_createAdminRole(); $admin_role->users()->attach($this->_user); // we create another user $credentials = ['last_name' => 'Autre', 'first_name' => 'autre', 'email' => '*****@*****.**', 'password' => 'autre']; $user = \Sentinel::register($credentials); /*************************************************************************************************************** * run test **************************************************************************************************************/ $I->amOnPage('/'); $I->amOnRoute('users.index'); $I->checkOption('#activate_' . $user->id); $I->submitForm('#form_activate_' . $user->id, []); $I->seeResponseCodeIs(200); // $I->see(strip_tags(trans('users.message.activation.success.label', ['action' => trans_choice('users.message.activation.success.action', true), 'name' => $user->first_name . ' ' . $user->last_name]))); $I->seeRecord('activations', ['user_id' => $user->id, 'completed' => true]); }
<?php $I = new FunctionalTester($scenario); // Prep $sentry = $I->grabService('sentry'); $user = $sentry->findUserByLogin('*****@*****.**'); // Test $I->amActingAs('*****@*****.**'); $I->wantTo('edit my own profile'); $I->amOnPage('/users/' . $user->id . '/edit'); $I->seeElement('form', ['class' => 'form-horizontal']); $I->fillField('first_name', 'Irina'); $I->fillField('last_name', 'Sergeyevna'); $I->click('Submit Changes'); $I->seeRecord('users', ['email' => '*****@*****.**', 'first_name' => 'Irina', 'last_name' => 'Sergeyevna']);
<?php $I = new FunctionalTester($scenario); $I->wantTo('register as a new user'); $I->amOnPage('/register'); $I->fillField('username', 'tuzenbach'); $I->fillField('email', '*****@*****.**'); $I->fillField('password', 'irina99'); $I->fillField('password_confirmation', 'irina99'); $I->click('Register', '.btn'); $I->see('Your account has been created.'); $I->seeRecord('users', ['email' => '*****@*****.**', 'username' => 'tuzenbach']);
// 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'); $I->see('Our company', 'h1'); $I->seeRecord('sections', ['name' => 'Our company', 'menu_order' => 2, 'menu' => 1, 'published' => 0]);
<?php $I = new FunctionalTester($scenario); $I->wantTo('register a user'); $I->amOnPage('/auth/register'); $I->fillField('name', 'John Doe'); $I->fillField('email', '*****@*****.**'); $I->fillField('password', 'password'); $I->fillField('password_confirmation', 'password'); $I->click('button[type=submit]'); $I->amOnPage('/'); $I->seeRecord('users', ['email' => '*****@*****.**']); $I->seeAuthentication();
<?php $I = new FunctionalTester($scenario); // Prep $sentry = $I->grabService('sentry'); $user = $sentry->findUserByLogin('*****@*****.**'); // Test $I->amActingAs('*****@*****.**'); $I->wantTo('create a new group'); $I->amOnPage('/groups/create'); $I->seeElement('input', ['class' => 'form-control', 'name' => 'name']); $I->fillField('name', 'Prozorovs'); $I->click('Create New Group'); $I->seeRecord('groups', ['name' => 'Prozorovs']);
<?php $I = new FunctionalTester($scenario); // Prep $sentry = $I->grabService('sentry'); $user = $sentry->findUserByLogin('*****@*****.**'); $group = $sentry->findGroupByName('Users'); // Test $I->amActingAs('*****@*****.**'); $I->wantTo('edit a group name'); $I->amOnPage('/groups/' . $group->id . '/edit'); $I->seeElement('input', ['class' => 'form-control', 'name' => 'name']); $I->fillField('name', 'Prozorovs'); $I->click('Save Changes'); $I->seeRecord('groups', ['name' => 'Prozorovs', 'id' => $group->id]);
<?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']);
* Pin a topic to top * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Pin a topic on Top of the topic default list'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); // Testing as a visitor $I->am('a Phphub visitor'); $I->amOnRoute('topics.show', $topic->id); $I->dontSeeElement('#topic-pin-button'); $I->amOnRoute('topics.pin', $topic->id); $I->seeCurrentRouteIs('login-required'); // Test as a normal member $I->am('a Phphub member'); $I->signIn(); $I->amOnRoute('topics.show', $topic->id); $I->dontSeeElement('#topic-pin-button'); $I->amOnRoute('topics.pin', $topic->id); $I->seeCurrentRouteIs('admin-required'); // Testing as a admin user $I->am('a Phphub admin'); $I->signInAsAdmin(); $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#topic-pin-button'); $I->click('#topic-pin-button'); // check the list $I->amOnRoute('topics.index'); $I->seeElement('#pin-' . $topic->id); $I->seeRecord('topics', ['id' => $topic->id, 'order' => 1]);
<?php $I = new FunctionalTester($scenario); $I->am('a guest'); $I->wantTo('Sign up for a Socializer account'); $I->amOnPage('/'); $I->click('Tilmeld dig'); $I->seeCurrentUrlEquals('/register'); $I->fillField('Email:', '*****@*****.**'); $I->fillField('Password:'******'123456'); $I->fillField('Password (gentag):', '123456'); $I->click('Tilmeld'); $I->seeCurrentUrlEquals(''); $I->see('Velkommen til Socializer'); $I->seeRecord('users', ['email' => '*****@*****.**']); $I->assertTrue(Auth::check());
<?php /** * ------------------------------------ * Notify user being "@" * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Notify a User when he/she is being AT on a newly Reply'); $SuperMan = $I->have('User', ['name' => 'SuperMan']); $user = $I->signIn(); $topic = $I->postATopic(['title' => 'My Awsome Topic.', 'user_id' => $user->id]); // another user leave a reply $randomUser = $I->signIn(); $I->amOnRoute('topics.show', $topic->id); $I->fillField(['name' => 'body'], 'The Awsome Reply. @SuperMan'); $I->click('#reply-create-submit'); $I->see('The Awsome Reply. <a href="' . route('users.show', $SuperMan->id) . '">@SuperMan</a>'); // sign in the author $user = $I->signIn($SuperMan); $I->seeRecord('users', ['id' => $user->id, 'notification_count' => 1]); $I->amOnRoute('notifications.index'); $I->see('My Awsome Topic.'); $I->see('The Awsome Reply. <a href="' . route('users.show', $SuperMan->id) . '">@SuperMan</a>'); $I->see($randomUser->name); $I->seeRecord('users', ['id' => $user->id, 'notification_count' => 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'));
<?php $I = new FunctionalTester($scenario); $I->wantTo('flush old devices'); $piOne = ['ip' => '192.168.1.101', 'mac' => '11:22:33:44:55:66', 'name' => 'Awesome Pi One', 'created_at' => (new \Carbon\Carbon())->subHour()->toDateTimeString(), 'updated_at' => (new \Carbon\Carbon())->subHour()->toDateTimeString()]; $I->haveRecord('devices', $piOne); $piTwo = ['ip' => '192.168.1.102', 'mac' => '11:22:33:44:55:67', 'name' => 'Awesome Pi Two', 'created_at' => (new \Carbon\Carbon())->subHour()->toDateTimeString(), 'updated_at' => (new \Carbon\Carbon())->now()->toDateTimeString()]; $I->haveRecord('devices', $piTwo); $I->assertEquals(2, \PiFinder\Device::count()); $I->runConsoleCommand('pi:flush'); $I->assertEquals(1, \PiFinder\Device::count()); $I->dontSeeRecord('devices', $piOne); $I->seeRecord('devices', $piTwo);
<?php /** * ------------------------------------ * Down vote a topic * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Down Vote Topic as a visitor and a menber.'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); // --------------- As a visitor -------------- $I->am('as a Visitor'); $I->amOnRoute('topics.show', $topic->id); $I->click('#down-vote'); $I->seeCurrentUrlEquals('/login-required'); // --------------- As a member -------------- $user = $I->signIn(); $I->am('as a Member'); $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#down-vote'); $I->click('#down-vote'); $I->see('My Awsome Topic.'); $I->seeRecord('topics', ['id' => $topic->id, 'vote_count' => -1]);