Files
DomFramework/Tests/HttpTest.php

79 lines
1.7 KiB
PHP

<?php
/**
* DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
namespace Domframework\Tests;
use Domframework\Http;
/**
* Test the Http.php file
*/
class HttpTest extends \PHPUnit_Framework_TestCase
{
/**
* bestChoice : exact existing entry
*/
public function testBestChoice1()
{
$http = new Http();
$res = $http->bestChoice(
"text/html,application/xhtml+xml,application/xml;q=0.9,
*/*;q=0.8",
["application/xml"],
"text/html"
);
$this->assertSame($res, "application/xml");
}
/**
* bestChoice : Generic catch.
* Use default value
*/
public function testBestChoice2()
{
$http = new Http();
$res = $http->bestChoice(
"text/html,application/xhtml+xml,application/xml;q=0.9,
*/*;q=0.8",
["text/plain"],
"text/html"
);
$this->assertSame($res, "text/html");
}
/**
* bestChoice : no solution : use the default value
*/
public function testBestChoice3()
{
$http = new Http();
$res = $http->bestChoice(
"text/html,application/xhtml+xml,application/xml;q=0.9",
["text/plain"],
"text/html"
);
$this->assertSame($res, "text/html");
}
/**
* bestChoice : invalid entry (end with comma). Continue without error and
* skip the bad choices
*/
public function testBestChoice4()
{
$http = new Http();
$res = $http->bestChoice(
"text/html,application/xhtml+xml,application/xml;q=0.9,",
["text/plain"],
"text/html"
);
$this->assertSame($res, "text/html");
}
}