/** * @param FunctionalTester $I */ public function dontSeeVisualChanges(FunctionalTester $I) { $I->amOnPage('/'); $I->dontSeeVisualChanges('same'); // the test has to be called twice for comparison on the travis server $I->amOnPage('/'); $I->dontSeeVisualChanges('same'); }
public function checkAuthEndpoint(FunctionalTester $I) { $I->wantTo('Visit login endpoint'); $I->amOnPage('login'); $I->seeResponseCodeIs(200); $I->wantTo('Visit register endpoint'); $I->amOnPage('register'); $I->seeResponseCodeIs(200); }
public function requireAuthenticationForRoute(FunctionalTester $I) { $I->dontSeeAuthentication(); $I->amOnPage('/secure'); $I->seeCurrentUrlEquals('/auth/login'); $I->see('Login'); $I->amLoggedAs(User::firstOrNew($this->userAttributes)); $I->amOnPage('/secure'); $I->seeResponseCodeIs(200); $I->see('Hello World'); }
public function testRegisterSuccsess(FunctionalTester $I) { $I->wantTo('register a user'); $I->amOnPage('/register'); $I->fillField('name', 'JohnDoe'); $I->fillField('email', '*****@*****.**'); $I->fillField('password', 'admin'); $I->fillField('password_confirmation', 'admin'); $I->click('Continue'); $I->amOnPage('/'); }
public function requireAuthenticationForRoute(FunctionalTester $I) { $I->haveEnabledFilters(); $I->amOnPage('/secure'); $I->seeCurrentUrlEquals('/auth/login'); $I->see('Login'); $I->amLoggedAs(User::create($this->userAttributes)); $I->amOnPage('/secure'); $I->seeResponseCodeIs(200); $I->see('Hello World'); }
private function append_token_to_reset_password_route(FunctionalTester $I) { // get reset token $password_reset = $I->grabRecord('password_resets', ['email' => self::EMAIL]); // fill password reset form $I->amOnPage('/password/reset/' . $password_reset->token); }
/** * @param FunctionalTester $I */ public function seeContact(FunctionalTester $I) { $I->wantToTest('if I can see the contact form as anonymous user'); $I->amOnPage('/'); $I->click(['link' => 'Contact']); $I->see('ContactForm'); }
public function cantCreateDuplicateKeyEntry(FunctionalTester $I) { $I->am('an equipment team member'); $I->wantTo('make sure I cant create duplicate entries'); //Load and login a known member $I->loginEquipmentTeamMember(); $I->amOnPage('/equipment'); $I->canSee('Record a new item'); $name = $this->faker->word; $slug = substr($this->faker->slug, 0, 10); //First item $I->click('Record a new item'); $I->fillField('Name', $name); $I->fillField('Slug', $slug); $I->click('Save'); $I->seeCurrentUrlEquals('/equipment/' . $slug . '/edit'); /* //Second item $I->click('Record a new item'); $I->fillField('Name', $name); $I->fillField('Key', $slug); $I->assertTrue( $I->seeExceptionThrown('BB\Exceptions\FormValidationException', function() use ($I){ $I->click('Save'); }) ); */ }
/** @test */ public function should_correctly_route_to_index(FunctionalTester $I) { // given .. I am on index page $I->amOnPage('/'); // then ... I should see correct route $I->seeCurrentUrlEquals('/'); }
public function _before(FunctionalTester $I) { $this->tester = ['name' => 'Tester', 'email' => 'tester+' . str_random(8) . '@stellardestiny.online', 'password' => 'password']; $I->amOnPage('/'); $I->click('Register'); $I->seeCurrentUrlEquals('/auth/register'); }
public function seeLinksList(FunctionalTester $I) { $I->haveRecord('links', $this->linkRecord); $I->amOnPage(LinksPage::$URL); $I->see('Links'); $I->see('/' . $this->link['uri']); $I->see($this->link['description']); }
/** * @test * it should render extended shortcode */ public function it_should_render_extended_shortcode(\FunctionalTester $I) { $content = 'Lorem ipsum [idlikethis]Some idea of mine[/idlikethis]'; $post_id = $I->havePostInDatabase(['post_name' => 'foo', 'post_content' => $content]); $I->amOnPage('/foo'); $text = "Some idea of mine"; $I->seeElement('.idlikethis-button[data-post-id="' . $post_id . '"][data-text="' . $text . '"] button'); }
public function guestCantVisitRolesPage(FunctionalTester $I) { $I->am('a guest'); $I->wantTo('make sure I can\'t view the roles page'); //I can see the menu item $I->amOnPage('/roles'); $I->canSeeCurrentUrlEquals('/login'); }
public function deletePost(FunctionalTester $I) { $id = $I->haveRecord('posts', $this->postAttributes); $I->amOnPage(PostsPage::$url); $I->see('Hello Universe'); PostsPage::of($I)->deletePost($id); $I->seeCurrentUrlEquals(PostsPage::$url); $I->dontSee('Hello Universe'); }
/** * Define custom actions here */ function checkIfLogin(\FunctionalTester $I) { //if ($I->loadSessionSnapshot('login')) return; $I->amOnPage('/login'); $I->fillField(['name' => 'email'], Fixtures::get('username')); $I->fillField(['name' => 'password'], Fixtures::get('password')); $I->click('#loginButton'); //$I->saveSessionSnapshot('login'); }
/** * @test * it should insert a comment when hitting the endpoint with valid params */ public function it_should_insert_a_comment_when_hitting_the_endpoint_with_valid_params(\FunctionalTester $I) { $post_id = $I->havePostInDatabase(['post_title' => 'Some post']); $I->amOnPage('/'); $wp_rest_nonce = $I->grabValueFrom('input[name="rest_nonce"]'); $I->haveHttpHeader('X-WP-Nonce', $wp_rest_nonce); $I->sendAjaxPostRequest('/wp-json/idlikethis/v1/button-click', ['post_id' => $post_id, 'content' => 'Some Content']); $I->seeResponseCodeIs(200); $I->seeCommentInDatabase(['comment_post_ID' => $post_id]); }
public function deleteADiscussion(FunctionalTester $I, UserSteps $userSteps) { $userId = $userSteps->amRegularUser(); $catId = $userSteps->haveCategory(['name' => 'Some Category', 'slug' => 'some-category', 'description' => 'A description of the category']); $postId = $userSteps->havePost(['title' => 'Is there a way to validate only some fields?', 'content' => 'as I see, only the form itself can be validated. It validates if all fields passes, right?' . ' Well, this time I have to validate 3 fields - but those fields what passes, should go inside database.' . ' With the original schema, I cant do that', 'users_id' => $userId, 'slug' => 'is-there-a-way-to-validate-only-some-fields', 'categories_id' => $catId]); $I->amOnPage("/discussion/{$postId}/is-there-a-way-to-validate-only-some-fields"); $I->seeInTitle('Is there a way to validate only some fields? - Discussion - Phalcon Framework'); $I->seeElement(['css' => 'a.btn-delete-post']); $I->click(['css' => 'a.btn-delete-post']); $I->see('Discussion was successfully deleted', '//body/div[1]/div/div/div'); }
public function loginFailsWhenPasswordIncorrect(FunctionalTester $I) { $I->amOnPage('/auth/login'); $I->see('Login'); $I->fillField('email', '*****@*****.**'); $I->fillField('password', 'incorrect'); $I->click('Login'); $I->seeCurrentUrlEquals('/auth/login'); $I->dontSeeAuthentication(); $I->see('These credentials do not match our records.'); }
public function requireAuthenticationForSecureRoute(FunctionalTester $I) { $I->dontSeeAuthentication(); $I->amOnPage(LinksPage::$URL); $I->seeCurrentUrlEquals(LoginPage::$URL); $I->see(LoginPage::$title); LoginPage::of($I)->loginByCredentials(env('LDAP_ADMIN_USER'), env('LDAP_ADMIN_PASSWORD')); $I->amOnPage(LinksPage::$URL); $I->seeResponseCodeIs(200); $I->see(LinksPage::$title); }
public function trySigninWithInvalidCredentials(FunctionalTester $I) { $I->wantTo('Login as user with invalid credentials'); $I->dontSeeAuthentication(); $I->amOnPage('/login'); $I->fillField('identifier', 'spectator'); $I->fillField('password', 'invalid'); $I->click('button[type=submit]'); $I->seeCurrentUrlEquals('/login'); $I->dontSeeAuthentication(); }
public function deleteADiscussion(FunctionalTester $I, UserSteps $userSteps) { $userId = $userSteps->amRegularUser(); $catId = $userSteps->haveCategory(); $postId = $userSteps->havePost(['title' => 'Is there a way to validate only some fields?', 'users_id' => $userId, 'categories_id' => $catId]); $I->amOnPage("/discussion/{$postId}/abc"); $I->seeInTitle('Is there a way to validate only some fields? - Discussion'); $I->seeElement(['css' => 'a.btn-delete-post']); $I->click(['css' => 'a.btn-delete-post']); $I->see('Discussion was successfully deleted', '//body/div[1]/div/div/div'); }
public function memberCanLeave(FunctionalTester $I) { $I->am('a member'); $I->wantTo('leave build brighton'); //Load and login a known member $user = User::find(1); Auth::login($user); $I->amOnPage('/account/' . $user->id . ''); $I->canSee('Active'); $I->click("Leave Build Brighton"); $I->canSee('Leaving'); }
public function teamMemberCanEditLog(FunctionalTester $I) { $I->am('a laser team member'); $I->wantTo('make sure I can edit laser logs'); //Load and login a known admin member $user = $I->loginLaserTeamMember(); $otherUser = User::find(1); $I->amOnPage('/equipment/laser'); $I->see($otherUser->name); $I->selectOption('form[name=equipmentLog] select[name=reason]', 'testing'); $I->click('Update'); }
public function generateStars(FunctionalTester $I) { $I->amOnPage('/admin/star'); $I->see('Star administration'); $star_count_before = $I->grabTextFrom('~<li>Star count: (\\d+)</li>~'); $star_link_count_before = $I->grabTextFrom('~<li>Star link count: (\\d+)</li>~'); $I->click('Generate new galaxy.'); $star_count_after = $I->grabTextFrom('~<li>Star count: (\\d+)</li>~'); $star_link_count_after = $I->grabTextFrom('~<li>Star link count: (\\d+)</li>~'); $I->assertGreaterThan($star_count_before, $star_count_after); $I->assertGreaterThan($star_link_count_before, $star_link_count_after); }
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 financeMemberCanVisitPaymentPage(FunctionalTester $I) { $I->am('a member of the finance group'); $I->wantTo('make sure I can view the payments page'); //Load and login a known member $user = User::find(3); $role = Role::findByName('finance'); $role->users()->attach($user->id); Auth::login($user); $I->amOnPage('/payments'); $I->seeCurrentUrlEquals('/payments'); $I->see('Payments'); }
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 getNoErrorIfAssetsAreDumped(FunctionalTester $I) { $I->bootKernelWith('customized'); $I->runCommand('maba_webpack.command.setup'); $I->seeFileFound(__DIR__ . '/Fixtures/package.json'); $I->seeFileFound(__DIR__ . '/Fixtures/app/config/webpack.config.js'); $I->runCommand('maba_webpack.command.compile'); $I->seeCommandStatusCode(0); $I->seeInCommandDisplay('webpack'); $I->dontSeeInCommandDisplay('error'); $I->amOnPage('/customized'); $I->canSeeResponseCodeIs(200); $I->dontSee('Manifest file not found'); $I->seeInSource('<link rel="stylesheet" id="css1" href="/assets/'); $href = $I->grabAttributeFrom('link#css1', 'href'); preg_match('#/assets/(.*)#', $href, $matches); $I->seeFileFound(__DIR__ . '/Fixtures/web/assets/' . $matches[1]); $I->openFile(__DIR__ . '/Fixtures/web/assets/' . $matches[1]); $I->canSeeInThisFile('.green'); $I->canSeeInThisFile('.red'); $I->canSeeInThisFile('-ms-fullscreen a.css'); $I->amGoingTo('Check if less file was compiled'); $I->canSeeInThisFile('color: #123456'); $I->canSeeInThisFile('-ms-fullscreen a.less'); $I->amGoingTo('Check if sass file was compiled'); $I->canSeeInThisFile('color: #654321'); $I->canSeeInThisFile('-ms-fullscreen a.scss'); $I->amGoingTo('Check if cat.png was included'); $I->canSeeInThisFile('background: url(/assets/'); $I->seeInSource('<link rel="stylesheet" id="css2" href="/assets/'); $href = $I->grabAttributeFrom('link#css2', 'href'); preg_match('#/assets/(.*)#', $href, $matches); $I->seeFileFound(__DIR__ . '/Fixtures/web/assets/' . $matches[1]); $I->openFile(__DIR__ . '/Fixtures/web/assets/' . $matches[1]); $I->canSeeInThisFile('color: #123456'); $I->seeInSource('<script src="/assets/'); $src = $I->grabAttributeFrom('script', 'src'); preg_match('#/assets/(.*)#', $src, $matches); $I->seeFileFound(__DIR__ . '/Fixtures/web/assets/' . $matches[1]); $I->openFile(__DIR__ . '/Fixtures/web/assets/' . $matches[1]); $I->canSeeInThisFile('additional-asset-content'); $I->canSeeInThisFile('additional asset B'); $I->canSeeInThisFile('app-asset-content'); $I->dontSeeInThisFile('featureA-content'); $I->dontSeeInThisFile('featureB-content'); $I->seeInSource('<img src="/assets/'); $src = $I->grabAttributeFrom('img', 'src'); preg_match('#/assets/(.*)#', $src, $matches); $I->seeFileFound(__DIR__ . '/Fixtures/web/assets/' . $matches[1]); $I->seeFileIsSmallerThan(__DIR__ . '/Fixtures/web/assets/' . $matches[1], __DIR__ . '/Fixtures/src/Resources/assets/cat.png'); }
public function adminCanDeclineExpenses(FunctionalTester $I) { $I->am('an admin'); $I->wantTo('make sure I can decline an expense'); //Create a proposal that's currently open $I->haveInDatabase('expenses', ['id' => 4, 'category' => 'consumables', 'description' => 'Another Description', 'user_id' => '3', 'amount' => 1234, 'expense_date' => Carbon::now()]); //Load and login a known member $user = User::find(3); Auth::login($user); $I->amOnPage('/expenses'); $I->canSee('Expenses'); $I->canSee('Another Description'); $I->cantSee('Declined by'); $I->click('Decline'); $I->canSee('Declined by'); }
public function createATicketSuccessfully(FunctionalTester $I) { $I->amLoggedAs(User::where('email', '*****@*****.**')->first()); $I->seeAuthentication(); $I->amOnPage('/ticket/create'); $I->see('Create Ticket', 'h1'); $I->fillField('customer_name', 'Evie Martell'); $I->fillField('customer_address', 'Luton, LU1 9AB'); $I->fillField('customer_tel', '07710999888'); $I->fillField('customer_email', '*****@*****.**'); $I->selectOption('select[name=type]', 'Fault'); $I->selectOption('select[name=category_id]', '1'); $I->fillField('post_serial', '2997'); $I->fillField('description', 'Testing the post fault'); $I->seeAuthentication(); $I->click('Create'); $I->see('Ticket created'); }