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