1
0
mirror of synced 2024-11-22 11:56:03 +03:00

additional fixes

This commit is contained in:
Pavel 2022-12-22 15:21:14 +03:00
parent 45b1012632
commit 7e1ed1a241
4 changed files with 26 additions and 9 deletions

1
.gitignore vendored
View File

@ -195,3 +195,4 @@ build/*
# Test report & coverage # Test report & coverage
test-report.xml test-report.xml
clover.xml clover.xml
composer.lock

View File

@ -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);

View File

@ -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;

View File

@ -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');
} }