- md5
- 005d82039cfa207c8c466b68e7cf7a96
- sha1
- bbdfd8ecdae35dd15c0309e217693a7a42a2aff6
- sha256
- c77c42f0d242095757487e8ca374ed7402ffe0bd2a8af114090d9e0c7cbe26b0
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
<?php
namespace Negotiation\Tests;
use Negotiation\Accept;
class AcceptTest extends TestCase
{
public function testGetParameter()
{
$accept = new Accept('foo/bar; q=1; hello=world');
$this->assertTrue($accept->hasParameter('hello'));
$this->assertEquals('world', $accept->getParameter('hello'));
$this->assertFalse($accept->hasParameter('unknown'));
$this->assertNull($accept->getParameter('unknown'));
$this->assertFalse($accept->getParameter('unknown', false));
$this->assertSame('world', $accept->getParameter('hello', 'goodbye'));
}
/**
* @dataProvider dataProviderForTestGetNormalizedValue
*/
public function testGetNormalizedValue($header, $expected)
{
$accept = new Accept($header);
$actual = $accept->getNormalizedValue();
$this->assertEquals($expected, $actual);
}
public static function dataProviderForTestGetNormalizedValue()
{
return array(
array('text/html; z=y; a=b; c=d', 'text/html; a=b; c=d; z=y'),
array('application/pdf; q=1; param=p', 'application/pdf; param=p')
);
}
/**
* @dataProvider dataProviderForGetType
*/
public function testGetType($header, $expected)
{
$accept = new Accept($header);
$actual = $accept->getType();
$this->assertEquals($expected, $actual);
}
public static function dataProviderForGetType()
{
return array(
array('text/html;hello=world', 'text/html'),
array('application/pdf', 'application/pdf'),
array('application/xhtml+xml;q=0.9', 'application/xhtml+xml'),
array('text/plain; q=0.5', 'text/plain'),
array('text/html;level=2;q=0.4', 'text/html'),
array('text/html ; level = 2 ; q = 0.4', 'text/html'),
array('text/*', 'text/*'),
array('text/* ;q=1 ;level=2', 'text/*'),
array('*/*', '*/*'),
array('*', '*/*'),
array('*/* ; param=555', '*/*'),
array('* ; param=555', '*/*'),
array('TEXT/hTmL;leVel=2; Q=0.4', 'text/html'),
);
}
/**
* @dataProvider dataProviderForGetValue
*/
public function testGetValue($header, $expected)
{
$accept = new Accept($header);
$actual = $accept->getValue();
$this->assertEquals($expected, $actual);
}
public static function dataProviderForGetValue()
{
return array(
array('text/html;hello=world ;q=0.5', 'text/html;hello=world ;q=0.5'),
array('application/pdf', 'application/pdf'),
);
}
}
The same content is in 19 releases, Joomla 4.0.0-alpha7 to 4.0.0-rc6. See them all, or every version of this file.