【发布时间】:2016-12-13 18:19:30
【问题描述】:
使用phpunit 命令 Laravel 将运行我们项目中的所有单元测试。
如何在Laravel 5.1 中运行一个或特定的单元测试?
我只想从我的测试套件中运行testFindToken。
<?php
use Mockery as m;
use App\Models\AccessToken;
use Illuminate\Foundation\Testing\WithoutMiddleware;
class AccessTokenRepositoryTest extends TestCase
{
use WithoutMiddleware;
public function setUp()
{
parent::setUp();
$this->accessToken = factory(AccessToken::class);
$this->repo_AccessToken = app()->make('App\Repositories\AccessTokenRepository');
}
public function testFindToken()
{
$model = $this->accessToken->make();
$model->save();
$model_accessToken = $this->repo_AccessToken->findToken($model->id);
$this->assertInstanceOf(Illuminate\Database\Eloquent\Model::class, $model);
$this->assertNotNull(true, $model_accessToken);
}
}
【问题讨论】:
标签: php laravel testing phpunit