php - Pestphp 错误:调用未定义的函数 mock()
问题描述
文件害虫.php
<?php
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(Tests\TestCase::class, RefreshDatabase::class)->in('Feature', 'Unit');
File Unit/Repositories/PersonalDataRepository
文件单元/存储库/PersonalDataRepositoryTest.php
<?php
use Tests\Helpers\Api\ResponseApi;
use App\Services\ExternalApi\BigBoost\PeopleService;
use App\Services\Repositories\PersonalDataRepository;
uses(ResponseApi::class);
test('should register data in the personal data table with the bigbooster api data ',
function () {
$dataApi = $this->responseBigboostPeople();
$placeEmail = \App\Models\PlaceEmail::factory()->make();
$peopleService = mock(PeopleService::class);
$peopleService
->expects($this->once())
->method('make')
->willReturn($dataApi);
$personalDataRepository = new PersonalDataRepository();
$response = $personalDataRepository->create($placeEmail, $peopleService);
$this->assertEquals($placeEmail->email, $response->email);
$this->assertEquals('TESTE DA SILVA', $response->name);
$this->assertEquals('LEAO', $response->zodiac_sign);
$this->assertEquals('Mother user', $response->mother_name);
$this->assertEquals('Father user', $response->father_name);
$this->assertEquals('11111111111', $response->cpf);
$this->assertEquals('1991-08-04', $response->birth_date);
});
使用 $ this-> createMock 方法时出现错误,Member has protected access,因为没有扩展 TestCase 类
解决方案
推荐阅读
- python - python cv2溢出RAM
- c - 如何识别 mpegts 文件?
- nginx - Kubeadm Kubernetes 集群无法使用 ingress 将外部 IP 地址映射到域名
- ansible - 如何从ansible库存文件中跳过主机名?
- javascript - 如何将自动对焦设置为选择下拉列表中的输入?
- django - modelManager get_by_natural 密钥方法更改 USERNAME_FIELD 影响我的身份验证?
- typescript - 我怎样才能做 debounceTime 但第一个值
- r - “文件中的错误(文件,“rt”):在读取 1 个 .csv 文件时,“描述”参数无效”
- azure - Azure DevOps 部署到具有不同 SPN 的同一订阅中的资源组
- angular - 为什么我的 Angular 模板中的数据会出现“未定义”错误?