Files
DomFramework/Tests/HttpTest.php

61 lines
1.5 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",
array ("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",
array ("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",
array ("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,",
array ("text/plain"), "text/html");
$this->assertSame ($res, "text/html");
}
}