/**
  * @param AcceptanceTester $I
  */
 protected function setLoginCookies(\AcceptanceTester $I)
 {
     $authTokenName = (string) $this->tokenNames['authtoken'];
     $sessionTokenName = (string) $this->tokenNames['session'];
     $I->setCookie($this->tokenNames['authtoken'], $this->cookies[$authTokenName]);
     $I->setCookie($this->tokenNames['session'], $this->cookies[$sessionTokenName]);
 }
示例#2
0
 /**
  * Publish the 'Contact' page.
  *
  * @param \AcceptanceTester $I
  */
 public function publishContactPageTest(\AcceptanceTester $I)
 {
     $I->wantTo("Publish the 'Contact' page with 'templatefields' as 'manager' user");
     // Set up the browser
     $I->setCookie('bolt_authtoken', $this->cookies['bolt_authtoken']);
     $I->setCookie('bolt_session', $this->cookies['bolt_session']);
     $I->amOnPage('/bolt/editcontent/pages/3');
     $I->see('This is the contact text');
     $I->selectOption('#statusselect', 'published');
     $I->click('Save', '#savecontinuebutton');
     $I->see('The changes to this Page have been saved.');
 }
 /**
  * Create an 'About' page record.
  *
  * @param \AcceptanceTester $I
  */
 public function editAboutPageTest(\AcceptanceTester $I)
 {
     $I->wantTo("Edit the 'About' page as the 'author' user");
     // Set up the browser
     $I->setCookie('bolt_authtoken', $this->cookies['bolt_authtoken']);
     $I->setCookie('bolt_session', $this->cookies['bolt_session']);
     $I->amOnPage('/bolt');
     $I->see('Edit', 'a');
     $I->click('Edit', 'a');
     $I->click('Save Page', '#savecontinuebutton');
     $I->see('The changes to the Page have been saved.');
 }
示例#4
0
 /**
  * Test that a user with no access rights to Dashboard gets redirected to
  * the hmoepage.
  *
  * Inspired by the Atari game Lemmings and the Eddie Vedder commment:
  * "Longest song title in the Pearl Jam catalogue", referencing the song
  * "Elderly Woman Behind the Counter in a Small Town", and the name of the
  * particular unit test method until Bolt 2.3…
  *
  * @param \AcceptanceTester $I
  */
 public function dashboardWithoutPermissionRedirectsToHomepageTest(\AcceptanceTester $I)
 {
     $I->wantTo('Set permissions/global/dashboard to empty and be redirected to the homepage');
     // Set up the browser
     $I->setCookie($this->tokenNames['authtoken'], $this->cookies[$this->tokenNames['authtoken']]);
     $I->setCookie($this->tokenNames['session'], $this->cookies[$this->tokenNames['session']]);
     $I->amOnPage('/bolt/file/edit/config/permissions.yml');
     $yaml = $I->getLemmingsPermissions();
     $I->fillField('#form_contents', $yaml);
     $token = $I->grabValueFrom('#form__token');
     $I->sendAjaxPostRequest('/bolt/file/edit/config/permissions.yml', ['form[_token]' => $token, 'form[contents]' => $yaml]);
     // Verify we go to the dashboard and end up on the homepage
     $I->amOnPage('/bolt');
     $I->see('A sample site');
     $I->see('Recent Pages');
     $I->dontSee('Recent Resources');
     $I->see('A Page I Made', 'h1');
     $I->see('Built with Bolt, tested with Codeception', 'footer');
 }
 /**
  * Helping function to login without checking cookie since not compatible
  * with browserstack ie8-9
  *
  * @param AcceptanceTester $I
  */
 protected function login(AcceptanceTester $I)
 {
     //Check if cookie first
     static $cookie = null;
     if (!is_null($cookie)) {
         $I->setCookie(AUTH_COOKIE, $cookie);
         return;
     }
     $I->wantTo('Log into WordPress admin');
     // Let's start on the login page
     $I->amOnPage(wp_login_url());
     // Populate the login form's user id field
     $I->fillField(['id' => 'user_login'], 'admin');
     // Populate the login form's password field
     $I->fillField(['id' => 'user_pass'], 'password');
     // Submit the login form
     $I->click(['name' => 'wp-submit']);
     // Wait for page to load [Hack for Safari and IE]
     $I->waitForElementVisible(['css' => 'body.index-php'], 5);
     $cookie = $I->grabCookie(AUTH_COOKIE);
 }
 /**
  * Logout the admin user
  *
  * @param \AcceptanceTester $I
  */
 public function logoutAdminUserTest(\AcceptanceTester $I)
 {
     $I->wantTo('log out of the backend as Admin');
     // Set up the browser
     $I->setCookie('bolt_authtoken', $this->cookies['bolt_authtoken']);
     $I->setCookie('bolt_session', $this->cookies['bolt_session']);
     $I->amOnPage('/bolt');
     $I->see('Dashboard');
     $I->click('Logout');
     $I->see('You have been logged out');
     $I->amOnPage('/bolt');
     $I->see('Please log on');
 }
