Inheritance: extends Codeception\Actor
示例#1
0
 /** @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 testChangePassword(FunctionalTester $I)
 {
     $I->amGoingTo('test the change password functionality');
     // Create one user
     $user = Commons::createUser();
     $I->amGoingTo('login a user');
     $loginPage = LoginPage::openBy($I);
     $loginPage->login(Commons::TEST_EMAIL, Commons::TEST_PASSWORD);
     $changePasswordPage = ChangePasswordPage::openBy($I);
     $I->see('Change password');
     $I->seeElement('#changepasswordform-newpassword');
     $I->seeElement('#changepasswordform-newpasswordrepeat');
     $I->dontSeeElement('#changepasswordform-email');
     $I->dontSeeElement('#changepasswordform-oldpassword');
     $I->amGoingTo('try to change the password with two different passwords for the new password and the new password repeat fields');
     $changePasswordPage->changePassword('123123', '234234');
     $I->expect('the form will catch the difference');
     $I->see('The new passwords are not the same.');
     $I->amGoingTo('test adding new password with length lower than the default length');
     $changePasswordPage->changePassword('123', '123');
     $I->expect('the form will warn the user');
     $I->see('New password should contain at least 6 characters');
     $I->see('New password repeat should contain at least 6 characters');
     $I->amGoingTo('change the password of the user properly');
     $changePasswordPage->changePassword('Nik)lay!23', 'Nik)lay!23');
     $I->expect('that this time everything will be ok and the user will be redirected to the home page');
     $user->refresh();
     $I->assertNotNull($user->password_changed_at);
     $I->seeInCurrentUrl('/');
 }
 /**
  * @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');
 }
示例#4
0
 /**
  *
  * @param \FunctionalTester $I
  * @param \Codeception\Scenario $scenario
  */
 public function testUserRegistration($I, $scenario)
 {
     $I->wantTo('ensure that registration works');
     $registrationPage = RegistrationPage::openBy($I);
     $I->see('Sign up', 'h1');
     $I->amGoingTo('submit registration form with no data');
     $registrationPage->submit([]);
     $I->expectTo('see validations errors');
     $I->see('Username cannot be blank.', '.help-block');
     $I->see('E-mail cannot be blank.', '.help-block');
     $I->see('Password cannot be blank.', '.help-block');
     $I->see('Repeated password cannot be blank.', '.help-block');
     $I->amGoingTo('submit registration form with not correct email and repeated password');
     $registrationPage->submit(['username' => 'tester', 'email' => 'tester.email', 'password' => 'tester_password', 'password2' => 'tester_password2']);
     $I->expectTo('see that email address and repeated password is wrong');
     $I->dontSee('Username cannot be blank.', '.help-block');
     $I->dontSee('Password cannot be blank.', '.help-block');
     $I->dontSee('Repeated password cannot be blank.', '.help-block');
     $I->see('E-mail is not a valid email address.', '.help-block');
     $I->see('Repeated password must be repeated exactly.', '.help-block');
     $I->amGoingTo('submit registration form with correct data');
     $registrationPage->submit(['username' => 'tester', 'email' => '*****@*****.**', 'password' => 'tester_password', 'password2' => 'tester_password']);
     $registrationPage = RegistrationPage::openBy($I);
     $I->amGoingTo('submit registration form with same data');
     $registrationPage->submit(['username' => 'tester', 'email' => '*****@*****.**', 'password' => 'tester_password', 'password2' => 'tester_password']);
     $I->expectTo('see that username and email address have already been taken');
     $I->see('Username "tester" has already been taken.', '.help-block');
     $I->see('E-mail "*****@*****.**" has already been taken.', '.help-block');
     //        $I->expectTo('see that user logged in');
     //        $I->seeLink('Logout (tester)');
 }
示例#5
0
 public function testPageContent(\FunctionalTester $I)
 {
     $I->wantTo('test that the project creation page works');
     CreatePage::openBy($I, $this->params);
     $I->see(CreatePage::$headingText, CreatePage::$headingSelector);
     $I->see(CreatePage::$placeholderText);
 }
 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 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.');
 }
示例#8
0
 public function testValidDetails(\FunctionalTester $I)
 {
     $I->wantTo('test logging in with the correct details');
     LoginPage::openBy($I);
     LoginPage::loginAsUser($I);
     $I->seeCurrentUrlEquals(IndexPage::$url);
 }
示例#9
0
 /**
  * @test
  * it should allow not having a link in the database
  */
 public function it_should_allow_not_having_a_link_in_the_database(FunctionalTester $I)
 {
     $id = $I->haveLinkInDatabase();
     $I->seeLinkInDatabase(['link_id' => $id]);
     $I->dontHaveLinkInDatabase(['link_id' => $id]);
     $I->dontSeeLinkInDatabase(['link_id' => $id]);
 }
示例#10
0
 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');
 }
示例#11
0
 public function NotGetting500(Tester $I)
 {
     $I->wantToTest('whether we are getting any 500 error');
     $I->haveHttpHeader("apikey", $this->apiInfo[Helper::CSV_ORDER_APIKEY]);
     $I->sendGET("currenttime", ["source" => $this->apiInfo[Helper::CSV_ORDER_SOURCE]]);
     $I->dontSeeResponseCodeIs(500);
 }
 public function getNoErrorWithTwigUnknownsIfIgnoring(FunctionalTester $I)
 {
     $I->bootKernelWith('unknowns_suppress');
     $I->runCommand('maba_webpack.command.setup');
     $I->runCommand('maba_webpack.command.compile');
     $I->seeCommandStatusCode(0);
 }
