Posted by & filed under Webdev.

Modern PHP testing for everyone.


Codeception PHP Testing Framework is designed to work just out of the box. This means its installation requires minimal steps and no external dependencies preinstalled (except PHP, of course). Only one configuration step should be taken and you are ready to test your web application from an eye of actual user.

Project Home Yii2 extension
Acceptance Test

$I = new AcceptanceTester($scenario);
$I->wantTo('create wiki page');
$I->see('New Page');
$I->fillField('title', 'Hobbit');
$I->fillField('body', 'By Peter Jackson');
$I->see('page created'); // notice generated
$I->see('Hobbit','h1'); // head of page of is our title
$I->seeInDatabase('pages', array('title' => 'Hobbit'));

API Test

$I = new ApiTester($scenario);
$I->wantTo('create a new user by API');
$I->sendPOST('/users', array('name' => 'davert' ));
$I->seeResponseContainsJson(array('result' => 'ok'));

Unit Test

use \Codeception\Util\Stub;
class UserTest extends \Codeception\TestCase\Test
    public function testUserSave() {
        $user = Stub::make('User');
        $this->assertEquals('davert', $user->getName());
        $this->tester->seeInDatabase('users', array('name' => 'davert'));

Comments are closed.