Merge pull request #561 from arabcoders/dev

Allow backends to be served from /subfolders
This commit is contained in:
Abdulmohsen
2024-10-12 16:05:10 +03:00
committed by GitHub
7 changed files with 543 additions and 519 deletions

58
composer.lock generated
View File

@@ -68,16 +68,16 @@
}, },
{ {
"name": "dragonmantank/cron-expression", "name": "dragonmantank/cron-expression",
"version": "v3.3.3", "version": "v3.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/dragonmantank/cron-expression.git", "url": "https://github.com/dragonmantank/cron-expression.git",
"reference": "adfb1f505deb6384dc8b39804c5065dd3c8c8c0a" "reference": "8c784d071debd117328803d86b2097615b457500"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/adfb1f505deb6384dc8b39804c5065dd3c8c8c0a", "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/8c784d071debd117328803d86b2097615b457500",
"reference": "adfb1f505deb6384dc8b39804c5065dd3c8c8c0a", "reference": "8c784d071debd117328803d86b2097615b457500",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -90,10 +90,14 @@
"require-dev": { "require-dev": {
"phpstan/extension-installer": "^1.0", "phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.0", "phpstan/phpstan": "^1.0",
"phpstan/phpstan-webmozart-assert": "^1.0",
"phpunit/phpunit": "^7.0|^8.0|^9.0" "phpunit/phpunit": "^7.0|^8.0|^9.0"
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Cron\\": "src/Cron/" "Cron\\": "src/Cron/"
@@ -117,7 +121,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/dragonmantank/cron-expression/issues", "issues": "https://github.com/dragonmantank/cron-expression/issues",
"source": "https://github.com/dragonmantank/cron-expression/tree/v3.3.3" "source": "https://github.com/dragonmantank/cron-expression/tree/v3.4.0"
}, },
"funding": [ "funding": [
{ {
@@ -125,7 +129,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-08-10T19:36:49+00:00" "time": "2024-10-09T13:47:03+00:00"
}, },
{ {
"name": "halaxa/json-machine", "name": "halaxa/json-machine",
@@ -3561,12 +3565,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Roave/SecurityAdvisories.git", "url": "https://github.com/Roave/SecurityAdvisories.git",
"reference": "6f63660a573ec1e6d48d54ff7c44dfb1e303f30d" "reference": "c3c55a0f6643119fa8699577cc83ca6256d98ab5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/6f63660a573ec1e6d48d54ff7c44dfb1e303f30d", "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/c3c55a0f6643119fa8699577cc83ca6256d98ab5",
"reference": "6f63660a573ec1e6d48d54ff7c44dfb1e303f30d", "reference": "c3c55a0f6643119fa8699577cc83ca6256d98ab5",
"shasum": "" "shasum": ""
}, },
"conflict": { "conflict": {
@@ -3667,7 +3671,7 @@
"concrete5/core": "<8.5.8|>=9,<9.1", "concrete5/core": "<8.5.8|>=9,<9.1",
"contao-components/mediaelement": ">=2.14.2,<2.21.1", "contao-components/mediaelement": ">=2.14.2,<2.21.1",
"contao/comments-bundle": ">=2,<4.13.40|>=5.0.0.0-RC1-dev,<5.3.4", "contao/comments-bundle": ">=2,<4.13.40|>=5.0.0.0-RC1-dev,<5.3.4",
"contao/contao": ">=3,<3.5.37|>=4,<4.4.56|>=4.5,<4.9.40|>=4.10,<4.11.7|>=4.13,<4.13.21|>=5.1,<5.1.4", "contao/contao": "<=5.4.1",
"contao/core": "<3.5.39", "contao/core": "<3.5.39",
"contao/core-bundle": "<4.13.49|>=5,<5.3.15|>=5.4,<5.4.3", "contao/core-bundle": "<4.13.49|>=5,<5.3.15|>=5.4,<5.4.3",
"contao/listing-bundle": ">=3,<=3.5.30|>=4,<4.4.8", "contao/listing-bundle": ">=3,<=3.5.30|>=4,<4.4.8",
@@ -3690,6 +3694,7 @@
"derhansen/fe_change_pwd": "<2.0.5|>=3,<3.0.3", "derhansen/fe_change_pwd": "<2.0.5|>=3,<3.0.3",
"derhansen/sf_event_mgt": "<4.3.1|>=5,<5.1.1|>=7,<7.4", "derhansen/sf_event_mgt": "<4.3.1|>=5,<5.1.1|>=7,<7.4",
"desperado/xml-bundle": "<=0.1.7", "desperado/xml-bundle": "<=0.1.7",
"dev-lancer/minecraft-motd-parser": "<=1.0.5",
"devgroup/dotplant": "<2020.09.14-dev", "devgroup/dotplant": "<2020.09.14-dev",
"directmailteam/direct-mail": "<6.0.3|>=7,<7.0.3|>=8,<9.5.2", "directmailteam/direct-mail": "<6.0.3|>=7,<7.0.3|>=8,<9.5.2",
"doctrine/annotations": "<1.2.7", "doctrine/annotations": "<1.2.7",
@@ -3704,9 +3709,9 @@
"dolibarr/dolibarr": "<19.0.2", "dolibarr/dolibarr": "<19.0.2",
"dompdf/dompdf": "<2.0.4", "dompdf/dompdf": "<2.0.4",
"doublethreedigital/guest-entries": "<3.1.2", "doublethreedigital/guest-entries": "<3.1.2",
"drupal/core": ">=6,<6.38|>=7,<7.96|>=8,<=11.0.4", "drupal/core": ">=6,<6.38|>=7,<7.96|>=8,<10.2.9|>=10.3,<10.3.6|>=11,<11.0.5",
"drupal/core-recommended": ">=8,<=11.0.4", "drupal/core-recommended": ">=8,<10.2.9|>=10.3,<10.3.6|>=11,<11.0.5",
"drupal/drupal": ">=5,<5.11|>=6,<6.38|>=7,<7.80|>=8,<=11.0.4", "drupal/drupal": ">=5,<5.11|>=6,<6.38|>=7,<7.80|>=8,<10.2.9|>=10.3,<10.3.6|>=11,<11.0.5",
"duncanmcclean/guest-entries": "<3.1.2", "duncanmcclean/guest-entries": "<3.1.2",
"dweeves/magmi": "<=0.7.24", "dweeves/magmi": "<=0.7.24",
"ec-cube/ec-cube": "<2.4.4|>=2.11,<=2.17.1|>=3,<=3.0.18.0-patch4|>=4,<=4.1.2", "ec-cube/ec-cube": "<2.4.4|>=2.11,<=2.17.1|>=3,<=3.0.18.0-patch4|>=4,<=4.1.2",
@@ -3872,13 +3877,15 @@
"klaviyo/magento2-extension": ">=1,<3", "klaviyo/magento2-extension": ">=1,<3",
"knplabs/knp-snappy": "<=1.4.2", "knplabs/knp-snappy": "<=1.4.2",
"kohana/core": "<3.3.3", "kohana/core": "<3.3.3",
"krayin/laravel-crm": "<1.2.2", "krayin/laravel-crm": "<=1.3",
"kreait/firebase-php": ">=3.2,<3.8.1", "kreait/firebase-php": ">=3.2,<3.8.1",
"kumbiaphp/kumbiapp": "<=1.1.1", "kumbiaphp/kumbiapp": "<=1.1.1",
"la-haute-societe/tcpdf": "<6.2.22", "la-haute-societe/tcpdf": "<6.2.22",
"laminas/laminas-diactoros": "<2.18.1|==2.19|==2.20|==2.21|==2.22|==2.23|>=2.24,<2.24.2|>=2.25,<2.25.2", "laminas/laminas-diactoros": "<2.18.1|==2.19|==2.20|==2.21|==2.22|==2.23|>=2.24,<2.24.2|>=2.25,<2.25.2",
"laminas/laminas-form": "<2.17.1|>=3,<3.0.2|>=3.1,<3.1.1", "laminas/laminas-form": "<2.17.1|>=3,<3.0.2|>=3.1,<3.1.1",
"laminas/laminas-http": "<2.14.2", "laminas/laminas-http": "<2.14.2",
"lara-zeus/artemis": ">=1,<=1.0.6",
"lara-zeus/dynamic-dashboard": ">=3,<=3.0.1",
"laravel/fortify": "<1.11.1", "laravel/fortify": "<1.11.1",
"laravel/framework": "<6.20.44|>=7,<7.30.6|>=8,<8.75", "laravel/framework": "<6.20.44|>=7,<7.30.6|>=8,<8.75",
"laravel/laravel": ">=5.4,<5.4.22", "laravel/laravel": ">=5.4,<5.4.22",
@@ -3894,13 +3901,13 @@
"librenms/librenms": "<2017.08.18", "librenms/librenms": "<2017.08.18",
"liftkit/database": "<2.13.2", "liftkit/database": "<2.13.2",
"lightsaml/lightsaml": "<1.3.5", "lightsaml/lightsaml": "<1.3.5",
"limesurvey/limesurvey": "<3.27.19", "limesurvey/limesurvey": "<6.5.12",
"livehelperchat/livehelperchat": "<=3.91", "livehelperchat/livehelperchat": "<=3.91",
"livewire/livewire": ">2.2.4,<2.2.6|>=3.3.5,<3.4.9", "livewire/livewire": "<2.12.7|>=3.0.0.0-beta1,<3.5.2",
"lms/routes": "<2.1.1", "lms/routes": "<2.1.1",
"localizationteam/l10nmgr": "<7.4|>=8,<8.7|>=9,<9.2", "localizationteam/l10nmgr": "<7.4|>=8,<8.7|>=9,<9.2",
"luyadev/yii-helpers": "<1.2.1", "luyadev/yii-helpers": "<1.2.1",
"magento/community-edition": "<2.4.5|==2.4.5|>=2.4.5.0-patch1,<2.4.5.0-patch9|==2.4.6|>=2.4.6.0-patch1,<2.4.6.0-patch7|==2.4.7|>=2.4.7.0-patch1,<2.4.7.0-patch2", "magento/community-edition": "<2.4.5|==2.4.5|>=2.4.5.0-patch1,<2.4.5.0-patch10|==2.4.6|>=2.4.6.0-patch1,<2.4.6.0-patch8|>=2.4.7.0-beta1,<2.4.7.0-patch3",
"magento/core": "<=1.9.4.5", "magento/core": "<=1.9.4.5",
"magento/magento1ce": "<1.9.4.3-dev", "magento/magento1ce": "<1.9.4.3-dev",
"magento/magento1ee": ">=1,<1.14.4.3-dev", "magento/magento1ee": ">=1,<1.14.4.3-dev",
@@ -3914,6 +3921,7 @@
"mautic/core": "<4.4.13|>=5,<5.1.1", "mautic/core": "<4.4.13|>=5,<5.1.1",
"mautic/core-lib": ">=1.0.0.0-beta,<4.4.13|>=5.0.0.0-alpha,<5.1.1", "mautic/core-lib": ">=1.0.0.0-beta,<4.4.13|>=5.0.0.0-alpha,<5.1.1",
"mdanter/ecc": "<2", "mdanter/ecc": "<2",
"mediawiki/cargo": "<3.6.1",
"mediawiki/core": "<1.36.2", "mediawiki/core": "<1.36.2",
"mediawiki/matomo": "<2.4.3", "mediawiki/matomo": "<2.4.3",
"mediawiki/semantic-media-wiki": "<4.0.2", "mediawiki/semantic-media-wiki": "<4.0.2",
@@ -3970,7 +3978,7 @@
"nzo/url-encryptor-bundle": ">=4,<4.3.2|>=5,<5.0.1", "nzo/url-encryptor-bundle": ">=4,<4.3.2|>=5,<5.0.1",
"october/backend": "<1.1.2", "october/backend": "<1.1.2",
"october/cms": "<1.0.469|==1.0.469|==1.0.471|==1.1.1", "october/cms": "<1.0.469|==1.0.469|==1.0.471|==1.1.1",
"october/october": "<=3.4.4", "october/october": "<=3.6.4",
"october/rain": "<1.0.472|>=1.1,<1.1.2", "october/rain": "<1.0.472|>=1.1,<1.1.2",
"october/system": "<1.0.476|>=1.1,<1.1.12|>=2,<2.2.34|>=3,<3.5.15", "october/system": "<1.0.476|>=1.1,<1.1.12|>=2,<2.2.34|>=3,<3.5.15",
"omeka/omeka-s": "<4.0.3", "omeka/omeka-s": "<4.0.3",
@@ -4022,7 +4030,7 @@
"phpmyfaq/phpmyfaq": "<3.2.5|==3.2.5", "phpmyfaq/phpmyfaq": "<3.2.5|==3.2.5",
"phpoffice/common": "<0.2.9", "phpoffice/common": "<0.2.9",
"phpoffice/phpexcel": "<1.8", "phpoffice/phpexcel": "<1.8",
"phpoffice/phpspreadsheet": "<1.29.1|>=2,<2.1.1|>=2.2,<2.2.1", "phpoffice/phpspreadsheet": "<1.29.2|>=2,<2.1.1|>=2.2,<2.3",
"phpseclib/phpseclib": "<2.0.47|>=3,<3.0.36", "phpseclib/phpseclib": "<2.0.47|>=3,<3.0.36",
"phpservermon/phpservermon": "<3.6", "phpservermon/phpservermon": "<3.6",
"phpsysinfo/phpsysinfo": "<3.4.3", "phpsysinfo/phpsysinfo": "<3.4.3",
@@ -4132,7 +4140,7 @@
"slim/slim": "<2.6", "slim/slim": "<2.6",
"slub/slub-events": "<3.0.3", "slub/slub-events": "<3.0.3",
"smarty/smarty": "<4.5.3|>=5,<5.1.1", "smarty/smarty": "<4.5.3|>=5,<5.1.1",
"snipe/snipe-it": "<6.4.2", "snipe/snipe-it": "<7.0.10",
"socalnick/scn-social-auth": "<1.15.2", "socalnick/scn-social-auth": "<1.15.2",
"socialiteproviders/steam": "<1.1", "socialiteproviders/steam": "<1.1",
"spatie/browsershot": "<3.57.4", "spatie/browsershot": "<3.57.4",
@@ -4150,7 +4158,7 @@
"subhh/libconnect": "<7.0.8|>=8,<8.1", "subhh/libconnect": "<7.0.8|>=8,<8.1",
"sukohi/surpass": "<1", "sukohi/surpass": "<1",
"sulu/form-bundle": ">=2,<2.5.3", "sulu/form-bundle": ">=2,<2.5.3",
"sulu/sulu": "<1.6.44|>=2,<2.4.17|>=2.5,<2.5.13", "sulu/sulu": "<1.6.44|>=2,<2.6.5",
"sumocoders/framework-user-bundle": "<1.4", "sumocoders/framework-user-bundle": "<1.4",
"superbig/craft-audit": "<3.0.2", "superbig/craft-audit": "<3.0.2",
"swag/paypal": "<5.4.4", "swag/paypal": "<5.4.4",
@@ -4222,13 +4230,13 @@
"topthink/thinkphp": "<=3.2.3", "topthink/thinkphp": "<=3.2.3",
"torrentpier/torrentpier": "<=2.4.3", "torrentpier/torrentpier": "<=2.4.3",
"tpwd/ke_search": "<4.0.3|>=4.1,<4.6.6|>=5,<5.0.2", "tpwd/ke_search": "<4.0.3|>=4.1,<4.6.6|>=5,<5.0.2",
"tribalsystems/zenario": "<9.5.60602", "tribalsystems/zenario": "<=9.7.61188",
"truckersmp/phpwhois": "<=4.3.1", "truckersmp/phpwhois": "<=4.3.1",
"ttskch/pagination-service-provider": "<1", "ttskch/pagination-service-provider": "<1",
"twbs/bootstrap": "<=3.4.1|>=4,<=4.6.2", "twbs/bootstrap": "<=3.4.1|>=4,<=4.6.2",
"twig/twig": "<1.44.8|>=2,<2.16.1|>=3,<3.11.1|>=3.12,<3.14", "twig/twig": "<1.44.8|>=2,<2.16.1|>=3,<3.11.1|>=3.12,<3.14",
"typo3/cms": "<9.5.29|>=10,<10.4.35|>=11,<11.5.23|>=12,<12.2", "typo3/cms": "<9.5.29|>=10,<10.4.35|>=11,<11.5.23|>=12,<12.2",
"typo3/cms-backend": "<4.1.14|>=4.2,<4.2.15|>=4.3,<4.3.7|>=4.4,<4.4.4|>=7,<=7.6.50|>=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", "typo3/cms-backend": "<4.1.14|>=4.2,<4.2.15|>=4.3,<4.3.7|>=4.4,<4.4.4|>=7,<=7.6.50|>=8,<=8.7.39|>=9,<=9.5.24|>=10,<10.4.46|>=11,<11.5.40|>=12,<12.4.21|>=13,<13.3.1",
"typo3/cms-core": "<=8.7.56|>=9,<=9.5.47|>=10,<=10.4.44|>=11,<=11.5.36|>=12,<=12.4.14|>=13,<=13.1", "typo3/cms-core": "<=8.7.56|>=9,<=9.5.47|>=10,<=10.4.44|>=11,<=11.5.36|>=12,<=12.4.14|>=13,<=13.1",
"typo3/cms-extbase": "<6.2.24|>=7,<7.6.8|==8.1.1", "typo3/cms-extbase": "<6.2.24|>=7,<7.6.8|==8.1.1",
"typo3/cms-fluid": "<4.3.4|>=4.4,<4.4.1", "typo3/cms-fluid": "<4.3.4|>=4.4,<4.4.1",
@@ -4381,7 +4389,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-09-30T18:06:02+00:00" "time": "2024-10-11T18:06:00+00:00"
}, },
{ {
"name": "sebastian/cli-parser", "name": "sebastian/cli-parser",

File diff suppressed because it is too large Load Diff

View File

@@ -172,7 +172,9 @@ final class Update
private function fromRequest(array $config, iRequest $request, iClient $client): array private function fromRequest(array $config, iRequest $request, iClient $client): array
{ {
$data = DataUtil::fromArray($request->getParsedBody()); $data = DataUtil::fromArray(
array_map(fn($v) => false === is_string($v) ? $v : trim($v), $request->getParsedBody())
);
$newData = [ $newData = [
'url' => $data->get('url'), 'url' => $data->get('url'),

View File

@@ -122,7 +122,9 @@ final class Add
private function fromRequest(string $type, iRequest $request, iClient $client): array private function fromRequest(string $type, iRequest $request, iClient $client): array
{ {
$data = DataUtil::fromArray($request->getParsedBody()); $data = DataUtil::fromArray(
array_map(fn($v) => false === is_string($v) ? $v : trim($v), $request->getParsedBody())
);
$config = [ $config = [
'type' => $type, 'type' => $type,

View File

@@ -12,27 +12,6 @@ class TestCase extends \PHPUnit\Framework\TestCase
{ {
protected TestHandler|null $handler = null; protected TestHandler|null $handler = null;
/**
* Prints logs to the standard output.
*
* @return void
*/
protected function printLogs(): void
{
if (null === $this->handler) {
return;
}
$d = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[0];
$getScript = ag($d, 'file');
$line = ag($d, 'line');
dump(
$getScript . ':' . $line,
array_map(fn($v) => $v['formatted'] ?? $v['message'], $this->handler->getRecords())
);
}
/** /**
* Checks if the given closure throws an exception. * Checks if the given closure throws an exception.
* *

View File

@@ -88,7 +88,13 @@ final class Uri implements UriInterface, Stringable
public function __toString(): string public function __toString(): string
{ {
return self::createUriString($this->scheme, $this->getAuthority(), $this->path, $this->query, $this->fragment); return self::createUriString(
$this->getScheme(),
$this->getAuthority(),
$this->getPath(),
$this->getQuery(),
$this->getFragment()
);
} }
public function getScheme(): string public function getScheme(): string

View File

@@ -17,27 +17,27 @@ class UriTest extends TestCase
'/', '/',
]; ];
private UriInterface|null $uri = null; protected function getUri(): UriInterface
protected function setUp(): void
{ {
parent::setUp(); return new Uri('http://user:pass@host:81/path?query=string#fragment');
$this->uri = new Uri('http://user:pass@host:81/path?query=string#fragment');
} }
public function test_scheme() public function test_scheme()
{ {
$this->assertSame('http', $this->uri->getScheme(), 'The protocol should be http'); $this->assertSame('http', $this->getUri()->getScheme(), 'The protocol should be http');
$url2 = $this->uri->withScheme('https'); $url2 = $this->getUri()->withScheme('https');
$this->assertSame('https', $url2->getScheme(), 'The protocol should be https'); $this->assertSame('https', $url2->getScheme(), 'The protocol should be https');
$obj = $this->getUri();
$this->assertSame( $this->assertSame(
spl_object_id($this->uri), spl_object_id($obj),
spl_object_id($this->uri->withScheme('HTTP')), spl_object_id($obj->withScheme('HTTP')),
'The object should be the same if the scheme is the same' 'The object should be the same if the scheme is the same'
); );
$this->checkException( $this->checkException(
closure: fn() => $this->uri->withScheme(false), closure: fn() => $this->getUri()->withScheme(false),
reason: 'Exception should be thrown if the scheme is not a string', reason: 'Exception should be thrown if the scheme is not a string',
exception: InvalidArgumentException::class, exception: InvalidArgumentException::class,
exceptionMessage: 'Scheme must be a string' exceptionMessage: 'Scheme must be a string'
@@ -46,12 +46,13 @@ class UriTest extends TestCase
public function test_host() public function test_host()
{ {
$this->assertSame('host', $this->uri->getHost(), 'The host should be host'); $this->assertSame('host', $this->getUri()->getHost(), 'The host should be host');
$url2 = $this->uri->withHost('host2'); $url2 = $this->getUri()->withHost('host2');
$this->assertSame('host2', $url2->getHost(), 'The host should be host2'); $this->assertSame('host2', $url2->getHost(), 'The host should be host2');
$obj = $this->getUri();
$this->assertSame( $this->assertSame(
spl_object_id($this->uri), spl_object_id($obj),
spl_object_id($this->uri->withHost($this->uri->getHost())), spl_object_id($obj->withHost($this->getUri()->getHost())),
'The object should be the same if the host is the same' 'The object should be the same if the host is the same'
); );
@@ -63,7 +64,7 @@ class UriTest extends TestCase
); );
$this->checkException( $this->checkException(
closure: fn() => $this->uri->withHost(false), closure: fn() => $this->getUri()->withHost(false),
reason: 'Exception should be thrown if the host is not a string', reason: 'Exception should be thrown if the host is not a string',
exception: InvalidArgumentException::class, exception: InvalidArgumentException::class,
exceptionMessage: 'Host must be a string' exceptionMessage: 'Host must be a string'
@@ -72,17 +73,18 @@ class UriTest extends TestCase
public function test_userInfo() public function test_userInfo()
{ {
$this->assertSame('user:pass', $this->uri->getUserInfo(), 'The user info should be user:pass'); $this->assertSame('user:pass', $this->getUri()->getUserInfo(), 'The user info should be user:pass');
$obj = $this->getUri();
$this->assertSame( $this->assertSame(
spl_object_id($this->uri), spl_object_id($obj),
spl_object_id($this->uri->withUserInfo('user', 'pass')), spl_object_id($obj->withUserInfo('user', 'pass')),
'The object should be the same if the user info is the same' 'The object should be the same if the user info is the same'
); );
$url2 = $this->uri->withUserInfo('user2', 'pass2'); $url2 = $this->getUri()->withUserInfo('user2', 'pass2');
$this->assertSame('user2:pass2', $url2->getUserInfo(), 'The user info should be user2:pass2'); $this->assertSame('user2:pass2', $url2->getUserInfo(), 'The user info should be user2:pass2');
$url3 = $this->uri->withUserInfo('user3'); $url3 = $this->getUri()->withUserInfo('user3');
$this->assertSame('user3', $url3->getUserInfo(), 'The user info should be user3'); $this->assertSame('user3', $url3->getUserInfo(), 'The user info should be user3');
$this->checkException( $this->checkException(
@@ -93,14 +95,14 @@ class UriTest extends TestCase
); );
$this->checkException( $this->checkException(
closure: fn() => $this->uri->withUserInfo('foo', false), closure: fn() => $this->getUri()->withUserInfo('foo', false),
reason: 'Exception should be thrown if the user info is not a string', reason: 'Exception should be thrown if the user info is not a string',
exception: InvalidArgumentException::class, exception: InvalidArgumentException::class,
exceptionMessage: 'must be a string' exceptionMessage: 'must be a string'
); );
$this->checkException( $this->checkException(
closure: fn() => $this->uri->withUserInfo(false, 'foo'), closure: fn() => $this->getUri()->withUserInfo(false, 'foo'),
reason: 'Exception should be thrown if the user info is not a string', reason: 'Exception should be thrown if the user info is not a string',
exception: InvalidArgumentException::class, exception: InvalidArgumentException::class,
exceptionMessage: 'must be a string' exceptionMessage: 'must be a string'
@@ -109,16 +111,17 @@ class UriTest extends TestCase
public function test_port() public function test_port()
{ {
$this->assertSame(81, $this->uri->getPort(), 'The port should be 80'); $this->assertSame(81, $this->getUri()->getPort(), 'The port should be 80');
$obj = $this->getUri();
$this->assertSame( $this->assertSame(
spl_object_id($this->uri), spl_object_id($obj),
spl_object_id($this->uri->withPort(81)), spl_object_id($obj->withPort(81)),
'The object should be the same if the port is the same' 'The object should be the same if the port is the same'
); );
$this->assertSame(8080, $this->uri->withPort(8080)->getPort(), 'The port should be 8080'); $this->assertSame(8080, $this->getUri()->withPort(8080)->getPort(), 'The port should be 8080');
$this->assertNull($this->uri->withPort(null)->getPort(), 'The port should be null'); $this->assertNull($this->getUri()->withPort(null)->getPort(), 'The port should be null');
$this->checkException( $this->checkException(
closure: fn() => $this->uri->withPort(65536), closure: fn() => $this->getUri()->withPort(65536),
reason: 'Exception should be thrown if the port is invalid', reason: 'Exception should be thrown if the port is invalid',
exception: InvalidArgumentException::class, exception: InvalidArgumentException::class,
); );
@@ -133,10 +136,14 @@ class UriTest extends TestCase
public function test_authority() public function test_authority()
{ {
$this->assertSame('user:pass@host:81', $this->uri->getAuthority(), 'The authority should be user:pass@host:81'); $this->assertSame(
'user:pass@host:81',
$this->getUri()->getAuthority(),
'The authority should be user:pass@host:81'
);
$this->assertSame( $this->assertSame(
'', '',
$this->uri->withHost('')->getAuthority(), $this->getUri()->withHost('')->getAuthority(),
'The authority should be empty if the host is empty' 'The authority should be empty if the host is empty'
); );
} }
@@ -156,36 +163,48 @@ class UriTest extends TestCase
$this->assertSame('/path/', $uri->withPath('/path/')->getPath(), 'The path should be /path'); $this->assertSame('/path/', $uri->withPath('/path/')->getPath(), 'The path should be /path');
$this->assertSame( $this->assertSame(
'/path/bar', '/path/bar',
$this->uri->withPath('/bar')->getPath(), $this->getUri()->withPath('/bar')->getPath(),
'The path should be /path/bar due to basePath' 'The path should be /path/bar due to basePath'
); );
$this->checkException( $this->checkException(
closure: fn() => $this->uri->withPath(false), closure: fn() => $this->getUri()->withPath(false),
reason: 'Exception should be thrown if the path is not a string', reason: 'Exception should be thrown if the path is not a string',
exception: InvalidArgumentException::class, exception: InvalidArgumentException::class,
exceptionMessage: 'must be a string' exceptionMessage: 'must be a string'
); );
$this->assertSame('/path/foo/', $this->uri->withHost('')->withPath('///foo/')->getPath()); $this->assertSame('/path/foo/', $this->getUri()->withHost('')->withPath('///foo/')->getPath());
$this->assertSame('/foo/', $uri->withPath('foo/')->getPath()); $this->assertSame('/foo/', $uri->withPath('foo/')->getPath());
$this->assertSame(
'/path/foo/',
$this->getUri()->withPath('/foo/')->getPath(),
'withPath should consider the base path if it was given in constructor.'
);
$this->assertSame(
'http://user:pass@host:81/path/foo/?query=string#fragment',
(string)$this->getUri()->withPath('/foo/'),
'uri string should consider the base path if it was given in constructor.'
);
} }
public function test_query() public function test_query()
{ {
$this->assertSame('query=string', $this->uri->getQuery(), 'The query should be query=string'); $this->assertSame('query=string', $this->getUri()->getQuery(), 'The query should be query=string');
$obj = $this->getUri();
$this->assertSame( $this->assertSame(
spl_object_id($this->uri), spl_object_id($obj),
spl_object_id($this->uri->withQuery('query=string')), spl_object_id($obj->withQuery('query=string')),
'The object should be the same if the query is the same' 'The object should be the same if the query is the same'
); );
$this->assertSame( $this->assertSame(
'query=string2', 'query=string2',
$this->uri->withQuery('query=string2')->getQuery(), $this->getUri()->withQuery('query=string2')->getQuery(),
'The query should be query=string2' 'The query should be query=string2'
); );
$this->assertSame('', $this->uri->withQuery('')->getQuery(), 'The query should be empty'); $this->assertSame('', $this->getUri()->withQuery('')->getQuery(), 'The query should be empty');
$this->checkException( $this->checkException(
closure: fn() => $this->uri->withQuery(false), closure: fn() => $this->getUri()->withQuery(false),
reason: 'parse_url returns false if the port is invalid', reason: 'parse_url returns false if the port is invalid',
exception: InvalidArgumentException::class, exception: InvalidArgumentException::class,
exceptionMessage: 'must be a string' exceptionMessage: 'must be a string'
@@ -194,21 +213,22 @@ class UriTest extends TestCase
public function test_fragment() public function test_fragment()
{ {
$this->assertSame('fragment', $this->uri->getFragment(), 'The fragment should be fragment'); $this->assertSame('fragment', $this->getUri()->getFragment(), 'The fragment should be fragment');
$obj = $this->getUri();
$this->assertSame( $this->assertSame(
spl_object_id($this->uri), spl_object_id($obj),
spl_object_id($this->uri->withFragment('fragment')), spl_object_id($obj->withFragment('fragment')),
'The object should be the same if the fragment is the same' 'The object should be the same if the fragment is the same'
); );
$this->assertSame( $this->assertSame(
'fragment2', 'fragment2',
$this->uri->withFragment('fragment2')->getFragment(), $this->getUri()->withFragment('fragment2')->getFragment(),
'The fragment should be fragment2' 'The fragment should be fragment2'
); );
$this->assertSame('', $this->uri->withFragment('')->getFragment(), 'The fragment should be empty'); $this->assertSame('', $this->getUri()->withFragment('')->getFragment(), 'The fragment should be empty');
$this->checkException( $this->checkException(
closure: fn() => $this->uri->withFragment(false), closure: fn() => $this->getUri()->withFragment(false),
reason: 'Exception should be thrown if the fragment is not a string', reason: 'Exception should be thrown if the fragment is not a string',
exception: InvalidArgumentException::class, exception: InvalidArgumentException::class,
exceptionMessage: 'must be a string' exceptionMessage: 'must be a string'
@@ -219,7 +239,7 @@ class UriTest extends TestCase
{ {
$this->assertSame( $this->assertSame(
'http://user:pass@host:81/path?query=string#fragment', 'http://user:pass@host:81/path?query=string#fragment',
$this->uri->__toString(), $this->getUri()->__toString(),
'The string should be http://user:pass@host:81/path?query=string#fragment' 'The string should be http://user:pass@host:81/path?query=string#fragment'
); );