Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
571 views
in Technique[技术] by (71.8m points)

php - Pestphp Error : Call to undefined function mock()

File Pest.php

<?php

use IlluminateFoundationTestingRefreshDatabase;

uses(TestsTestCase::class, RefreshDatabase::class)->in('Feature', 'Unit');

File Unit/Repositories/PersonalDataRepository

File Unit/Repositories/PersonalDataRepositoryTest.php

<?php


use TestsHelpersApiResponseApi;
use AppServicesExternalApiBigBoostPeopleService;
use AppServicesRepositoriesPersonalDataRepository;

uses(ResponseApi::class);

test('should register data in the personal data table with the bigbooster api data ', 
function () {

$dataApi = $this->responseBigboostPeople();

$placeEmail = AppModelsPlaceEmail::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);
});

when using the $ this-> createMock method I get the error, Member has protected access, because the TestCase class is not being extended


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...