aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/http/HttpUtils/IndexUrlTestWithConstant.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-09-22 14:08:54 +0200
committerGitHub <noreply@github.com>2020-09-22 14:08:54 +0200
commit98e7a59ca21b51cbd86d09cd5d217c0c8bf3db77 (patch)
tree044721fd02d631f561b9279e5181905a2b1bfa49 /tests/http/HttpUtils/IndexUrlTestWithConstant.php
parent6f199ee48906ca8cdc7d7f2cacbd4c57f474c879 (diff)
parentb93cfeba7b5ddb8b20d805017404e73eafd68c95 (diff)
downloadShaarli-98e7a59ca21b51cbd86d09cd5d217c0c8bf3db77.tar.gz
Shaarli-98e7a59ca21b51cbd86d09cd5d217c0c8bf3db77.tar.zst
Shaarli-98e7a59ca21b51cbd86d09cd5d217c0c8bf3db77.zip
Merge pull request #1539 from ArthurHoaro/feature/manual-root-url
Diffstat (limited to 'tests/http/HttpUtils/IndexUrlTestWithConstant.php')
-rw-r--r--tests/http/HttpUtils/IndexUrlTestWithConstant.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/http/HttpUtils/IndexUrlTestWithConstant.php b/tests/http/HttpUtils/IndexUrlTestWithConstant.php
new file mode 100644
index 00000000..15ca3d72
--- /dev/null
+++ b/tests/http/HttpUtils/IndexUrlTestWithConstant.php
@@ -0,0 +1,51 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Shaarli\Http;
6
7use PHPUnit\Framework\TestCase;
8
9/**
10 * Test index_url with SHAARLI_ROOT_URL defined to override automatic retrieval.
11 * This should stay in its dedicated class to make sure to not alter other tests of the suite.
12 */
13class IndexUrlTestWithConstant extends TestCase
14{
15 public static function setUpBeforeClass(): void
16 {
17 define('SHAARLI_ROOT_URL', 'http://other-host.tld/subfolder/');
18 }
19
20 /**
21 * The route is stored in REQUEST_URI and subfolder
22 */
23 public function testIndexUrlWithConstantDefined()
24 {
25 $this->assertEquals(
26 'http://other-host.tld/subfolder/',
27 index_url(
28 array(
29 'HTTPS' => 'Off',
30 'SERVER_NAME' => 'host.tld',
31 'SERVER_PORT' => '80',
32 'SCRIPT_NAME' => '/index.php',
33 'REQUEST_URI' => '/picture-wall',
34 )
35 )
36 );
37
38 $this->assertEquals(
39 'http://other-host.tld/subfolder/',
40 index_url(
41 array(
42 'HTTPS' => 'Off',
43 'SERVER_NAME' => 'host.tld',
44 'SERVER_PORT' => '80',
45 'SCRIPT_NAME' => '/admin/index.php',
46 'REQUEST_URI' => '/admin/picture-wall',
47 )
48 )
49 );
50 }
51}