`
fighter1945
  • 浏览: 232236 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

yii2的phpunit test

    博客分类:
  • php
阅读更多

## 参照网站

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,太重

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics