test(casts): add tests for ShopperEstablishmentCodeCast functionality test(casts): add tests for ShopperServiceCodeCast functionality test(casts): add tests for ShopperSiteCodeCast functionality test(dto): update ProductDtoTest to include additional fields test(dto): update SettingDtoTest to remove arcadiaSites assertions test(events): update AnOrderHasBeenPlacedTest to use value objects test(entities): update OrderTest to use value objects for employee details test(value-objects): update EmployeeUpsertDataTest to use value objects test(pagination): update PaginationTest to access value properties test(services): update AppCustomerAuthServiceTest to use CrmHashcode test(services): update CrmServiceTest to use CrmHashcode for customer retrieval
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests;
|
|
|
|
use GuzzleHttp\Psr7\Response as GuzzleResponse;
|
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
|
use LDC\LDCCRM\CrmApiV4;
|
|
use LDC\LDCCRM\Enums\ApiStatus;
|
|
use LDC\LDCCRM\Models\ClientModel;
|
|
use LDC\LDCCRM\Transport\ApiInterface;
|
|
use LDC\LDCCRM\Transport\Response as CrmResponse;
|
|
use LDC\LDCCRM\Utils;
|
|
use Mockery;
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
{
|
|
use CreatesApplication;
|
|
|
|
#[\Override]
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->mockCrmTransport();
|
|
}
|
|
|
|
private function mockCrmTransport(): void
|
|
{
|
|
$apiInterface = Mockery::mock(ApiInterface::class);
|
|
$apiInterface->shouldReceive('call')->byDefault()->andReturn(
|
|
new CrmResponse(
|
|
ApiStatus::OK,
|
|
new GuzzleResponse(200, [], (string) json_encode([
|
|
'version' => Utils::getPackageInfo()['version'],
|
|
'data' => [],
|
|
]))
|
|
)
|
|
);
|
|
|
|
$refClientModel = new \ReflectionProperty(ClientModel::class, 'apiInterface');
|
|
$refClientModel->setValue(null, $apiInterface);
|
|
|
|
$refCrmApi = new \ReflectionProperty(CrmApiV4::class, 'apiInterface');
|
|
$refCrmApi->setValue(null, $apiInterface);
|
|
}
|
|
}
|