This commit is contained in:
2022-11-25 21:21:30 +01:00
parent 2d6df0d5f0
commit 94deb06f52
132 changed files with 44887 additions and 41368 deletions

View File

@@ -1,4 +1,5 @@
<?php
/** DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
@@ -14,52 +15,52 @@ class RestTest extends \PHPUnit_Framework_TestCase
{
/** No param, JSON by default
*/
public function testChooseType1 ()
{
$rest = new Rest ();
$res = $rest->chooseType ();
$this->assertSame ($res, "json");
}
public function testChooseType1()
{
$rest = new Rest();
$res = $rest->chooseType();
$this->assertSame($res, "json");
}
/** If limited allowedTypes, return the first one as default
*/
public function testChooseType2 ()
{
$rest = new Rest ();
$rest->allowedtypes = array ("xml", "csv");
$res = $rest->chooseType ();
$this->assertSame ($res, "xml");
}
public function testChooseType2()
{
$rest = new Rest();
$rest->allowedtypes = array ("xml", "csv");
$res = $rest->chooseType();
$this->assertSame($res, "xml");
}
/** Choose by the user specification : exact match
*/
public function testChooseType3 ()
{
$rest = new Rest ();
$_SERVER["HTTP_ACCEPT"] = "text/html,application/xml;q=0.9,*/*;q=0.8";
$res = $rest->chooseType ();
$this->assertSame ($res, "xml");
}
public function testChooseType3()
{
$rest = new Rest();
$_SERVER["HTTP_ACCEPT"] = "text/html,application/xml;q=0.9,*/*;q=0.8";
$res = $rest->chooseType();
$this->assertSame($res, "xml");
}
/** Choose by the user specification : generic match
*/
public function testChooseType4 ()
{
$rest = new Rest ();
$_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
$res = $rest->chooseType ();
$this->assertSame ($res, "json");
}
public function testChooseType4()
{
$rest = new Rest();
$_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
$res = $rest->chooseType();
$this->assertSame($res, "json");
}
/** Choose by the user specification : generic match with limited allowed
* types
*/
public function testChooseType5 ()
{
$rest = new Rest ();
$rest->allowedtypes = array ("xml", "csv");
$_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
$res = $rest->chooseType ();
$this->assertSame ($res, "xml");
}
public function testChooseType5()
{
$rest = new Rest();
$rest->allowedtypes = array ("xml", "csv");
$_SERVER["HTTP_ACCEPT"] = "text/html;q=0.9,*/*;q=0.8";
$res = $rest->chooseType();
$this->assertSame($res, "xml");
}
}