1
0
mirror of synced 2024-11-25 13:16:01 +03:00

update dependencies

This commit is contained in:
Pavel 2022-12-22 15:40:59 +03:00 committed by GitHub
commit 910bf5e118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 58 additions and 4477 deletions

View File

@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
php-version: ['7.2', '7.3', '7.4', '8.0'] php-version: ['7.3', '7.4', '8.0', '8.1']
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Setup PHP ${{ matrix.php-version }} - name: Setup PHP ${{ matrix.php-version }}

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

@ -16,17 +16,17 @@
"ext-curl": "*", "ext-curl": "*",
"ext-json": "*", "ext-json": "*",
"jms/serializer": "3.*", "jms/serializer": "3.*",
"symfony/validator": "5.4.*", "symfony/validator": "5.4.*|^6",
"doctrine/annotations": "1.13.*", "doctrine/annotations": "^1",
"doctrine/cache": "1.11.*", "guzzlehttp/guzzle": "7.*",
"guzzlehttp/guzzle": "6.*", "symfony/intl": "5.4.*|^6",
"symfony/intl": "^5.4" "symfony/cache": "5.4.*|^6"
}, },
"require-dev": { "require-dev": {
"phpmd/phpmd": "2.*", "phpmd/phpmd": "2.*",
"squizlabs/php_codesniffer": "3.4.*", "squizlabs/php_codesniffer": "3.4.*",
"symfony/dotenv": "5.4.*", "symfony/dotenv": "5.4.*",
"phpunit/phpunit": "8.5.*", "phpunit/phpunit": "^9",
"phpstan/phpstan": "0.12.*" "phpstan/phpstan": "0.12.*"
}, },
"support": { "support": {

4436
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html --> <!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
colors="false" colors="false"
bootstrap="tests/bootstrap.php" bootstrap="tests/bootstrap.php"
@ -15,22 +13,21 @@
stopOnFailure="false" stopOnFailure="false"
stopOnIncomplete="false" stopOnIncomplete="false"
stopOnSkipped="false" stopOnSkipped="false"
stopOnRisky="false" stopOnRisky="false">
> <coverage>
<testsuites> <include>
<testsuite name="Project Test Suite"> <directory>src</directory>
<directory>tests</directory> </include>
</testsuite> <report>
</testsuites> <clover outputFile="clover.xml"/>
</report>
<filter> </coverage>
<whitelist> <testsuites>
<directory>src</directory> <testsuite name="Project Test Suite">
</whitelist> <directory>tests</directory>
</filter> </testsuite>
</testsuites>
<logging> <logging>
<log type="coverage-clover" target="clover.xml"/> <junit outputFile="/tmp/logfile.xml"/>
<log type="junit" target="/tmp/logfile.xml"/> </logging>
</logging>
</phpunit> </phpunit>

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\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
use function GuzzleHttp\Psr7\stream_for;
/** /**
* Class HttpClient * Class HttpClient
@ -137,7 +137,7 @@ class HttpClient
[self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH, self::METHOD_DELETE] [self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH, self::METHOD_DELETE]
) && is_string($requestBody) ) && is_string($requestBody)
) { ) {
$request = $request->withBody(stream_for($requestBody)); $request = $request->withBody(Utils::streamFor($requestBody));
} }
$responseObject = null; $responseObject = null;
@ -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,17 +27,32 @@ 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,
null, null,
false, false,
$this->getEmptyResponse(400) $this->getErrorsResponse(400, 'Something is not quite right.')
); );
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');
} }

View File

@ -6,8 +6,11 @@ if (function_exists('date_default_timezone_set')
date_default_timezone_set(date_default_timezone_get()); date_default_timezone_set(date_default_timezone_get());
} }
$loader = include dirname(__DIR__) . '/vendor/autoload.php'; (static function () {
$loader->add('RetailCrm\\Mg\\Bot\\Test', __DIR__); $loader = include dirname(__DIR__) . '/vendor/autoload.php';
$loader->add('RetailCrm\\Mg\\Bot\\Test', __DIR__);
})();
use Symfony\Component\Dotenv\Dotenv; use Symfony\Component\Dotenv\Dotenv;