欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

yii2的phpunit test 博客分类: php phpphpunityii2 

程序员文章站 2024-02-16 14:20:58
...

## 参照网站

phpunit官方网站  http://www.phpunit.cn/  https://phpunit.de/

 

## 代码示例

 

https://github.com/sebastianbergmann/money/blob/master/tests/MoneyTest.php

 

```php

use PHPUnit\Framework\TestCase;

class MoneyTest extends TestCase

 

```

 

## 简单步骤

 

1. 按照网站所示下载phpunit6并放到/usr/local/bin

2. 写testcode

3. yii2的话,跟 phpunit --bootstrap src/autoload.php tests/MoneyTest有点不一样

   要把src/autoload.php变成 web/index.php ,才能包含所有的require的文件

   但是web/index.php ,最后一行,(new yii\web\Application($config))->run();

   换成 return (new yii\web\Application($config))->run();

4. 不想用yii2的codeception,因为除了unit之外还包含了acceptance和functional,太重

相关标签: php phpunit yii2