Skip to content

Commit

Permalink
Added custom_base test
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed May 8, 2024
1 parent 8c941cc commit 51623ee
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/unit/Grav/Common/UriTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Codeception\Util\Fixtures;
use Grav\Common\Config\Config;
use Grav\Common\Grav;
use Grav\Common\Uri;
use Grav\Common\Utils;
Expand All @@ -16,6 +17,9 @@ class UriTest extends \Codeception\TestCase\Test
/** @var Uri $uri */
protected $uri;

/** @var Config $config */
protected $config;

protected $tests = [
'/path' => [
'scheme' => '',
Expand Down Expand Up @@ -704,7 +708,7 @@ class UriTest extends \Codeception\TestCase\Test
'route' => '/localhost',
'paths' => ['localhost'],
'params' => '/script%3E:',
'url' => '//localhost',
'url' => '/localhost',
'environment' => 'unknown',
'basename' => 'localhost',
'base' => '',
Expand Down Expand Up @@ -859,6 +863,7 @@ protected function _before(): void
$grav = Fixtures::get('grav');
$this->grav = $grav();
$this->uri = $this->grav['uri'];
$this->config = $this->grav['config'];
}

protected function _after(): void
Expand Down Expand Up @@ -1149,4 +1154,25 @@ public function testAddNonce(): void
{
$this->runTestSet($this->tests, 'addNonce');
}

public function testCustomBase(): void
{
$current_base = $this->config->get('system.custom_base_url');
$this->config->set('system.custom_base_url', '/test');
$this->uri->initializeWithURL('https://mydomain.example.com:8090/test/korteles/kodai%20something?test=true#some-fragment')->init();

$this->assertSame([
"scheme" => "https",
"host" => "mydomain.example.com",
"port" => 8090,
"user" => null,
"pass" => null,
"path" => "/korteles/kodai%20something",
"params" => [],
"query" => "test=true",
"fragment" => "some-fragment",
], $this->uri->toArray());

$this->config->set('system.custom_base_url', $current_base);
}
}

0 comments on commit 51623ee

Please sign in to comment.