bariew / yii2-doctest-extension
Executes @example docBlock params as test cases
Installs: 3 057
Dependents: 2
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- bariew/phpquery: ~1.0.3
- chuyskywalker/rolling-curl: ~3.1.0
- dev-master
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.1-beta.1
- 2.2.1-beta
- 2.2.1-alpha.1
- 2.2.1-alpha
- 2.2.0-beta
- 2.2.0-alpha.1
- 2.2.0-alpha
- 2.1.0-beta
- 2.1.0-alpha
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0.0-beta.2
- 2.0.0-beta.1
- 2.0.0-beta
- 2.0.0-alpha.3
- 2.0.0-alpha.2
- 2.0.0-alpha.1
- 2.0.0-alpha
- 1.3.0
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.5
- 1.0.4
- 1.0.3
This package is auto-updated.
Last update: 2024-11-29 04:52:10 UTC
README
If you don't have a time to write tests.
Description
This extension is for testing without test writing. It doe few things.
-
It uses Curl to visit all your app pages (it finds them too) and submits all found forms just to make sure they are generally ok. It is useful to avoid critical errors like 404 or 500 error pages.
-
It takes your docblock @example tag and runs its content as assert expression. See examples below.
-
It also runs you url get and post requests, e.g. you can test your controller, eg API. with @example tags for each method.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist bariew/yii2-doctest-extension "*"
or add
"bariew/yii2-doctest-extension": "*"
to the require section of your composer.json
file.
Unit tests:
- define @example docblock in your tested class method descriptions:
/**
* Returns user default name
* @return string name.
* @example $this->getDefaultName() == "Mr. Smith"
*/
protected function getDefaultName()
{
return "Mr. Smith"
}
- Call UnitTest from your test script:
$docTester = new \bariew\docTest\UnitTest("app\models\User");
$docTester->test();
Url tests:
- define @example docblocks in your target class method descriptions:
$this->post("http://mySite.com/myPath", ["myParam"=>"MyValue"]) == '{"code":200, "message":"OK"}'
- Call DocTest from your test script:
$docTester = new \bariew\docTest\UrlTest("app\controllers\UserController");
$docTester->test();
- Click tests. See in examples folder.