<?php
namespace Tests\Feature;
use App\Models\User;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\Traits\ActingJWTUser;
class UserAddressApiTest extends TestCase
{
use WithFaker, ActingJWTUser;
protected $user;
/**
* A basic test example.
*
* @return void
*/
public function setUp()
{
parent::setUp(); // TODO: Change the autogenerated stub
$this->user = factory(User::class)->create();
}
/**
* 新增收货地址
*/
public function testStoreUserAddress()
{
$data = [
'contract_name' => $this->faker->name,
'contract_phone' => $this->faker->phoneNumber,
'province' => $this->faker->state,
'city' => $this->faker->city,
'district' => $this->faker->area,
'address' => sprintf('第%d大道%d号', 1, 1)
];
$response = $this->JWTActingAs($this->user)
->json('POST', '/api/addresses', $data);
$response->assertStatus(201)->assertJsonFragment($data);
}
}
setUp中 factory在数据库中生成了一条测试数据,请问怎么在一套phpunit跑完之后删除这条数据和其他一起生成的数据
© 著作权归作者所有
举报
发表评论
0/200