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 openPageByRoute(FunctionalTester $I) { $I->amOnRoute('front.contact'); $I->see('Contact Us'); $I->see('Send us a message and let us know how we can help.'); $I->seeCurrentUrlEquals('/contact-us'); }
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 canEditMicroblog(FunctionalTester $I) { $fake = Factory::create(); $text = $fake->text(); $id = $I->haveRecord('microblogs', ['user_id' => $this->user->id, 'text' => $text, 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'score' => 0]); $I->amOnRoute('microblog.save', [$id]); $I->see($text); }
public function it_has_permission_in_db_after_registration(FunctionalTester $I) { $I->amOnRoute(RegisterPage::$ROUTE); $userData = $this->userActor->fillRegisterPageFields($I); $I->submitForm(RegisterPage::$formId, [], 'Register'); $user = $I->grabRecord('users', ['username' => $userData['username']]); $permission = Permission::where('name', '=', array_shift(Permission::$defaultPermissions))->first(); $I->seeRecord(UserPermission::$tableName, ['user_id' => $user->id, 'permission_id' => $permission->id]); }
/** * @depends loginSuccessfully */ public function openFregat(\FunctionalTester $I) { $I->setCookie('_identity', $this->cookie_identity); $I->setCookie('PHPSESSID', $this->cookie_session); // $I->click('Fregat/fregat/mainmenu'); $I->amOnRoute('site/index'); $I->see('Система "Фрегат"'); $I->amOnRoute('Fregat/fregat/mainmenu'); $I->see('Справочники'); /* $I->click('//div[contains(text(), "Фрегат")]'); $I->see('Журнал материальных ценностей'); $I->see('Журнал перемещений материальных ценностей'); $I->see('Журнал снятия комплектующих с материальных ценностей'); $I->see('Журнал осмотров материальных ценностей'); $I->see('Журнал осмотров материалов'); $I->see('Журнал восстановления материальных ценностей'); $I->see('Журнал списания основных средств'); $I->see('Импорт данных'); $I->see('Справочники');*/ }
public function it_register_a_valide_user(FunctionalTester $I) { $name = 'joe'; $email = '*****@*****.**'; $password = '******'; $I->amOnRoute('user:register'); $I->fillField('username', $name); $I->fillField('email', $email); $I->fillField('password', $password); $I->fillField('password_confirmation', $password); $I->click(Lang::get('form.register')); //$I->seePageIs(route('home')); //$I->seeInDatabase('users', ['username' => $name, 'email' => $email]); }
<?php $I = new FunctionalTester($scenario); $I->wantTo('Update Article Tests'); // Not signed tests $I->amOnRoute('article.edit', 19); $I->seeCurrentUrlEquals('/auth/login'); // Sign in $I->signIn(); // Update Article $I->amOnRoute('article.edit', 19); $I->see('Edit Article'); $I->fillField('form input[name=title]', 'New Article by FunctionalTester'); $I->selectOption('form select[name=category_id]', '1'); $I->fillField('form textarea[name=body]', 'bodybodybody \\n by FunctionalTester'); $I->click('form [type=submit]'); $I->seeCurrentUrlMatches('~^/article/(\\d+)$~'); $I->seeCurrentRouteIs('article.show', 19);
<?php $I = new FunctionalTester($scenario); $I->wantTo('Add a product to cart'); $product = $I->createModel(DanPowell\Shop\Models\Product::class, [], 'published', 1); $I->amOnRoute('shop.product.show', $product->slug); $I->click('Add to Cart'); $I->seeCurrentRouteIs('shop.cart.show'); $I->see('Product added to cart', '.alert'); $I->see($product->title, '.CartTable-product-title');
<?php /** * ------------------------------------ * Testing User index * ------------------------------------ */ $I = new FunctionalTester($scenario); $I->am('a Phphub member'); $I->wantTo('List all the user are registered for PHPHUB'); $user = $I->have('User', ['name' => 'SuperMeOriganal', 'created_at' => Carbon::now()->toDateTimeString()]); $I->seeRecord('users', ['id' => $user->id]); $I->amOnRoute('users.index'); $I->seeElement('.users-index-' . $user->id);
public function _before(FunctionalTester $I) { $I->haveFixtures(['user' => ['class' => UserFixture::class]]); $I->amOnRoute('site/login'); }
<?php /** * ------------------------------------ * User favorites * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Visit a users.favorites as a Visitor and as a Member.'); $user = $I->have('User'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); $favorite = $I->have('Favorite', ['user_id' => $user->id, 'topic_id' => $topic->id]); // --------------- As a visitor -------------- $I->am('as a Visitor'); $I->amOnRoute('users.favorites', $user->id); $I->see('My Awsome Topic.'); // --------------- As a member -------------- $I->am('as a Member'); $I->signIn(); $I->amOnRoute('users.favorites', $user->id); $I->see('My Awsome Topic.');
<?php /** * ------------------------------------ * User replies * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Visit a users.replies as a Visitor and as a Member.'); $user = $I->have('User'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); $data = ['body' => 'My Awsome Reply.', 'topic_id' => $topic->id, 'user_id' => $user->id]; $reply = $I->have('Reply', $data); // --------------- As a visitor -------------- $I->am('as a Visitor'); $I->amOnRoute('users.replies', $user->id); $I->see('My Awsome Topic.'); $I->see('My Awsome Reply.'); // --------------- As a member -------------- $I->am('as a Member'); $I->signIn(); $I->amOnRoute('users.replies', $user->id); $I->see('My Awsome Topic.'); $I->see('My Awsome Reply.');
public function visitARouteWithASubdomain(FunctionalTester $I) { $I->amOnRoute('subdomain', 'l4'); $I->see('Subdomain route'); }
<?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 /** * ------------------------------------ * 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
<?php /** * ------------------------------------ * Topic creation * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Creating a new topic as a visitor and member.'); // Test Login Redirect $I->am('a Phphub visitor'); $I->amOnRoute('topics.create'); $I->seeCurrentRouteIs('login-required'); // Test as a member $I->signIn(); $I->am('as a Phphub member'); $I->amOnRoute('topics.create'); $I->selectOption('form select[name=node_id]', 'php'); $I->fillField(['name' => 'title'], 'My first post!'); $I->fillField(['name' => 'body'], 'My first post body.'); $I->click('#topic-create-submit'); $I->see('My first post!');
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->wantTo('Create Blog Tests'); // Not signed tests $I->amOnRoute('blog.create'); $I->seeCurrentUrlEquals('/auth/login'); // Sign in $I->signIn(); // Create blog $I->amOnRoute('blog.create'); $I->see('Create Blog'); $I->fillField('form input[name=title]', 'New Blog by FunctionalTester'); $I->selectOption('form select[name=category_id]', '2'); $I->fillField('form textarea[name=body]', 'bodybodybody \\n by FunctionalTester'); $I->click('form [type=submit]'); $I->seeCurrentUrlMatches('~^/blog/(\\d+)$~');
<?php $I = new FunctionalTester($scenario); $I->wantTo('show select page for Catalog'); $I->amOnRoute('catalog-select', ['item' => 'main']); //$I->see('一覧', '#tabAll');
public function checkAbout(FunctionalTester $I) { $I->amOnRoute('/about-us'); $I->see('About us', 'h1'); }
public function deactivate_slide(FunctionalTester $I) { $I->am('Admin'); $I->wantTo('deactivate a slide'); $I->expectTo('see that the user has been deactivated'); /*************************************************************************************************************** * 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->amOnRoute('home.edit'); $I->uncheckOption('#activate_' . $this->_slide->id); $I->submitForm('#form_activate_' . $this->_slide->id, []); $I->seeResponseCodeIs(200); // $I->see(strip_tags(trans('home.message.slide.activation.success.label', ['action' => trans_choice('users.message.activation.success.action', false), 'slide' => $this->_slide->title]))); $I->seeRecord('slides', ['id' => $this->_slide->id, 'active' => false]); }
public function create_account(FunctionalTester $I) { $I->am('Unlogged user'); $I->wantTo('create an account'); $I->expectTo('see a success confirmation message asking to validate the account email'); /*************************************************************************************************************** * run test **************************************************************************************************************/ $I->amOnRoute('account.create'); $I->fillField('last_name', 'COUCOU'); $I->fillField('first_name', 'Test'); $I->fillField('email', '*****@*****.**'); $I->fillField('password', 'password'); $I->fillField('password_confirmation', 'password'); $I->click(trans('auth.account_creation.action.create')); $I->see(trans('global.modal.alert.title.success'), 'h3'); $I->see(trans('auth.message.account_creation.success')); $I->seeInLastEmailTo('*****@*****.**', htmlentities(trans('emails.account_activation.title')), 'h3'); $I->seeInLastEmailTo('*****@*****.**', trans('emails.account_activation.hello', ['name' => 'Test COUCOU']), 'p'); $I->seeInLastEmailTo('*****@*****.**', trans('emails.account_activation.content'), 'p'); $I->seeInLastEmailTo('*****@*****.**', htmlentities(trans('emails.account_activation.button'), ENT_QUOTES), 'button'); }
public function openRouteWithDomainSpecified(FunctionalTester $I) { $I->amOnRoute('domain'); $I->seeResponseCodeIs(200); $I->see('Domain route'); }
<?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 /** * ------------------------------------ * Topic editing function * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Editing a topic as a Visitor, Member and Author.'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); // --------------- As a visitor -------------- $I->am('as a Visitor'); $I->amOnRoute('topics.show', $topic->id); $I->dontSeeElement('#topic-edit-button'); $I->amOnRoute('topics.edit', $topic->id); $I->seeCurrentUrlEquals('/login-required'); // --------------- As a member -------------- $user = $I->signIn(); $I->am('as the author'); $topic = $I->postATopic(['title' => 'My Awsome Topic.', 'user_id' => $user->id]); $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#topic-edit-button'); $I->click('#topic-edit-button'); $I->selectOption('form select[name=node_id]', 'php'); $I->fillField(['name' => 'title'], 'My first post!'); $I->fillField(['name' => 'body'], 'My first post body.'); $I->click('#topic-create-submit'); $I->see('My first post!');
<?php $I = new FunctionalTester($scenario); $I->wantTo('Create Article Tests'); // Not signed tests $I->amOnRoute('article.create'); $I->seeCurrentUrlEquals('/auth/login'); // Sign in $I->signIn(); // Create article $I->amOnRoute('article.create'); $I->see('Create Article'); $I->fillField('form input[name=title]', 'New Article by FunctionalTester'); $I->selectOption('form select[name=category_id]', '1'); $I->fillField('form textarea[name=body]', 'bodybodybody \\n by FunctionalTester'); $I->click('form [type=submit]'); $I->seeCurrentUrlMatches('~^/article/(\\d+)$~');
<?php $I = new FunctionalTester($scenario); $I->wantTo('Update Blog Tests'); // Not signed tests $I->amOnRoute('blog.edit', 47); $I->seeCurrentUrlEquals('/auth/login'); // Sign in $I->signIn(); // Update Blog $I->amOnRoute('blog.edit', 47); $I->see('Edit Blog'); $I->fillField('form input[name=title]', 'New Blog by FunctionalTester'); $I->selectOption('form select[name=category_id]', '2'); $I->fillField('form textarea[name=body]', 'bodybodybody \\n by FunctionalTester'); $I->click('form [type=submit]'); $I->seeCurrentUrlMatches('~^/blog/(\\d+)$~'); $I->seeCurrentRouteIs('blog.show', 47);
<?php /** * ------------------------------------ * 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 /** * ------------------------------------ * Topic Listing * ------------------------------------ */ $I = new FunctionalTester($scenario); $I->am('a Phphub member'); $I->wantTo('List all topics which are created for PHPHUB'); $I->postATopic(['title' => 'Foo']); $I->postATopic(['title' => 'Bar']); $I->amOnRoute('topics.index'); $I->see('Foo'); $I->see('Bar');