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.xml
|
||||
clover.xml
|
||||
composer.lock
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user