ldc-crm/tests/Client/CrmClientClientTest.php
2025-09-08 14:59:53 +02:00

58 lines
1.3 KiB
PHP

<?php
namespace Tests\Client;
use LDC\LDCCRM\CrmApiV4;
use LDC\LDCCRM\Enums\ApiStatus;
use LDC\LDCCRM\Enums\HttpMethods;
use LDC\LDCCRM\Exceptions\AccessError;
use LDC\LDCCRM\Models\Customer;
use LDC\LDCCRM\Transport\ApiInterface;
use LDC\LDCCRM\Transport\Request;
class CrmClientClientTest extends CrmClientTester
{
/**
* Test api interface.
*
* @return void
*/
public function testApiInterface(): void
{
$routes = $this->getClientRoutes();
$interface = new ApiInterface();
$request = new Request(
HttpMethods::make(\strtolower($routes['apiV4.ping']['methods'][0]), 'name'),
$routes['apiV4.ping']['uri']
);
$response = $interface->call($request);
$this->assertEquals(ApiStatus::OK->value(), $response->status->value());
}
/**
* Test ping.
*
* @return void
*/
public function testClientPing(): void
{
$api = new CrmApiV4();
$this->assertTrue($api->ping());
}
/**
* Set unknown attribute set.
*
* @return void
*/
public function testCrmModelSetUnknownAttribute(): void
{
$this->expectException(AccessError::class);
$customer = new Customer();
$customer->unknownAttribute = 'totot';
}
}