немного тестов
This commit is contained in:
parent
88ab0a8e81
commit
e6aea87d1e
13
bootstrap.php
Normal file
13
bootstrap.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
use Composer\Autoload\ClassLoader;
|
||||||
|
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ClassLoader $loader
|
||||||
|
*/
|
||||||
|
$loader = require __DIR__.'/vendor/autoload.php';
|
||||||
|
|
||||||
|
AnnotationRegistry::registerLoader('class_exists');
|
||||||
|
|
||||||
|
|
||||||
|
return $loader;
|
@ -11,7 +11,7 @@
|
|||||||
processIsolation = "true"
|
processIsolation = "true"
|
||||||
stopOnFailure = "false"
|
stopOnFailure = "false"
|
||||||
syntaxCheck = "false"
|
syntaxCheck = "false"
|
||||||
bootstrap = "vendor/autoload.php" >
|
bootstrap = "bootstrap.php" >
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@ class AtolOnline
|
|||||||
return new Configuration();
|
return new Configuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $response
|
||||||
|
* @return OperationResponse
|
||||||
|
*/
|
||||||
public function deserializeOperationResponse($response)
|
public function deserializeOperationResponse($response)
|
||||||
{
|
{
|
||||||
return $this->serializer->deserialize(
|
return $this->serializer->deserialize(
|
||||||
@ -37,6 +41,10 @@ class AtolOnline
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $response
|
||||||
|
* @return OperationResponse
|
||||||
|
*/
|
||||||
public function deserializeCheckStatusResponse($response)
|
public function deserializeCheckStatusResponse($response)
|
||||||
{
|
{
|
||||||
return $this->serializer->deserialize(
|
return $this->serializer->deserialize(
|
||||||
@ -47,6 +55,10 @@ class AtolOnline
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $request
|
||||||
|
* @return mixed|string
|
||||||
|
*/
|
||||||
public function serializeOperationRequest($request)
|
public function serializeOperationRequest($request)
|
||||||
{
|
{
|
||||||
return $this->serializer->serialize(
|
return $this->serializer->serialize(
|
||||||
|
@ -8,6 +8,7 @@ class OperationResponse
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Поле отсутсвует в ответе а операцию sell с ошибкой начиная с 4й версии
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @Serializer\Groups({"post", "get"})
|
* @Serializer\Groups({"post", "get"})
|
||||||
@ -91,8 +92,6 @@ class OperationResponse
|
|||||||
*/
|
*/
|
||||||
private $callbackUrl;
|
private $callbackUrl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -4,6 +4,7 @@ namespace AtolOnlineClient\Tests;
|
|||||||
|
|
||||||
use AtolOnlineClient\AtolOnline;
|
use AtolOnlineClient\AtolOnline;
|
||||||
use AtolOnlineClient\Configuration;
|
use AtolOnlineClient\Configuration;
|
||||||
|
use AtolOnlineClient\Response\OperationResponse;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class AtolOnlineTest extends TestCase
|
class AtolOnlineTest extends TestCase
|
||||||
@ -14,4 +15,32 @@ class AtolOnlineTest extends TestCase
|
|||||||
$atol = new AtolOnline();
|
$atol = new AtolOnline();
|
||||||
$this->assertInstanceOf(Configuration::class, $atol->createConfiguration());
|
$this->assertInstanceOf(Configuration::class, $atol->createConfiguration());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider dataSellErrorResponse
|
||||||
|
*/
|
||||||
|
public function testDeserializeOperationResponse($file)
|
||||||
|
{
|
||||||
|
$response = file_get_contents(__DIR__ . '/data/'. $file);
|
||||||
|
$atol = new AtolOnline();
|
||||||
|
$operationResponse = $atol->deserializeOperationResponse($response);
|
||||||
|
$this->assertInstanceOf(OperationResponse::class, $operationResponse);
|
||||||
|
$this->assertEquals('12.04.2017 06:15:06', $operationResponse->getTimestamp());
|
||||||
|
$this->assertEquals('fail', $operationResponse->getStatus());
|
||||||
|
$this->assertEquals(30, $operationResponse->getError()->getCode());
|
||||||
|
$this->assertEquals('system', $operationResponse->getError()->getType());
|
||||||
|
$this->assertEquals(
|
||||||
|
' Передан некорректный UUID : "{0}". Необходимо повторить запрос с корректными данными ',
|
||||||
|
$operationResponse->getError()->getText()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataSellErrorResponse()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['sell_error_response_v3.json'],
|
||||||
|
['sell_error_response_v3.json']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"uuid": "4355",
|
||||||
|
"timestamp": "12.04.2017 06:15:06",
|
||||||
|
"status": "fail",
|
||||||
|
"error": {
|
||||||
|
"error_id": "475d6d8d-844d-4d05-aa8b-e3dbdf4defd6",
|
||||||
|
"code": 30,
|
||||||
|
"text": " Передан некорректный UUID : \"{0}\". Необходимо повторить запрос с корректными данными ",
|
||||||
|
"type": "system"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"timestamp": "12.04.2017 06:15:06",
|
||||||
|
"status": "fail",
|
||||||
|
"error": {
|
||||||
|
"error_id": "475d6d8d-844d-4d05-aa8b-e3dbdf4defd6",
|
||||||
|
"code": 30,
|
||||||
|
"text": " Передан некорректный UUID : \"{0}\". Необходимо повторить запрос с корректными данными ",
|
||||||
|
"type": "system"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user