示例#13
0
文件: LinksCest.php 项目: mlanin/go
 public function deleteMyRedirect(FunctionalTester $I)
 {
     $I->haveRecord('links', $this->linkRecord);
     LinksPage::of($I)->deleteLink();
     $I->dontSeeRecord('links', $this->linkRecord);
     $I->seeCurrentUrlEquals(LinksPage::$URL);
     $I->dontSee('/' . $this->link['uri']);
 }
 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');
 }
示例#15
0
 public function testUnApprovedUser(FunctionalTester $I)
 {
     $I->wantTo('ensure that unapproved user cannot login');
     $loginPage = LoginPage::openBy($I);
     $loginPage->login('UnApprovedUser', '123qwe');
     $I->expectTo('see validations errors');
     $I->see('Your account is not approved yet!');
 }
示例#16
0
 /**
  * @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 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 editAnAuthorWithInvalidAttributes(FunctionalTester $I)
 {
     $author = $I->haveAuthor();
     $attributes = ['id' => $author->id, 'name' => 'Updated Author2', 'email' => 'debug'];
     $I->sendPUT('/authors/' . $author->id, $attributes);
     $I->sendGET('/authors');
     $I->dontSeeResponseContainsJson($attributes);
 }
示例#19
0
 /**
  * @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');
 }
示例#20
0
 /**
  * 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');
 }
示例#21
0
 public function testValidPassword(\FunctionalTester $I)
 {
     $I->wantTo('test that supplying valid new password succeeds');
     ResetPasswordPage::setNewPassword($I, Auth::$newPassword);
     $I->seeCurrentUrlEquals(IndexPage::$url);
     $I->see('Your new password has been saved.');
     $hash = $I->grabRecord('app\\models\\User', ['email' => Auth::$validEmail])->passwordHash;
     $I->assertTrue(Yii::$app->getSecurity()->validatePassword(Auth::$newPassword, $hash));
 }
 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]);
 }
示例#23
0
 /**
  * @param FunctionalTester $I
  */
 public function loginWithCorrectData(FunctionalTester $I)
 {
     $I->wantToTest('if I can login with correct data');
     TestCommons::authentificate($I, 'owner');
     $I->see('( aaaaa )');
     $I->see('Edit profile');
     $I->see('Administration');
     $I->dontSee('The entered data is not correct!');
 }
 public function canFetchPhoto(FunctionalTester $I)
 {
     $I->am('a developer');
     $I->wantTo('ensure photos can be fetched');
     $equipment = \BB\Entities\Equipment::findOrFail(2);
     $equipment->addPhoto('foo.png');
     $equipment = \BB\Entities\Equipment::findOrFail(2);
     $I->assertEquals($equipment->getPhotoBasePath() . 'foo.png', $equipment->getPhotoPath(0));
 }
示例#25
0
 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');
 }
 /**
  * @test
  * it should allow getting non blog id prefixed table names for main blog
  */
 public function it_should_allow_getting_non_blog_id_prefixed_table_names_for_main_blog(FunctionalTester $I)
 {
     $tables = ['commentmeta', 'comments', 'links', 'options', 'postmeta', 'posts', 'term_relationships', 'term_taxonomy', 'terms', 'termmeta'];
     foreach ($tables as $table) {
         $I->useMainBlog();
         $tableName = $I->grabPrefixedTableNameFor($table);
         $I->assertEquals($I->grabTablePrefix() . $table, $tableName);
     }
 }
示例#27
0
 public function tryExceptWithInvalidRoute(FunctionalTester $I)
 {
     $I->expectException(new \Exception('This route is invalid!'), function () {
         $_GET = ['zc' => 2];
         $_SERVER['REQUEST_URI'] = '/errorURL.jpg';
         $this->config->appConfigs = ['route' => '^\\/(?P<w>\\d+)x(?P<h>\\d+)\\/(?<src>[\\w.-]+)', 'permit_params_with_route' => 0];
         $this->config->setUrlParams();
     });
 }
示例#28
0
 public function testValidDetails(\FunctionalTester $I)
 {
     $page = $this->page;
     $activity = $this->activity;
     $I->wantTo('test that submitting valid data is successful');
     $page::openBy($I, $this->params);
     $page::submit($I, ['project' => $activity::$project, 'name' => $activity::$name, 'date' => $activity::$date, 'description' => $activity::$description]);
     $I->seeCurrentUrlEquals(IndexPage::$url);
     $I->see($activity::$name);
     $I->seeRecord('app\\models\\ProjectActivity', ['projectID' => $activity::$project, 'name' => $activity::$name, 'date' => $activity::$date, 'description' => $activity::$description]);
 }
示例#29
0
 public function testVolunteerFormLinkWithLogin(\FunctionalTester $I)
 {
     $I->wantTo('check that logging in after trying to access the volunteer form redirects me to the volunteer form');
     IndexPage::openBy($I);
     $I->click(IndexPage::$volunteerFormButtonText, IndexPage::$contentSelector);
     $I->seeCurrentUrlEquals(LoginPage::$url);
     LoginPage::loginAsUser($I);
     $I->seeCurrentUrlEquals(VolunteerPage::$url);
     $I->seeLink(VolunteerPage::$logoutLinkText);
     $I->see(VolunteerPage::$headingText, VolunteerPage::$headingSelector);
 }
 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);
 }