1
0
mirror of synced 2024-11-25 05:06:02 +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.xml
clover.xml
composer.lock

View File

@ -13,7 +13,12 @@ namespace RetailCrm\Mg\Bot;
use BadMethodCallException;
use ErrorException;
use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Utils;
use InvalidArgumentException;
use Psr\Http\Message\ResponseInterface;
use RetailCrm\Common\Exception\InvalidJsonException;
use RetailCrm\Common\Exception\LimitException;
use RetailCrm\Common\Exception\NotFoundException;
@ -22,11 +27,6 @@ use RetailCrm\Common\Serializer;
use RetailCrm\Common\Url;
use RuntimeException;
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
@ -216,14 +216,15 @@ class HttpClient
/**
* Validate given class
*
* @param string $class
* @param object $class
*
* @return void
*/
private function validateRequest($class)
private function validateRequest(object $class)
{
$validator = Validation::createValidatorBuilder()
->enableAnnotationMapping()
->addDefaultDoctrineAnnotationReader()
->getValidator();
$errors = $validator->validate($class);

View File

@ -27,7 +27,7 @@ class UploadFileByUrlRequest implements ModelInterface
*
* @Type("string")
* @Accessor(getter="getUrl",setter="setUrl")
* @Assert\NotBlank()
* @Assert\NotBlank(allowNull=false)
* @Assert\Url()
*/
private $url;

View File

@ -27,7 +27,7 @@ class FileTest extends TestCase
* @group("upload")
* @throws \Exception
*/
public function testUploadFileByUrlException()
public function testUploadFileByUrlEmpty()
{
$client = self::getApiClient(
null,
@ -38,6 +38,21 @@ class FileTest extends TestCase
self::expectException(\InvalidArgumentException::class);
$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');
}