国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

webman中如何集成單元測試?

碼龍

我參照了thinkphp的集成單元測試。

可以測試服務(wù)類

但是無法測試http請求

test/BaseText.php


# DI
protected $container;

public function __construct($name = null, array $data = [], $dataName = '')
{
    parent::__construct($name, $data, $dataName);
    $builder = new \DI\ContainerBuilder();
    $builder->addDefinitions(config('dependence', []));
    $builder->useAutowiring(true);
    $builder->useAnnotations(true);
    $this->container = $builder->build();
}

public function __call($name, $arguments)
{
    return $this->container->{$name}(...$arguments);
}

test/ExampleText

use app\api\service\auth\Auth;

class ExampleTest extends BaseTest
{
    public function testExample()
    {
        $auth = $this->container->get(Auth::class);
        $this->assertInstanceOf(Auth::class, $auth);
        $row = $auth->login('admin', '123456');
        $this->assertIsNumeric($row->id);
        $token = $auth->getToken();
        $this->assertIsString($token);
        $boole = $auth->init($token);
        $this->assertIsBool($boole);
    }
}

截圖

可以測試服務(wù)類 有不有辦法測試控制器的返回呢

4275 1 2
1個回答

Jonas

請教一下,你這里BaseText.php的完整代碼是什么。它繼承的是哪個類?另外你是如何實現(xiàn)單元測試可以自動加載項目類的?

  • 暫無評論
年代過于久遠(yuǎn),無法發(fā)表回答
??