示例#7
0
 /**
  * Test that the 'developer' user can configure installed extensions.
  *
  * @param \AcceptanceTester $I
  */
 public function configureInstalledExtensions(\AcceptanceTester $I, \Codeception\Scenario $scenario)
 {
     $I->wantTo("See that the 'developer' user can configure installed extensions.");
     // Set up the browser
     $I->setCookie($this->tokenNames['authtoken'], $this->cookies[$this->tokenNames['authtoken']]);
     $I->setCookie($this->tokenNames['session'], $this->cookies[$this->tokenNames['session']]);
     $I->amOnPage('/bolt/files/config/extensions');
     $I->see('testerevents.bolt.yml', Locator::href('/bolt/file/edit/config/extensions/testerevents.bolt.yml'));
     $I->click('testerevents.bolt.yml', Locator::href('/bolt/file/edit/config/extensions/testerevents.bolt.yml'));
     $I->see('# Sit back and breathe', 'textarea');
     $I->see('its_nice_to_know_you_work_alone: true', 'textarea');
     // Edit the field
     $twig = $I->grabTextFrom('#form_contents', 'textarea');
     $twig .= PHP_EOL . "# Let's make this perfectly clear";
     $twig .= PHP_EOL . 'theres_no_secrets_this_year: true' . PHP_EOL;
     $I->fillField('#form_contents', $twig);
     $token = $I->grabValueFrom('#form__token');
     $I->sendAjaxPostRequest('/bolt/file/edit/config/extensions/testerevents.bolt.yml', ['form[_token]' => $token, 'form[contents]' => $twig]);
     $I->amOnPage('/bolt/file/edit/config/extensions/testerevents.bolt.yml');
     $I->see("# Let's make this perfectly clear", 'textarea');
     $I->see('theres_no_secrets_this_year: true', 'textarea');
 }
示例#8
0
 /**
  * Create a contact page with templatefields
  *
  * @param \AcceptanceTester $I
  */
 public function checkTemplateFieldsTest(\AcceptanceTester $I)
 {
     $I->wantTo('Create a contact page with templatefields');
     // Set up the browser
     $I->setCookie($this->tokenNames['authtoken'], $this->cookies[$this->tokenNames['authtoken']]);
     $I->setCookie($this->tokenNames['session'], $this->cookies[$this->tokenNames['session']]);
     $I->amOnPage('bolt');
     $I->see('New Page');
     $I->click('New Page');
     $I->fillField('#title', 'Contact Page');
     $I->fillField('#slug', 'contact');
     $I->selectOption('#template', 'extrafields.twig');
     $I->click('Save Page', '#savecontinuebutton');
     $I->see('The new Page has been saved.');
     $I->click('CONTACT PAGE');
     // Page has been saved, fill templatefields
     $I->see('Template', 'a[data-toggle=tab]');
     $I->fillField('#templatefields-section_1', 'This is the contact text');
     $I->click('Save Page');
     $I->click('CONTACT PAGE');
     /*
      * In v2.0.13 Codeception made the awesome decision to refactor their
      * PHP Browser code — in a patch release no less — and it doesn't
      * properly handle URL queries parameters in POSTs. For now we'll just
      * pretend that seeing the data is good enough…
      */
     $I->see('This is the contact text');
     //         $I->seeInField('#templatefields-section_1', 'This is the contact text');
 }
示例#9
0
 /**
  * Logout the admin user
  *
  * @param \AcceptanceTester $I
  */
 public function logoutAdminUserTest(\AcceptanceTester $I)
 {
     $I->wantTo('log out of the backend as Admin');
     // Set up the browser
     $I->setCookie($this->tokenNames['authtoken'], $this->cookies[$this->tokenNames['authtoken']]);
     $I->setCookie($this->tokenNames['session'], $this->cookies[$this->tokenNames['session']]);
     $I->amOnPage('/bolt');
     $I->see('Dashboard');
     $I->click('Logout');
     // Removed as we now unset the session cookie at logout
     //$I->see('You have been logged out');
     $I->amOnPage('/bolt');
     $I->see('Please log on');
 }
示例#10
0
 /**
  * Publish the 'Contact' page.
  *
  * @param \AcceptanceTester $I
  */
 public function publishContactPageTest(\AcceptanceTester $I, \Codeception\Scenario $scenario)
 {
     $I->wantTo("Publish the 'Contact' page with 'templatefields' as 'manager' user");
     $scenario->skip('Update Required');
     // Set up the browser
     $I->setCookie($this->tokenNames['authtoken'], $this->cookies[$this->tokenNames['authtoken']]);
     $I->setCookie($this->tokenNames['session'], $this->cookies[$this->tokenNames['session']]);
     $I->amOnPage('/bolt/editcontent/pages/3');
     $I->seeInSource('This is the contact text');
     $I->selectOption('#statusselect', 'published');
     $I->click('Save', '#savecontinuebutton');
     $I->see('The changes to the Page have been saved.');
 }