56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* DomFramework - Tests
|
|
* @package domframework
|
|
* @author Dominique Fournier <dominique@fournier38.fr>
|
|
* @license BSD
|
|
*/
|
|
|
|
namespace Domframework\Tests;
|
|
|
|
use Domframework\Auth;
|
|
|
|
/**
|
|
* Test the authentication
|
|
*/
|
|
class AuthTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
public function testPage1()
|
|
{
|
|
$auth = new Auth();
|
|
$res = $auth->pageHTML("http://localhost");
|
|
$this->assertSame(!! strpos($res, "<form "), true);
|
|
}
|
|
|
|
public function testMessage()
|
|
{
|
|
$auth = new Auth();
|
|
$res = $auth->pageHTML("http://localhost", "MESSAGE");
|
|
$this->assertSame(!! strpos($res, "MESSAGE"), true);
|
|
}
|
|
|
|
public function testURL1()
|
|
{
|
|
$auth = new Auth();
|
|
$res = $auth->pageHTML("http://localhost", "MESSAGE", "URL/TEST");
|
|
$this->assertSame(!! strpos($res, "URL/TEST"), true);
|
|
}
|
|
|
|
public function testAlreadyAuth1()
|
|
{
|
|
// Not Authenticated
|
|
$auth = new Auth();
|
|
$res = $auth->pageHTML("http://localhost", "MESSAGE", "URL/TEST", false);
|
|
$this->assertSame(!! strpos($res, "Please sign in"), true);
|
|
}
|
|
|
|
public function testAlreadyAuth2()
|
|
{
|
|
// Authenticated
|
|
$auth = new Auth();
|
|
$res = $auth->pageHTML("http://localhost", "", "", "AUTHENTICATED USER");
|
|
$this->assertSame(!! strpos($res, "AUTHENTICATED USER"), true);
|
|
}
|
|
}
|