additional fixes
This commit is contained in:
parent
45b1012632
commit
7e1ed1a241
1
.gitignore
vendored
1
.gitignore
vendored
@ -195,3 +195,4 @@ build/*
|
|||||||
# Test report & coverage
|
# Test report & coverage
|
||||||
test-report.xml
|
test-report.xml
|
||||||
clover.xml
|
clover.xml
|
||||||
|
composer.lock
|
||||||
|
@ -13,7 +13,12 @@ namespace RetailCrm\Mg\Bot;
|
|||||||
use BadMethodCallException;
|
use BadMethodCallException;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use GuzzleHttp\Psr7\Request;
|
||||||
|
use GuzzleHttp\Psr7\Utils;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use RetailCrm\Common\Exception\InvalidJsonException;
|
use RetailCrm\Common\Exception\InvalidJsonException;
|
||||||
use RetailCrm\Common\Exception\LimitException;
|
use RetailCrm\Common\Exception\LimitException;
|
||||||
use RetailCrm\Common\Exception\NotFoundException;
|
use RetailCrm\Common\Exception\NotFoundException;
|
||||||
@ -22,11 +27,6 @@ use RetailCrm\Common\Serializer;
|
|||||||
use RetailCrm\Common\Url;
|
use RetailCrm\Common\Url;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Symfony\Component\Validator\Validation;
|
use Symfony\Component\Validator\Validation;
|
||||||
use GuzzleHttp\Client;
|
|
||||||
use GuzzleHttp\Psr7\Request;
|
|
||||||
use GuzzleHttp\Psr7\Utils;
|
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class HttpClient
|
* Class HttpClient
|
||||||
@ -216,14 +216,15 @@ class HttpClient
|
|||||||
/**
|
/**
|
||||||
* Validate given class
|
* Validate given class
|
||||||
*
|
*
|
||||||
* @param string $class
|
* @param object $class
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function validateRequest($class)
|
private function validateRequest(object $class)
|
||||||
{
|
{
|
||||||
$validator = Validation::createValidatorBuilder()
|
$validator = Validation::createValidatorBuilder()
|
||||||
->enableAnnotationMapping()
|
->enableAnnotationMapping()
|
||||||
|
->addDefaultDoctrineAnnotationReader()
|
||||||
->getValidator();
|
->getValidator();
|
||||||
|
|
||||||
$errors = $validator->validate($class);
|
$errors = $validator->validate($class);
|
||||||
|
@ -27,7 +27,7 @@ class UploadFileByUrlRequest implements ModelInterface
|
|||||||
*
|
*
|
||||||
* @Type("string")
|
* @Type("string")
|
||||||
* @Accessor(getter="getUrl",setter="setUrl")
|
* @Accessor(getter="getUrl",setter="setUrl")
|
||||||
* @Assert\NotBlank()
|
* @Assert\NotBlank(allowNull=false)
|
||||||
* @Assert\Url()
|
* @Assert\Url()
|
||||||
*/
|
*/
|
||||||
private $url;
|
private $url;
|
||||||
|
@ -27,7 +27,7 @@ class FileTest extends TestCase
|
|||||||
* @group("upload")
|
* @group("upload")
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function testUploadFileByUrlException()
|
public function testUploadFileByUrlEmpty()
|
||||||
{
|
{
|
||||||
$client = self::getApiClient(
|
$client = self::getApiClient(
|
||||||
null,
|
null,
|
||||||
@ -38,6 +38,21 @@ class FileTest extends TestCase
|
|||||||
|
|
||||||
self::expectException(\InvalidArgumentException::class);
|
self::expectException(\InvalidArgumentException::class);
|
||||||
$client->uploadFileByUrl('');
|
$client->uploadFileByUrl('');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @group("upload")
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function testUploadFileByUrlInvalid()
|
||||||
|
{
|
||||||
|
$client = self::getApiClient(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
$this->getErrorsResponse(400, 'Something is not quite right.')
|
||||||
|
);
|
||||||
|
|
||||||
|
self::expectException(\InvalidArgumentException::class);
|
||||||
$client->uploadFileByUrl('rar');
|
$client->uploadFileByUrl('rar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user