Created
November 15, 2018 06:50
-
-
Save pretzelhands/1633a28aa37ad231db87cc6d1044cea5 to your computer and use it in GitHub Desktop.
A Codeception example for TodoMVC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Inherited Methods | |
* @method void wantToTest($text) | |
* @method void wantTo($text) | |
* @method void execute($callable) | |
* @method void expectTo($prediction) | |
* @method void expect($prediction) | |
* @method void amGoingTo($argumentation) | |
* @method void am($role) | |
* @method void lookForwardTo($achieveValue) | |
* @method void comment($description) | |
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL) | |
* | |
* @SuppressWarnings(PHPMD) | |
*/ | |
class AcceptanceTester extends \Codeception\Actor | |
{ | |
use _generated\AcceptanceTesterActions; | |
public function createATodo($text) | |
{ | |
$I = $this; | |
$I->fillField(".new-todo", $text); | |
$I->pressKey(".new-todo", WebDriverKeys::ENTER); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Codeception\Util\Locator; | |
class TodoCest | |
{ | |
public function testCreateTodo(AcceptanceTester $I) | |
{ | |
$I->amOnPage("/"); | |
$I->createATodo("My first todo"); | |
$I->waitForElement(".todo-list li"); | |
$I->see("My first todo"); | |
$I->see("1 item left"); | |
} | |
public function testMarkTodoCompleted(AcceptanceTester $I) | |
{ | |
$I->see("My first todo"); | |
$I->click(".toggle"); | |
$I->waitForElement(".completed"); | |
$I->see("My first todo"); | |
$I->see("0 items left"); | |
} | |
public function testDeleteTodo(AcceptanceTester $I) | |
{ | |
$I->see("My first todo"); | |
$I->moveMouseOver(".todo-list li:first-child"); | |
$I->click(".destroy"); | |
$I->dontSee("My first todo"); | |
} | |
public function testCreateMultipleTodos(AcceptanceTester $I) | |
{ | |
$I->createATodo("My second todo"); | |
$I->createATodo("My third todo"); | |
$I->waitForElement(".todo-list li"); | |
$I->see("My second todo"); | |
$I->see("My third todo"); | |
$I->see("2 items left"); | |
} | |
public function testCompletedView(AcceptanceTester $I) | |
{ | |
$I->see("My second todo"); | |
$I->click(Locator::firstElement(".toggle")); | |
$I->click("Completed"); | |
$I->see("My second todo"); | |
$I->dontSee("My third todo"); | |
} | |
public function testActiveView(AcceptanceTester $I) | |
{ | |
$I->click("Active"); | |
$I->dontSee("My second todo"); | |
$I->see("My third todo"); | |
} | |
public function testClearCompleted(AcceptanceTester $I) { | |
$I->click("All"); | |
$I->see("My second todo"); | |
$I->see("My third todo"); | |
$I->see("1 item left"); | |
$I->click("Clear completed"); | |
$I->dontSee("My second todo"); | |
$I->see("My third todo"); | |
$I->see("1 item left"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment