ldc-crm/tests/Client/CrmClientV2ClientTest.php
2023-10-06 16:33:22 +02:00

58 lines
1.3 KiB
PHP

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