3

File Pest.php

<?php

use Illuminate\Foundation\Testing\RefreshDatabase;

uses(Tests\TestCase::class, RefreshDatabase::class)->in('Feature', 'Unit');

File Unit/Repositories/PersonalDataRepository

File Unit/Repositories/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);
});

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

apokryfos
  • 38,771
  • 9
  • 70
  • 114

0 Answers0