summaryrefslogtreecommitdiffstats
path: root/admin/survey/minify/vendor/intervention/httpauth/tests/HttpauthTest.php
blob: 88230d5bdf557a0e1500c23aef63288e1f9f2129 (plain) (blame)
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
<?php

use Intervention\Httpauth\Httpauth;

class HttpauthTest extends PHPUnit_Framework_TestCase
{
    private function createTestHttpauth()
    {
        $config = array(
            'realm' => 'test_realm',
            'username' => 'test_user',
            'password' => 'test_password'
        );

        $httpauth = new Httpauth($config);
        return $httpauth;
    }

    public function testConstruction()
    {
        $httpauth = $this->createTestHttpauth();
        $this->assertInstanceOf('\Intervention\Httpauth\Httpauth', $httpauth);
        $this->assertEquals('test_realm', $httpauth->realm);
        $this->assertTrue($httpauth->isValid('test_user', 'test_password'));
    }

    public function testStaticCall()
    {
        $config = array(
            'realm' => '1',
            'username' => '2',
            'password' => '3'
        );

        $httpauth = Httpauth::make($config);

        $this->assertInstanceOf('\Intervention\Httpauth\Httpauth', $httpauth);
        $this->assertEquals('1', $httpauth->realm);
        $this->assertTrue($httpauth->isValid($config['username'], $config['password']));
    }

    /**
     * @expectedException Exception
     */
    public function testConstructorWithoutUserPassword()
    {
        $httpauth = new Httpauth;
    }
}