File: IsHttpsTest.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 (36 lines) | stat: -rw-r--r-- 1,191 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
<?php

namespace Shaarli\Http;

/**
 * Class IsHttpsTest
 *
 * Test class for is_https() function.
 */
class IsHttpsTest extends \Shaarli\TestCase
{
    /**
     * Test is_https with HTTPS values.
     */
    public function testIsHttpsTrue()
    {
        $this->assertTrue(is_https(['HTTPS' => true]));
        $this->assertTrue(is_https(['HTTPS' => '1']));
        $this->assertTrue(is_https(['HTTPS' => false, 'HTTP_X_FORWARDED_PORT' => 443]));
        $this->assertTrue(is_https(['HTTPS' => false, 'HTTP_X_FORWARDED_PORT' => '443']));
        $this->assertTrue(is_https(['HTTPS' => false, 'HTTP_X_FORWARDED_PORT' => '443,123,456,']));
    }

    /**
     * Test is_https with HTTP values.
     */
    public function testIsHttpsFalse()
    {
        $this->assertFalse(is_https([]));
        $this->assertFalse(is_https(['HTTPS' => false]));
        $this->assertFalse(is_https(['HTTPS' => '0']));
        $this->assertFalse(is_https(['HTTPS' => false, 'HTTP_X_FORWARDED_PORT' => 123]));
        $this->assertFalse(is_https(['HTTPS' => false, 'HTTP_X_FORWARDED_PORT' => '123']));
        $this->assertFalse(is_https(['HTTPS' => false, 'HTTP_X_FORWARDED_PORT' => ',123,456,']));
    }
}