Исправлена очистка версии api
This commit is contained in:
parent
1c68383869
commit
66690ac5dd
@ -28,7 +28,7 @@ class Utils
|
||||
*/
|
||||
public static function removeVersionFromUri(string $uri): string
|
||||
{
|
||||
return (string) preg_replace('/\/v\d{1,3}\/?/', '', $uri);
|
||||
return (string) preg_replace('#api/v\d{1,3}/?#', 'api', $uri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
37
tests/src/Component/UtilsTest.php
Normal file
37
tests/src/Component/UtilsTest.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\Tests\Component;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RetailCrm\Api\Component\Utils;
|
||||
|
||||
class UtilsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider removeVersionProvider
|
||||
*/
|
||||
public function testRemoveVersionFromUri(string $uri, string $expectedResult): void
|
||||
{
|
||||
$actualResult = Utils::removeVersionFromUri($uri);
|
||||
|
||||
self::assertEquals($expectedResult, $actualResult);
|
||||
}
|
||||
|
||||
public function removeVersionProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'https://v5gv5hv5fv5jv5v5fgv59hbfg9.retailcrm.io/api/v5',
|
||||
'https://v5gv5hv5fv5jv5v5fgv59hbfg9.retailcrm.io/api',
|
||||
],
|
||||
[
|
||||
'https://v5gv5hv5fv5jv5v5fgv59hbfg9.retailcrm.io/api/v5/',
|
||||
'https://v5gv5hv5fv5jv5v5fgv59hbfg9.retailcrm.io/api',
|
||||
],
|
||||
[
|
||||
'https://v5gv5hv5fv5jv5v5fgv59hbfg9.retailcrm.io',
|
||||
'https://v5gv5hv5fv5jv5v5fgv59hbfg9.retailcrm.io',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user