* @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"); } }