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
|
|
|
|
|
|
|
|
use LDC\LDCCRM\CrmApiV2;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
class CrmClientV2ClientTest extends CrmClientTester
|
|
|
|
|
{
|
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(
|
|
|
|
|
HttpMethods::make(\strtolower($routes['apiV2.ping']['methods'][0])),
|
|
|
|
|
$routes['apiV2.ping']['uri']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response = $interface->call($request);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(ApiStatus::OK(), $response->status);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
/**
|
|
|
|
|
* Test ping.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2021-08-04 09:42:48 +02:00
|
|
|
public function testClientPing()
|
|
|
|
|
{
|
|
|
|
|
$api = new CrmApiV2();
|
|
|
|
|
$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
|
|
|
}
|