fix & add tests
This commit is contained in:
parent
9bbf277d92
commit
8ebcdaeebc
@ -308,7 +308,7 @@ class ApiClientCustomersCorporateTest extends TestCase
|
|||||||
{
|
{
|
||||||
$client = static::getApiClient();
|
$client = static::getApiClient();
|
||||||
$response = $client->request->customersCorporateAddresses($ids['externalId'], ['name' => 'name'], 1, 20);
|
$response = $client->request->customersCorporateAddresses($ids['externalId'], ['name' => 'name'], 1, 20);
|
||||||
|
|
||||||
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
static::assertTrue(
|
static::assertTrue(
|
||||||
$response->isSuccessful(),
|
$response->isSuccessful(),
|
||||||
|
@ -40,7 +40,7 @@ class ApiResponseTest extends TestCase
|
|||||||
'Response object created'
|
'Response object created'
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
static::assertInstanceOf(
|
static::assertInstanceOf(
|
||||||
'RetailCrm\Response\ApiResponse',
|
'RetailCrm\Response\ApiResponse',
|
||||||
$response,
|
$response,
|
||||||
@ -54,7 +54,20 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testJsonInvalid()
|
public function testJsonInvalid()
|
||||||
{
|
{
|
||||||
new ApiResponse(400, '{ "asdf": }');
|
(new ApiResponse(400, '{ "asdf": }'))->asJsonResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group response
|
||||||
|
*/
|
||||||
|
public function testJsonInvalidNoDeserialize()
|
||||||
|
{
|
||||||
|
$response = new ApiResponse(400, '{ "asdf": }');
|
||||||
|
static::assertInstanceOf(
|
||||||
|
'RetailCrm\Response\ApiResponse',
|
||||||
|
$response,
|
||||||
|
'Response object created'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +82,7 @@ class ApiResponseTest extends TestCase
|
|||||||
'Response object returns the right status code'
|
'Response object returns the right status code'
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = new ApiResponse(460, '{ "success": false }');
|
$response = (new ApiResponse(460, '{ "success": false }'))->asJsonResponse();
|
||||||
static::assertEquals(
|
static::assertEquals(
|
||||||
460,
|
460,
|
||||||
$response->getStatusCode(),
|
$response->getStatusCode(),
|
||||||
@ -88,7 +101,7 @@ class ApiResponseTest extends TestCase
|
|||||||
'Request was successful'
|
'Request was successful'
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = new ApiResponse(460, '{ "success": false }');
|
$response = (new ApiResponse(460, '{ "success": false }'))->asJsonResponse();
|
||||||
static::assertFalse(
|
static::assertFalse(
|
||||||
$response->isSuccessful(),
|
$response->isSuccessful(),
|
||||||
'Request was failed'
|
'Request was failed'
|
||||||
@ -100,7 +113,7 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMagicCall()
|
public function testMagicCall()
|
||||||
{
|
{
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
static::assertEquals(
|
static::assertEquals(
|
||||||
true,
|
true,
|
||||||
$response->isSuccessful(),
|
$response->isSuccessful(),
|
||||||
@ -125,7 +138,7 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMagicCallException2()
|
public function testMagicCallException2()
|
||||||
{
|
{
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
/* @noinspection PhpUndefinedMethodInspection */
|
/* @noinspection PhpUndefinedMethodInspection */
|
||||||
$response->getSomeSuccess();
|
$response->getSomeSuccess();
|
||||||
}
|
}
|
||||||
@ -135,7 +148,7 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMagicGet()
|
public function testMagicGet()
|
||||||
{
|
{
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
static::assertEquals(
|
static::assertEquals(
|
||||||
true,
|
true,
|
||||||
$response->success,
|
$response->success,
|
||||||
@ -160,7 +173,7 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMagicGetException2()
|
public function testMagicGetException2()
|
||||||
{
|
{
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
/* @noinspection PhpUndefinedFieldInspection */
|
/* @noinspection PhpUndefinedFieldInspection */
|
||||||
$response->someSuccess;
|
$response->someSuccess;
|
||||||
}
|
}
|
||||||
@ -170,7 +183,7 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testArrayGet()
|
public function testArrayGet()
|
||||||
{
|
{
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
static::assertEquals(
|
static::assertEquals(
|
||||||
true,
|
true,
|
||||||
$response['success'],
|
$response['success'],
|
||||||
@ -194,7 +207,7 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testArrayGetException2()
|
public function testArrayGetException2()
|
||||||
{
|
{
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
$response['someSuccess'];
|
$response['someSuccess'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +216,7 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testArrayIsset()
|
public function testArrayIsset()
|
||||||
{
|
{
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
|
|
||||||
static::assertTrue(
|
static::assertTrue(
|
||||||
isset($response['success']),
|
isset($response['success']),
|
||||||
@ -222,7 +235,7 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testArraySetException1()
|
public function testArraySetException1()
|
||||||
{
|
{
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
$response['success'] = 'a';
|
$response['success'] = 'a';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +245,7 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testArraySetException2()
|
public function testArraySetException2()
|
||||||
{
|
{
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
$response['sssssssuccess'] = 'a';
|
$response['sssssssuccess'] = 'a';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +255,7 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testArrayUnsetException1()
|
public function testArrayUnsetException1()
|
||||||
{
|
{
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
unset($response['success']);
|
unset($response['success']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +265,7 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testArrayUnsetException2()
|
public function testArrayUnsetException2()
|
||||||
{
|
{
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
unset($response['sssssssuccess']);
|
unset($response['sssssssuccess']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +274,7 @@ class ApiResponseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMagicIsset()
|
public function testMagicIsset()
|
||||||
{
|
{
|
||||||
$response = new ApiResponse(201, '{ "success": true }');
|
$response = (new ApiResponse(201, '{ "success": true }'))->asJsonResponse();
|
||||||
|
|
||||||
static::assertTrue(
|
static::assertTrue(
|
||||||
isset($response->success),
|
isset($response->success),
|
||||||
|
Loading…
Reference in New Issue
Block a user