Skip to content

Instantly share code, notes, and snippets.

@nsanden
Created December 30, 2014 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nsanden/35ea7457bf3c4e9078b5 to your computer and use it in GitHub Desktop.
Save nsanden/35ea7457bf3c4e9078b5 to your computer and use it in GitHub Desktop.
<?php
use tests\codeception\backend\FunctionalTester;
use tests\codeception\common\_pages\CampaignPage;
use tests\codeception\common\_pages\LoginPage;
$I = new FunctionalTester($scenario);
$I->wantTo('ensure campaign page loads');
$loginPage = LoginPage::openBy($I);
//Log us in
$I->amGoingTo('try to login with correct credentials');
$loginPage->login('erau', 'password_0');
$I->expectTo('see that user is logged');
$I->seeLink('Logout (erau)');
$I->dontSeeLink('Login');
$I->dontSeeLink('Signup');
$campaignPage = CampaignPage::openBy($I);
//test sorting
$I->amGoingTo('see if the page loaded correctly');
$I->expectTo('see "Showing" text');
$I->see('Showing', '.summary');
$I->amGoingTo('confirm that sorting by status works fine');
$I->click('Status');
$I->expectTo('see a "status sort icon"');
$I->see('Status', '//a[@data-sort="-status"]');
$I->seeInCurrentUrl('sort=status');
$I->click('Status');
$I->expectTo('see a "status sort icon flipped"');
$I->see('Status', '//a[@data-sort="status"]');
$I->seeInCurrentUrl('sort=-status');
//test paging
$I->amGoingTo('confirm that paging works fine');
$I->click('3', '//a[@data-page="2"]');
$I->expectTo('see the url has changed correctly"');
$I->seeElement('//li[@class="active"]/a[@data-page="2"]');
$I->expectTo('see the url has changed correctly"');
$I->seeInCurrentUrl('page=3');
//test limit button
$I->amGoingTo('confirm qty limit works right');
$I->click('10', '//li[@role="presentation"]/a');
$I->expectTo('see the Showing 1-10 results');
$I->see('Showing 1-10', '.summary');
//test reset button
$I->amGoingTo('click reset button');
$I->click('Reset');
$I->expectTo('see page has reset');
$I->seeElement('//li[@class="active"]/a[@data-page="0"]'); //on correct page of paging elements
$I->cantSeeInCurrentUrl('&'); //no extra parameters in url
$I->see('Active', '//li[@class="active"]/a');
$I->see('Highest Selling', '//li[@class="active"]/a');
$I->see('1+ Sales', '//li[@class="active"]/a');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment