public function checkCorrectChangePassword(FunctionalTester $I) { $I->submitForm('#login-form', $this->loginFormParams('*****@*****.**', '123123')); $I->click('My Account'); $I->submitForm('#change-password-form', $this->resetPasswordFormParams('123456', '123456')); $I->see('Password has been updated.'); }
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 submitFormSuccessfully(\FunctionalTester $I) { $I->submitForm('#contact-form', ['ContactForm[name]' => 'tester', 'ContactForm[email]' => '*****@*****.**', 'ContactForm[subject]' => 'test subject', 'ContactForm[body]' => 'test content', 'ContactForm[verifyCode]' => 'testme']); $I->seeEmailIsSent(); $I->dontSeeElement('#contact-form'); $I->see('Thank you for contacting us. We will respond to you as soon as possible.'); }
public function checkValidLogin(FunctionalTester $I) { $I->submitForm('#login-form', $this->formParams('*****@*****.**', '123123')); $I->see('Logout (admin)', 'form button[type=submit]'); $I->dontSeeLink('Login'); $I->dontSeeLink('Signup'); }
public function it_validates_required_fields(FunctionalTester $I) { //For coverage $I->amOnRoute(RegisterPage::$ROUTE); $I->submitForm(RegisterPage::$formId, [], 'Register'); $I->see('The username field is required.'); $I->see('The email field is required.'); $I->see('The password field is required.'); $I->dontSee('The name field is required.'); }
public function checkAdminPanel(FunctionalTester $I) { $I->submitForm($this->formId, $this->formParams('*****@*****.**', '123123')); $I->see('Logout (admin)', 'form button[type=submit]'); $I->seeLink('Administration'); $I->click('Administration'); $I->see('Users'); $I->seeLink('CMS'); $I->seeLink('RBAC'); $I->seeLink('Settings Storage'); $I->seeLink('Cron Schedule Log'); }
/** * @param FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function addNote(FunctionalTester $I) { $I->am('Admin User'); $I->wantTo('add new note to a project'); $admin = $I->createUser(1, 4); $I->amLoggedAs($admin); $project = $I->createProject(1); $I->amOnAction('ProjectController@getNotes', ['project' => $project]); $I->submitForm('#new-note form', ['note_body' => 'note one']); $I->amOnAction('ProjectController@getNotes', ['project' => $project]); $I->see('note one', '//li[@id="note' . $project->notes()->first()->id . '"]'); }
public function loginSuccessfully(\FunctionalTester $I) { $I->amOnRoute('site/login'); $I->submitForm('#login-form', ['LoginForm[username]' => 'admin', 'LoginForm[password]' => 'admin']); $I->see('Главное меню'); $I->see('Система "Фрегат"'); $I->see('Регистр глаукомных пациентов'); $I->see('Настройки портала'); $I->see('Сменить пароль'); $I->dontSeeElement('form#login-form'); $I->canSeeCookie('_identity'); $I->canSeeCookie('PHPSESSID'); $this->cookie_identity = $I->grabCookie('_identity'); $this->cookie_session = $I->grabCookie('PHPSESSID'); }
/** * @param FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function updateTag(FunctionalTester $I) { $I->am('Admin User'); $I->wantTo('edit an existing tag'); $tag = (new Tag())->where('group', '=', false)->get()->random(1); $data = ['name' => 'tag updated']; $tagName = $tag->name; $I->amLoggedAs($I->createUser(1, 4)); $I->amOnAction('Administration\\TagsController@getIndex'); $I->click($this->_editTagSelector($tagName)); $I->seeCurrentActionIs('Administration\\TagsController@getEdit', ['tag' => $tag]); $I->submitForm('form', $data); $I->amOnAction('Administration\\TagsController@getIndex'); $I->see($data['name'], $this->_editTagSelector($data['name'])); $I->dontSee($data['name'], $this->_editTagSelector($tagName)); }
<?php use Laracasts\TestDummy\Factory; $I = new FunctionalTester($scenario); $I->am('talent4startups member'); $I->wantTo('login to my talent4startups account'); $user = Factory::create('App\\Models\\User', ['password' => 'password']); $I->amOnPage('/'); $I->click('#login-link'); $I->canSeeCurrentUrlEquals('/auth/login'); $I->submitForm('form', ['email' => $user->email, 'password' => '']); $I->dontSeeAuthentication(); $I->submitForm('form', ['email' => $user->email, 'password' => 'wrong_password']); $I->dontSeeAuthentication(); $I->submitForm('form', ['email' => $user->email, 'password' => 'password']); $I->amLoggedAs($user);
<?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' => '*****@*****.**']);
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]); }
<?php $I = new FunctionalTester($scenario); $I->wantTo('Add a product to cart that has low stock'); $product = $I->createModel(DanPowell\Shop\Models\Product::class, [], 'inStock', 1); $I->amOnRoute('shop.product.show', $product->slug); $I->submitForm('#addToCart', ['quantity' => 15]); $I->dontSee('Product added to cart'); $I->see('not enough product stock'); $I->seeFormHasErrors();
<?php $I = new FunctionalTester($scenario); $I->am('Registered LAZ User'); $I->wantTo('Post a new News Post on my timeline'); $I->amLoggedAs(['email' => '*****@*****.**', 'password' => 'password']); $I->seeAuthentication(); $I->amOnPage('/home'); $I->submitForm('#prevent', ['UserPosting' => 'JonDoe', 'UserPostingID' => '100', 'BaseComment' => 'We love big baconator from wendys'], 'Post'); $I->see('Posted Successfully');
/** * Sign up for a new user account with the given details. * @param \AcceptanceTester|\FunctionalTester $I * @param string $fields */ public static function signup($I, $fields) { $I->submitForm('#signup-form', ['SignupForm[email]' => $fields['email'], 'SignupForm[password]' => $fields['password'], 'SignupForm[forename]' => $fields['forename'], 'SignupForm[surname]' => $fields['surname']]); }
public function it_successfully_changes_password_from_password_change_form(FunctionalTester $I) { $email = '*****@*****.**'; //Existing record in DB $resetRecord = $I->grabRecord('password_resets', ['email' => $email]); $I->amOnPage(PasswordChangePage::$PAGE_PLAIN . $resetRecord->token); $I->fillField('email', $email); $I->fillField('password', '123456'); $I->fillField('password_confirmation', '123456'); $I->submitForm(PasswordChangePage::$formId, [], PasswordChangePage::$submit); $I->see('Password successfully reset. You can now login.'); }
<?php $I = new FunctionalTester($scenario); $I->wantTo('create a currency without data'); $I->am('a Administrator user'); $I->dontSeeAuthentication(); $I->amLoggedAs(['email' => '*****@*****.**', 'password' => 'admin']); $I->seeAuthentication(); //When $I->amOnPage('/settings/currency'); //And $I->see('Create'); $I->click('Create'); //Then $I->seeCurrentUrlEquals('/settings/currency/create'); //When $form = ['name' => '', 'symbol' => '']; //And $I->submitForm('//form', $form, 'Create'); //Then $I->seeFormErrorMessage('name', 'The name field is required.'); //
/** *Submit the volunteer form * @param \AcceptanceTester|\FunctionalTester $I * @param string $fields */ public static function submit($I, $fields) { $I->submitForm('#volunteer-form', ['VolunteerForm[interests]' => $fields['interests'], 'VolunteerForm[experience]' => $fields['experience'], 'VolunteerForm[availability]' => $fields['availability'], 'VolunteerForm[daysAvailable]' => $fields['daysAvailable'], 'VolunteerForm[skills]' => $fields['skills'], 'VolunteerForm[mobile]' => $fields['mobile']]); }
/** * Submit the project create/update form directly, without filling in * fields. New images cannot be submitted via this method, but it bypasses * certain field constraints. * @param \AcceptanceTester|\FunctionalTester $I * @param array $data */ public static function submitData($I, $data) { $I->submitForm('#project-form', ['Project[name]' => $data['name'], 'Project[coordinator]' => $data['coordinator'], 'Project[status]' => $data['status']]); }
/** * Login with the given details. * @param \AcceptanceTester|\FunctionalTester $I * @param string $email * @param string $password */ public static function login($I, $email, $password) { $I->submitForm('#login-form', ['LoginForm[email]' => $email, 'LoginForm[password]' => $password]); }
<?php $I = new FunctionalTester($scenario); $I->wantTo('Add a product to cart that has bad options'); $product = $I->createModel(DanPowell\Shop\Models\Product::class, [], 'inStock', 1); $options[] = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'radio', 1); $options[] = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'select', 1); $options[] = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'text', 1); $product->options()->saveMany($options); $I->amOnRoute('shop.product.show', $product->slug); $I->submitForm('#addToCart', ['option[' . $options[0]->id . ']' => '23', 'option[' . $options[1]->id . ']' => 'rewe', 'option[' . $options[2]->id . ']' => 'Testing']); $I->dontSee('Product added to cart', '.alert'); $I->seeCurrentRouteIs('shop.product.show'); $I->seeFormHasErrors();
<?php $I = new FunctionalTester($scenario); $I->wantTo('perform actions and see result'); $I->amOnPage('/login'); $I->see('Sign Up With Google'); $I->click('.google-button'); $I->see('Sign Up With Github'); $I->click('.gitbub-button'); $I->see('Sign Up With Facebook'); $I->see('Login'); $I->submitForm('#login-form', ['email' => 'Davert', 'password' => '123456', 'remember' => true], 'Login');
$I->seeElement('input[type="checkbox"].checkbox-select-all'); $I->seeElement('input[type="checkbox"].checkbox-select-all-item'); $I->seeElement('form#batch input[type="hidden"][name="action"]'); $I->seeElement('form#batch input[type="hidden"][name="action_type"]'); $I->see('Action for selected', 'form#batch button.dropdown-toggle'); $I->see('Action for all', 'form#batch button.dropdown-toggle'); $I->see('Set status New', 'div#batch-selected'); $I->see('Halt message', 'div#batch-selected'); $I->see('Cancel message', 'div#batch-selected'); $I->see('Reset GUIDs', 'div#batch-selected'); $I->see('Set status New', 'div#batch-all'); $I->see('Halt message', 'div#batch-all'); $I->see('Cancel message', 'div#batch-all'); $I->see('Reset GUIDs', 'div#batch-all'); # sending batch form with no action selected $I->submitForm('form[name="batch"]', []); $I->see('Please select batch action.', '.alert-danger'); # sending batch form with no action type selected $I->submitForm('form[name="batch"]', ['action' => 'new']); $I->see('Please select batch action type.', '.alert-danger'); # sending batch form with no Messages selected //$I->submitForm('form[name="batch"]', ['action' => 'ready', 'action_type' => 'selected']); //$I->see('Please select at least one Message.', '.alert-danger'); $I->see('New', 'table tr[class="status-new"] td'); $I->see('Cancelled', 'table tr[class="status-cancelled"] td'); $I->see('Halted', 'table tr[class="status-halted"] td'); $I->dontSee('Finished', 'table tr[class="status-halted"] td'); $I->dontSee('Error', 'table tr[class="status-halted"] td'); # sending batch form with action for all items $I->submitForm('form[name="batch"]', ['action' => 'new', 'action_type' => 'all']); $I->see('New', 'table tr[class="status-new"] td');
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('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->wantTo('Add a product to cart that has bad extras'); // Create the models $product = $I->createModel(DanPowell\Shop\Models\Product::class, [], 'inStock', 1); // Extra 1 - This extra has a few options and will be selected $extra1 = $I->makeModel(DanPowell\Shop\Models\Extra::class, [], 'inStock', 1); $extra1 = $product->extras()->save($extra1); $option1 = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'text', 1); $option1 = $extra1->options()->save($option1); $I->amOnRoute('shop.product.show', $product->slug); // Select the extra 1, but DON'T fill out the option value $I->checkOption('extra[' . $extra1->id . ']'); $I->submitForm('#addToCart', []); $I->dontSee('Product added to cart', '.alert'); $I->seeCurrentRouteIs('shop.product.show'); $I->seeFormHasErrors();
<?php $I = new FunctionalTester($scenario); $I->wantTo('I am Admin and Delete a new currency'); $I->dontSeeAuthentication(); $I->amLoggedAs(['email' => '*****@*****.**', 'password' => 'admin']); $I->seeAuthentication(); $I->amOnPage('/settings/currency/create'); //when $form = ['name' => 'Mau', 'symbol' => '@']; //And $id = $I->haveRecord('currencys', ['name' => 'Mau', 'symbol' => '@']); //And $I->amOnPage('/settings/currency/' . $id); //then $I->see('Delete'); //When $I->submitForm('//form', ['id' => $id], 'Delete'); $I->seeCurrentUrlEquals('/settings/currency');
$product->options()->saveMany($options); // Create another product so we can try and force it's option on to the 'correct' product $unrelatedProduct = $I->createModel(DanPowell\Shop\Models\Product::class, [], 'inStock', 1); $unrelatedOption = $I->makeModel(DanPowell\Shop\Models\Option::class, [], 'select', 1); $unrelatedProduct->options()->save($unrelatedOption); $I->amOnRoute('shop.product.show', $product->slug); // Randomly choose the option values $option_values = []; foreach ($options as $option) { if ($option->type == 'radio' || $option->type == 'select') { $option_values[$option->id] = $option->config[array_rand($option->config)]; $I->selectOption('option[' . $option->id . ']', $option_values[$option->id]); } else { $option_values[$option->id] = "Testing"; $I->fillField('option[' . $option->id . ']', "Testing"); } } // Submit the form $I->submitForm('#addToCart', ['option[' . $unrelatedOption->id . ']' => $unrelatedOption->config[0]]); $I->seeCurrentRouteIs('shop.cart.show'); // Check that we see the product $I->see('Product added to cart', '.alert'); $I->see($product->title, '.CartTable-product-title'); // Check that the selected options have been sent through foreach ($options as $option) { $I->see($option->title, '.CartTable-item-options'); $I->see($option_values[$option->id], '.CartTable-item-options'); } // Check that the unrelated option we forced through has *not* appeared $I->dontSee($unrelatedOption->title, '.CartTable-item-options'); $I->dontSee($unrelatedOption->config[0], '.CartTable-item-options');
/** * Submit the password reset request for the given email. * @param \AcceptanceTester|\FunctionalTester $I * @param string $email */ public static function submitEmail($I, $email) { $I->submitForm('#request-password-reset-form', ['PasswordResetRequestForm[email]' => $email]); }
<?php $I = new FunctionalTester($scenario); $I->am('an administrator'); $I->wantTo('add a new user'); Auth::loginUsingId(1); $I->amOnPage('/admin/users/create'); $I->submitForm('//form', ['name' => 'Tom', 'email' => '*****@*****.**']); $I->see('En epost er sendt'); $I->seeInDatabase('users', ['email' => '*****@*****.**', 'rights' => '[]']);