File: GetSiteUrlTest.php

package info (click to toggle)
postfixadmin 4.0.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,888 kB
  • sloc: php: 12,256; perl: 1,156; sh: 717; python: 142; xml: 63; sql: 3; makefile: 2
file content (59 lines) | stat: -rw-r--r-- 1,703 bytes parent folder | download
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
52
53
54
55
56
57
58
59
<?php

class GetSiteUrlTest extends \PHPUnit\Framework\TestCase
{
    public function testControlViaConfig()
    {
        $server = [];
        $orig = Config::getInstance()->getAll();
        $orig['site_url'] = 'https://example.com/postfixadmin-1.2.3.4/';
        Config::getInstance()->setAll($orig);

        $this->assertEquals('https://example.com/postfixadmin-1.2.3.4/', getSiteUrl($server));
    }

    public function testViaDiscovery()
    {
        $server = [
            'HTTP_HOST' => 'example.org',
            'REQUEST_SCHEME' => 'https',
            'REQUEST_URI' => '/postfixadmin-1.2.3.4/setup.php',
        ];

        $orig = Config::getInstance()->getAll();
        unset($orig['site_url']);
        Config::getInstance()->setAll($orig);

        $this->assertEquals('https://example.org/postfixadmin-1.2.3.4/', getSiteUrl($server));
    }

    public function testViaDiscoveryNoPrefix()
    {
        $server = [
            'HTTP_HOST' => 'example.org',
            'REQUEST_SCHEME' => 'https',
            'REQUEST_URI' => '/setup.php',
        ];

        $orig = Config::getInstance()->getAll();
        unset($orig['site_url']);
        Config::getInstance()->setAll($orig);

        $this->assertEquals('https://example.org/', getSiteUrl($server));
    }

    public function testViaDiscoveryhttp()
    {
        $server = [
            'HTTP_HOST' => 'example.org',
            'REQUEST_SCHEME' => 'http',
            'REQUEST_URI' => '/setup.php',
        ];

        $orig = Config::getInstance()->getAll();
        unset($orig['site_url']);
        Config::getInstance()->setAll($orig);

        $this->assertEquals('http://example.org/', getSiteUrl($server));
    }
}