public function loginUsingBadLdapCredentials(FunctionalTester $I) { $I->dontSeeAuthentication(); $I->dontSeeRecord('users', $this->userAttributes); LoginPage::of($I)->loginByCredentials(env('LDAP_ADMIN_USER'), 'foo'); $I->dontSeeRecord('users', $this->userAttributes); $I->dontSeeAuthentication(); }
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'); }
/** * @param FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function deleteProject(FunctionalTester $I) { $I->am('Admin User'); $I->wantTo('delete an existing project details'); $project = $I->createProject(1); $admin = $I->createUser(1, 4); $I->amLoggedAs($admin); $I->amOnAction('ProjectController@getEdit', ['project' => $project]); $I->click(trans('tinyissue.delete_something', ['name' => $project->name])); $I->seeCurrentActionIs('ProjectsController@getIndex'); $I->dontSeeLink('Project 1'); $I->amOnAction('ProjectsController@getIndex', ['status' => Project::STATUS_ARCHIVED]); $I->dontSeeLink('Project 1'); $I->dontSeeRecord($project->getTable(), ['name' => 'Project 1']); }
<?php $I = new FunctionalTester($scenario); $I->am('a CMS admin'); $I->wantTo('delete a section'); // When $id = $I->haveSection(); // And $I->amOnPage('admin/sections/' . $id); // Then $I->see('Delete section', 'button.btn-del'); // When $I->click('Delete section'); // Then $I->seeCurrentUrlEquals('/admin/sections'); $I->dontSeeRecord('sections', ['id' => $id]);
<?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');
public function deactivate_user(FunctionalTester $I) { $I->am('Admin'); $I->wantTo('deactivate a user'); $I->expectTo('see that the user has been deactivated'); /*************************************************************************************************************** * 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, true); /*************************************************************************************************************** * run test **************************************************************************************************************/ $I->amOnPage('/'); $I->amOnRoute('users.index'); $I->uncheckOption('#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', false), 'name' => $user->first_name . ' ' . $user->last_name]))); $I->dontSeeRecord('activations', ['user_id' => $user->id, 'completed' => true]); }
<?php $I = new FunctionalTester($scenario); $I->resetEmails(); //setup $I->am('a user'); $I->wantTo('activate my email adress with expired code'); $I->amAuthenticatedWithCredentials(); $I->canSeeAuthentication(); $I->haveRecord('users_confirmations', ['type' => 'mail', 'confirmation_code' => 'KGcClDwrpbZn2XwHJbBTcqf28GrY5O', 'user_id' => 1, 'created_at' => '2015-05-08 00:00:00', 'updated_at' => '2015-05-08 00:00:00']); //step4 $code = $I->grabRecord('users_confirmations', ['user_id' => 1, 'type' => 'mail']); $I->amOnPage('/confirmation/mail/' . $code->confirmation_code); $I->seeElement('#submit-mail-code'); $I->dontSeeRecord('users_profiles', ['user_id' => 1, 'mail_confirmed' => 1]);
<?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]');
/** * ------------------------------------ * Attenting a topic * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Attent a Topic discussion 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('#topic-attent-button'); $I->seeCurrentUrlEquals('/login-required'); // --------------- As a member -------------- $user = $I->signIn(); $I->am('as a Member'); // -- attent $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#topic-attent-button'); $I->click('#topic-attent-button'); $I->see('My Awsome Topic.'); $I->seeRecord('attentions', ['topic_id' => $topic->id, 'user_id' => $user->id]); // -- cancel attent $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#topic-attent-cancel-button'); $I->click('#topic-attent-cancel-button'); $I->see('My Awsome Topic.'); $I->dontSeeRecord('attentions', ['topic_id' => $topic->id, 'user_id' => $user->id]);
<?php use Coyote\Actkey; $I = new FunctionalTester($scenario); $I->wantTo('confirm my email address'); $userId = 100001; $actkey = 'randomstring'; $I->haveRecord('users', ['id' => $userId, 'name' => 'Joe Doe', 'email' => '*****@*****.**', 'password' => bcrypt('123'), 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'is_confirm' => 0]); // uzywamy modelu poniewaz w tabeli nie ma klucza "id" Actkey::create(['actkey' => $actkey, 'user_id' => $userId]); $I->amOnPage("/User/Confirm/Email?id={$userId}&actkey={$actkey}"); $I->see('Adres e-mail został pozytywnie potwierdzony'); $I->dontSeeRecord('actkeys', ['actkey' => $actkey, 'user_id' => $userId]);
<?php /** * Created by PhpStorm. * User: bill * Date: 16.02.15 * Time: 16:06 */ use app\modules\mobile\models\Document; Document::deleteAll(); $I = new FunctionalTester($scenario); $I->wantTo('ensure that remove document works'); $id = Document::getCollection()->insertFile(\Yii::getAlias('@data') . '/file1.jpg'); $I->seeRecord(Document::className(), ['_id' => $id]); $I->amOnPage(['mobile/number/detach-document', 'id' => (string) $id]); $I->dontSeeRecord(Document::className(), ['_id' => $id]);
/** * ------------------------------------ * Topic deletion * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Delete a topic as a visitor, normal member and admin.'); $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-delete-button'); $I->amOnRoute('topics.delete', $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-delete-button'); $I->amOnRoute('topics.delete', $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-delete-button'); $I->click('#topic-delete-button'); $I->seeCurrentRouteIs('topics'); $I->dontSeeRecord('topics', ['id' => $topic->id]);
/** * ------------------------------------ * Favorite a topic * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Favorite a 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('#topic-favorite-button'); $I->seeCurrentUrlEquals('/login-required'); // --------------- As a member -------------- $user = $I->signIn(); $I->am('as a Member'); // -- favorite $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#topic-favorite-button'); $I->click('#topic-favorite-button'); $I->see('My Awsome Topic.'); $I->seeRecord('favorites', ['topic_id' => $topic->id, 'user_id' => $user->id]); // -- cancel favorite $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#topic-favorite-cancel-button'); $I->click('#topic-favorite-cancel-button'); $I->see('My Awsome Topic.'); $I->dontSeeRecord('favorites', ['topic_id' => $topic->id, 'user_id' => $user->id]);
<?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);
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]); }
/** * ------------------------------------ * Reply deletion * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Delete a reply as a visitor, normal member and admin.'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); $reply = $I->have('Reply', ['topic_id' => $topic->id]); // Testing as a visitor $I->am('as a visitor'); $I->amOnRoute('topics.show', $topic->id); $I->dontSeeElement('#reply-delete-' . $reply->id); $I->amOnRoute('topics.delete', $topic->id); $I->seeCurrentRouteIs('login-required'); // Test as a normal member $I->am('as a member'); $I->signIn(); $I->dontSeeElement('#reply-delete-' . $reply->id); $I->amOnRoute('topics.delete', $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('#reply-delete-' . $reply->id); $I->click('#reply-delete-' . $reply->id); $I->dontSeeRecord('replies', ['id' => $reply->id]);
<?php $I = new FunctionalTester($scenario); $I->wantTo('create and delete a user'); $user = ['email' => '*****@*****.**', 'password' => 'password', 'password_confirmation' => 'password']; $I->dontSeeRecord('users', ['email' => '*****@*****.**']); $parameter = ['email' => $user['email'], '--password' => $user['password'], '--password_confirmation' => $user['password_confirmation']]; $I->runConsoleCommand('user:create', array_replace($parameter, ['email' => 'invalidformat'])); $I->dontSeeRecord('users', ['email' => '*****@*****.**']); $I->runConsoleCommand('user:create', $parameter); $I->seeRecord('users', ['email' => '*****@*****.**']); $I->runConsoleCommand('user:delete', ['email' => '*****@*****.**']); $I->seeInLastCommandOutput('Did not find a user with'); $I->runConsoleCommand('user:delete', ['email' => '*****@*****.**']); $I->dontSeeRecord('users', ['email' => '*****@*****.**']);