File: IndexUrlTestWithConstant.php

package info (click to toggle)
shaarli 0.15.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,640 kB
  • sloc: php: 30,003; javascript: 2,061; makefile: 135; xml: 69; python: 42; sh: 35
file content (51 lines) | stat: -rw-r--r-- 1,397 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

declare(strict_types=1);

namespace Shaarli\Http;

use Shaarli\TestCase;

/**
 * Test index_url with SHAARLI_ROOT_URL defined to override automatic retrieval.
 * This should stay in its dedicated class to make sure to not alter other tests of the suite.
 */
class IndexUrlTestWithConstant extends TestCase
{
    public static function setUpBeforeClass(): void
    {
        define('SHAARLI_ROOT_URL', 'http://other-host.tld/subfolder/');
    }

    /**
     * The route is stored in REQUEST_URI and subfolder
     */
    public function testIndexUrlWithConstantDefined()
    {
        $this->assertEquals(
            'http://other-host.tld/subfolder/',
            index_url(
                [
                    'HTTPS' => 'Off',
                    'SERVER_NAME' => 'host.tld',
                    'SERVER_PORT' => '80',
                    'SCRIPT_NAME' => '/index.php',
                    'REQUEST_URI' => '/picture-wall',
                ]
            )
        );

        $this->assertEquals(
            'http://other-host.tld/subfolder/',
            index_url(
                [
                    'HTTPS' => 'Off',
                    'SERVER_NAME' => 'host.tld',
                    'SERVER_PORT' => '80',
                    'SCRIPT_NAME' => '/admin/index.php',
                    'REQUEST_URI' => '/admin/picture-wall',
                ]
            )
        );
    }
}