Style, documentation, and test name updates
This commit is contained in:
parent
f98ee59e4a
commit
8462e2effc
|
|
@ -5,6 +5,19 @@ namespace WellRESTed\Message;
|
||||||
use ArrayAccess;
|
use ArrayAccess;
|
||||||
use Iterator;
|
use Iterator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HeaderCollection provides case-insenstive access to lists of header values.
|
||||||
|
*
|
||||||
|
* This class is an internal class used by Message and is not intended for
|
||||||
|
* direct use by consumers.
|
||||||
|
*
|
||||||
|
* HeaderCollection preserves the cases of keys as they are set, but treats key
|
||||||
|
* access case insesitively.
|
||||||
|
*
|
||||||
|
* Any values added to HeaderCollection are added to list arrays. Subsequent
|
||||||
|
* calls to add a value for a given key will append the new value to the list
|
||||||
|
* array of values for that key.
|
||||||
|
*/
|
||||||
class HeaderCollection implements ArrayAccess, Iterator
|
class HeaderCollection implements ArrayAccess, Iterator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,14 @@ namespace WellRESTed\Test\Message;
|
||||||
|
|
||||||
use WellRESTed\Message\HeaderCollection;
|
use WellRESTed\Message\HeaderCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @coversDefaultClass WellRESTed\Message\HeaderCollection
|
||||||
|
* @uses WellRESTed\Message\HeaderCollection
|
||||||
|
*/
|
||||||
class HeaderCollectionTest extends \PHPUnit_Framework_TestCase
|
class HeaderCollectionTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\HeaderCollection::__construct
|
* @covers ::__construct
|
||||||
*/
|
*/
|
||||||
public function testCreatesInstance()
|
public function testCreatesInstance()
|
||||||
{
|
{
|
||||||
|
|
@ -16,9 +20,8 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\HeaderCollection::offsetSet
|
* @covers ::offsetSet
|
||||||
* @covers WellRESTed\Message\HeaderCollection::offsetExists
|
* @covers ::offsetExists
|
||||||
* @uses WellRESTed\Message\HeaderCollection::__construct
|
|
||||||
*/
|
*/
|
||||||
public function testAddsSingleHeaderAndIndicatesCaseInsensitiveIsset()
|
public function testAddsSingleHeaderAndIndicatesCaseInsensitiveIsset()
|
||||||
{
|
{
|
||||||
|
|
@ -28,9 +31,8 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\HeaderCollection::offsetSet
|
* @covers ::offsetSet
|
||||||
* @covers WellRESTed\Message\HeaderCollection::offsetExists
|
* @covers ::offsetExists
|
||||||
* @uses WellRESTed\Message\HeaderCollection::__construct
|
|
||||||
*/
|
*/
|
||||||
public function testAddsMultipleHeadersAndIndicatesCaseInsensitiveIsset()
|
public function testAddsMultipleHeadersAndIndicatesCaseInsensitiveIsset()
|
||||||
{
|
{
|
||||||
|
|
@ -41,9 +43,7 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\HeaderCollection::offsetGet
|
* @covers ::offsetGet
|
||||||
* @uses WellRESTed\Message\HeaderCollection::offsetSet
|
|
||||||
* @uses WellRESTed\Message\HeaderCollection::__construct
|
|
||||||
*/
|
*/
|
||||||
public function testReturnsHeadersWithCaseInsensitiveHeaderName()
|
public function testReturnsHeadersWithCaseInsensitiveHeaderName()
|
||||||
{
|
{
|
||||||
|
|
@ -57,10 +57,7 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\HeaderCollection::offsetUnset
|
* @covers ::offsetUnset
|
||||||
* @uses WellRESTed\Message\HeaderCollection::__construct
|
|
||||||
* @uses WellRESTed\Message\HeaderCollection::offsetSet
|
|
||||||
* @uses WellRESTed\Message\HeaderCollection::offsetExists
|
|
||||||
*/
|
*/
|
||||||
public function testRemovesHeadersWithCaseInsensitiveHeaderName()
|
public function testRemovesHeadersWithCaseInsensitiveHeaderName()
|
||||||
{
|
{
|
||||||
|
|
@ -72,10 +69,7 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses WellRESTed\Message\HeaderCollection::__construct
|
* @coversNothing
|
||||||
* @uses WellRESTed\Message\HeaderCollection::offsetSet
|
|
||||||
* @uses WellRESTed\Message\HeaderCollection::offsetExists
|
|
||||||
* @uses WellRESTed\Message\HeaderCollection::offsetUnset
|
|
||||||
*/
|
*/
|
||||||
public function testCloneMakesDeepCopyOfHeaders()
|
public function testCloneMakesDeepCopyOfHeaders()
|
||||||
{
|
{
|
||||||
|
|
@ -90,15 +84,11 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\HeaderCollection::current
|
* @covers ::current
|
||||||
* @covers WellRESTed\Message\HeaderCollection::next
|
* @covers ::next
|
||||||
* @covers WellRESTed\Message\HeaderCollection::key
|
* @covers ::key
|
||||||
* @covers WellRESTed\Message\HeaderCollection::valid
|
* @covers ::valid
|
||||||
* @covers WellRESTed\Message\HeaderCollection::rewind
|
* @covers ::rewind
|
||||||
* @uses WellRESTed\Message\HeaderCollection::__construct
|
|
||||||
* @uses WellRESTed\Message\HeaderCollection::offsetSet
|
|
||||||
* @uses WellRESTed\Message\HeaderCollection::offsetExists
|
|
||||||
* @uses WellRESTed\Message\HeaderCollection::offsetUnset
|
|
||||||
*/
|
*/
|
||||||
public function testIteratesWithOriginalKeys()
|
public function testIteratesWithOriginalKeys()
|
||||||
{
|
{
|
||||||
|
|
@ -121,15 +111,11 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\HeaderCollection::current
|
* @covers ::current
|
||||||
* @covers WellRESTed\Message\HeaderCollection::next
|
* @covers ::next
|
||||||
* @covers WellRESTed\Message\HeaderCollection::key
|
* @covers ::key
|
||||||
* @covers WellRESTed\Message\HeaderCollection::valid
|
* @covers ::valid
|
||||||
* @covers WellRESTed\Message\HeaderCollection::rewind
|
* @covers ::rewind
|
||||||
* @uses WellRESTed\Message\HeaderCollection::__construct
|
|
||||||
* @uses WellRESTed\Message\HeaderCollection::offsetSet
|
|
||||||
* @uses WellRESTed\Message\HeaderCollection::offsetExists
|
|
||||||
* @uses WellRESTed\Message\HeaderCollection::offsetUnset
|
|
||||||
*/
|
*/
|
||||||
public function testIteratesWithOriginalKeysAndValues()
|
public function testIteratesWithOriginalKeysAndValues()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@
|
||||||
namespace WellRESTed\Test\Unit\Message;
|
namespace WellRESTed\Test\Unit\Message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @coversDefaultClass WellRESTed\Message\Message
|
||||||
* @uses WellRESTed\Message\Message
|
* @uses WellRESTed\Message\Message
|
||||||
* @uses WellRESTed\Message\HeaderCollection
|
* @uses WellRESTed\Message\HeaderCollection
|
||||||
*/
|
*/
|
||||||
class MessageTest extends \PHPUnit_Framework_TestCase
|
class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::__construct
|
* @covers ::__construct
|
||||||
*/
|
*/
|
||||||
public function testCreatesInstance()
|
public function testCreatesInstance()
|
||||||
{
|
{
|
||||||
|
|
@ -18,7 +19,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::__construct
|
* @covers ::__construct
|
||||||
*/
|
*/
|
||||||
public function testSetsHeadersOnConstruction()
|
public function testSetsHeadersOnConstruction()
|
||||||
{
|
{
|
||||||
|
|
@ -29,7 +30,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::__construct
|
* @covers ::__construct
|
||||||
*/
|
*/
|
||||||
public function testSetsBodyOnConstruction()
|
public function testSetsBodyOnConstruction()
|
||||||
{
|
{
|
||||||
|
|
@ -40,7 +41,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::__clone
|
* @covers ::__clone
|
||||||
*/
|
*/
|
||||||
public function testCloneMakesDeepCopyOfHeaders()
|
public function testCloneMakesDeepCopyOfHeaders()
|
||||||
{
|
{
|
||||||
|
|
@ -55,18 +56,18 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
// Protocol Version
|
// Protocol Version
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::getProtocolVersion
|
* @covers ::getProtocolVersion
|
||||||
*/
|
*/
|
||||||
public function testReturnsProtocolVersion1Point1ByDefault()
|
public function testGetProtocolVersionReturnsProtocolVersion1Point1ByDefault()
|
||||||
{
|
{
|
||||||
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
||||||
$this->assertEquals("1.1", $message->getProtocolVersion());
|
$this->assertEquals("1.1", $message->getProtocolVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::getProtocolVersion
|
* @covers ::getProtocolVersion
|
||||||
*/
|
*/
|
||||||
public function testReturnsProtocolVersion()
|
public function testGetProtocolVersionReturnsProtocolVersion()
|
||||||
{
|
{
|
||||||
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
||||||
$message = $message->withProtocolVersion("1.0");
|
$message = $message->withProtocolVersion("1.0");
|
||||||
|
|
@ -74,9 +75,9 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::withProtocolVersion
|
* @covers ::withProtocolVersion
|
||||||
*/
|
*/
|
||||||
public function testReplacesProtocolVersion()
|
public function testGetProtocolVersionReplacesProtocolVersion()
|
||||||
{
|
{
|
||||||
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
||||||
$message = $message->withProtocolVersion("1.0");
|
$message = $message->withProtocolVersion("1.0");
|
||||||
|
|
@ -87,8 +88,8 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
// Headers
|
// Headers
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::withHeader
|
* @covers ::withHeader
|
||||||
* @covers WellRESTed\Message\Message::getValidatedHeaders
|
* @covers ::getValidatedHeaders
|
||||||
* @dataProvider validHeaderValueProvider
|
* @dataProvider validHeaderValueProvider
|
||||||
*/
|
*/
|
||||||
public function testWithHeaderReplacesHeader($expected, $value)
|
public function testWithHeaderReplacesHeader($expected, $value)
|
||||||
|
|
@ -108,12 +109,12 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::withHeader
|
* @covers ::withHeader
|
||||||
* @covers WellRESTed\Message\Message::getValidatedHeaders
|
* @covers ::getValidatedHeaders
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
* @dataProvider invalidHeaderProvider
|
* @dataProvider invalidHeaderProvider
|
||||||
*/
|
*/
|
||||||
public function testWithHeaderThrowExceptionWithInvalidArgument($name, $value)
|
public function testWithHeaderThrowsExceptionWithInvalidArgument($name, $value)
|
||||||
{
|
{
|
||||||
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
||||||
$message->withHeader($name, $value);
|
$message->withHeader($name, $value);
|
||||||
|
|
@ -124,12 +125,12 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
return [
|
return [
|
||||||
[0, 1024],
|
[0, 1024],
|
||||||
["Content-length", false],
|
["Content-length", false],
|
||||||
["Content-length", [false]],
|
["Content-length", [false]]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::withAddedHeader
|
* @covers ::withAddedHeader
|
||||||
*/
|
*/
|
||||||
public function testWithAddedHeaderSetsHeader()
|
public function testWithAddedHeaderSetsHeader()
|
||||||
{
|
{
|
||||||
|
|
@ -139,7 +140,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::withAddedHeader
|
* @covers ::withAddedHeader
|
||||||
*/
|
*/
|
||||||
public function testWithAddedHeaderAppendsValue()
|
public function testWithAddedHeaderAppendsValue()
|
||||||
{
|
{
|
||||||
|
|
@ -152,7 +153,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::withoutHeader
|
* @covers ::withoutHeader
|
||||||
*/
|
*/
|
||||||
public function testWithoutHeaderRemovesHeader()
|
public function testWithoutHeaderRemovesHeader()
|
||||||
{
|
{
|
||||||
|
|
@ -163,7 +164,16 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::getHeader
|
* @covers ::getHeader
|
||||||
|
*/
|
||||||
|
public function testGetHeaderReturnsEmptyArrayForUnsetHeader()
|
||||||
|
{
|
||||||
|
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
||||||
|
$this->assertEquals([], $message->getHeader("X-name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::getHeader
|
||||||
*/
|
*/
|
||||||
public function testGetHeaderReturnsSingleHeader()
|
public function testGetHeaderReturnsSingleHeader()
|
||||||
{
|
{
|
||||||
|
|
@ -173,27 +183,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::getHeaderLine
|
* @covers ::getHeader
|
||||||
*/
|
|
||||||
public function testGetHeaderReturnsMultipleHeadersJoinedByCommas()
|
|
||||||
{
|
|
||||||
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
|
||||||
$message = $message->withAddedHeader("X-name", "cat=Molly");
|
|
||||||
$message = $message->withAddedHeader("X-name", "dog=Bear");
|
|
||||||
$this->assertEquals("cat=Molly, dog=Bear", $message->getHeaderLine("X-name"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers WellRESTed\Message\Message::getHeaderLine
|
|
||||||
*/
|
|
||||||
public function testGetHeaderLineReturnsEmptyStringForUnsetHeader()
|
|
||||||
{
|
|
||||||
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
|
||||||
$this->assertSame("", $message->getHeaderLine("X-not-set"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers WellRESTed\Message\Message::getHeader
|
|
||||||
*/
|
*/
|
||||||
public function testGetHeaderReturnsMultipleValuesForHeader()
|
public function testGetHeaderReturnsMultipleValuesForHeader()
|
||||||
{
|
{
|
||||||
|
|
@ -204,16 +194,27 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::getHeader
|
* @covers ::getHeaderLine
|
||||||
*/
|
*/
|
||||||
public function testGetHeaderReturnsEmptyArrayForUnsetHeader()
|
public function testGetHeaderLineReturnsEmptyStringForUnsetHeader()
|
||||||
{
|
{
|
||||||
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
||||||
$this->assertEquals([], $message->getHeader("X-name"));
|
$this->assertSame("", $message->getHeaderLine("X-not-set"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::hasHeader
|
* @covers ::getHeaderLine
|
||||||
|
*/
|
||||||
|
public function testGetHeaderLineReturnsMultipleHeadersJoinedByCommas()
|
||||||
|
{
|
||||||
|
$message = $this->getMockForAbstractClass('\WellRESTed\Message\Message');
|
||||||
|
$message = $message->withAddedHeader("X-name", "cat=Molly");
|
||||||
|
$message = $message->withAddedHeader("X-name", "dog=Bear");
|
||||||
|
$this->assertEquals("cat=Molly, dog=Bear", $message->getHeaderLine("X-name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::hasHeader
|
||||||
*/
|
*/
|
||||||
public function testHasHeaderReturnsTrueWhenHeaderIsSet()
|
public function testHasHeaderReturnsTrueWhenHeaderIsSet()
|
||||||
{
|
{
|
||||||
|
|
@ -223,7 +224,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::hasHeader
|
* @covers ::hasHeader
|
||||||
*/
|
*/
|
||||||
public function testHasHeaderReturnsFalseWhenHeaderIsNotSet()
|
public function testHasHeaderReturnsFalseWhenHeaderIsNotSet()
|
||||||
{
|
{
|
||||||
|
|
@ -232,7 +233,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::getHeaders
|
* @covers ::getHeaders
|
||||||
*/
|
*/
|
||||||
public function testGetHeadersReturnOriginalHeaderNamesAsKeys()
|
public function testGetHeadersReturnOriginalHeaderNamesAsKeys()
|
||||||
{
|
{
|
||||||
|
|
@ -252,7 +253,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::getHeaders
|
* @covers ::getHeaders
|
||||||
*/
|
*/
|
||||||
public function testGetHeadersReturnOriginalHeaderNamesAndValues()
|
public function testGetHeadersReturnOriginalHeaderNamesAndValues()
|
||||||
{
|
{
|
||||||
|
|
@ -285,7 +286,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
// Body
|
// Body
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::getBody
|
* @covers ::getBody
|
||||||
* @uses WellRESTed\Message\NullStream
|
* @uses WellRESTed\Message\NullStream
|
||||||
*/
|
*/
|
||||||
public function testGetBodyReturnsEmptyStreamByDefault()
|
public function testGetBodyReturnsEmptyStreamByDefault()
|
||||||
|
|
@ -295,8 +296,8 @@ class MessageTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Message::getBody
|
* @covers ::getBody
|
||||||
* @covers WellRESTed\Message\Message::withBody
|
* @covers ::withBody
|
||||||
*/
|
*/
|
||||||
public function testGetBodyReturnsAttachedStream()
|
public function testGetBodyReturnsAttachedStream()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,14 @@ namespace WellRESTed\Test\Message;
|
||||||
|
|
||||||
use WellRESTed\Message\NullStream;
|
use WellRESTed\Message\NullStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @coversDefaultClass WellRESTed\Message\NullStream
|
||||||
|
* @uses WellRESTed\Message\NullStream
|
||||||
|
*/
|
||||||
class NullStreamTest extends \PHPUnit_Framework_TestCase
|
class NullStreamTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::__toString()
|
* @covers ::__toString()
|
||||||
*/
|
*/
|
||||||
public function testCastsToString()
|
public function testCastsToString()
|
||||||
{
|
{
|
||||||
|
|
@ -18,12 +22,12 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testCloseDoesNothing()
|
public function testCloseDoesNothing()
|
||||||
{
|
{
|
||||||
$stream = new \WellRESTed\Message\NullStream();
|
$stream = new \WellRESTed\Message\NullStream();
|
||||||
$this->assertNull($stream->close());
|
$stream->close();
|
||||||
|
$this->assertTrue(true); // Asserting no exception occured.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::detach()
|
* @covers ::detach()
|
||||||
* @uses WellRESTed\Message\Stream
|
|
||||||
*/
|
*/
|
||||||
public function testDetachReturnsNull()
|
public function testDetachReturnsNull()
|
||||||
{
|
{
|
||||||
|
|
@ -32,8 +36,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::getSize
|
* @covers ::getSize
|
||||||
* @uses WellRESTed\Message\Stream
|
|
||||||
*/
|
*/
|
||||||
public function testSizeReturnsZero()
|
public function testSizeReturnsZero()
|
||||||
{
|
{
|
||||||
|
|
@ -42,7 +45,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::tell
|
* @covers ::tell
|
||||||
*/
|
*/
|
||||||
public function testTellReturnsZero()
|
public function testTellReturnsZero()
|
||||||
{
|
{
|
||||||
|
|
@ -51,17 +54,16 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::eof
|
* @covers ::eof
|
||||||
*/
|
*/
|
||||||
public function testEofReturnsReturnsTrue()
|
public function testEofReturnsTrue()
|
||||||
{
|
{
|
||||||
$stream = new \WellRESTed\Message\NullStream();
|
$stream = new \WellRESTed\Message\NullStream();
|
||||||
$this->assertTrue($stream->eof());
|
$this->assertTrue($stream->eof());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::isSeekable
|
* @covers ::isSeekable
|
||||||
* @uses WellRESTed\Message\Stream
|
|
||||||
*/
|
*/
|
||||||
public function testIsSeekableReturnsFalse()
|
public function testIsSeekableReturnsFalse()
|
||||||
{
|
{
|
||||||
|
|
@ -70,7 +72,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::seek
|
* @covers ::seek
|
||||||
* @expectedException \RuntimeException
|
* @expectedException \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testSeekReturnsFalse()
|
public function testSeekReturnsFalse()
|
||||||
|
|
@ -80,17 +82,17 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::rewind
|
* @covers ::rewind
|
||||||
* @expectedException \RuntimeException
|
* @expectedException \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testRewindReturnsFalse()
|
public function testRewindThrowsException()
|
||||||
{
|
{
|
||||||
$stream = new \WellRESTed\Message\NullStream();
|
$stream = new \WellRESTed\Message\NullStream();
|
||||||
$stream->rewind();
|
$stream->rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::isWritable
|
* @covers ::isWritable
|
||||||
*/
|
*/
|
||||||
public function testIsWritableReturnsFalse()
|
public function testIsWritableReturnsFalse()
|
||||||
{
|
{
|
||||||
|
|
@ -99,7 +101,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::write
|
* @covers ::write
|
||||||
* @expectedException \RuntimeException
|
* @expectedException \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testWriteThrowsException()
|
public function testWriteThrowsException()
|
||||||
|
|
@ -109,16 +111,16 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::isReadable
|
* @covers ::isReadable
|
||||||
*/
|
*/
|
||||||
public function testIsReableReturnsTrue()
|
public function testIsReadableReturnsTrue()
|
||||||
{
|
{
|
||||||
$stream = new \WellRESTed\Message\NullStream();
|
$stream = new \WellRESTed\Message\NullStream();
|
||||||
$this->assertTrue($stream->isReadable());
|
$this->assertTrue($stream->isReadable());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::read
|
* @covers ::read
|
||||||
*/
|
*/
|
||||||
public function testReadReturnsEmptyString()
|
public function testReadReturnsEmptyString()
|
||||||
{
|
{
|
||||||
|
|
@ -127,7 +129,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::getContents
|
* @covers ::getContents
|
||||||
*/
|
*/
|
||||||
public function testGetContentsReturnsEmptyString()
|
public function testGetContentsReturnsEmptyString()
|
||||||
{
|
{
|
||||||
|
|
@ -136,7 +138,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::getMetadata
|
* @covers ::getMetadata
|
||||||
*/
|
*/
|
||||||
public function testGetMetadataReturnsNull()
|
public function testGetMetadataReturnsNull()
|
||||||
{
|
{
|
||||||
|
|
@ -145,7 +147,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\NullStream::getMetadata
|
* @covers ::getMetadata
|
||||||
*/
|
*/
|
||||||
public function testGetMetadataReturnsNullWithKey()
|
public function testGetMetadataReturnsNullWithKey()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use WellRESTed\Message\Request;
|
||||||
use WellRESTed\Message\Uri;
|
use WellRESTed\Message\Uri;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @coversDefaultClass WellRESTed\Message\Request
|
||||||
* @uses WellRESTed\Message\Request
|
* @uses WellRESTed\Message\Request
|
||||||
* @uses WellRESTed\Message\Request
|
* @uses WellRESTed\Message\Request
|
||||||
* @uses WellRESTed\Message\Message
|
* @uses WellRESTed\Message\Message
|
||||||
|
|
@ -18,7 +19,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
// Construction
|
// Construction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::__construct
|
* @covers ::__construct
|
||||||
*/
|
*/
|
||||||
public function testCreatesInstance()
|
public function testCreatesInstance()
|
||||||
{
|
{
|
||||||
|
|
@ -27,7 +28,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::__construct
|
* @covers ::__construct
|
||||||
*/
|
*/
|
||||||
public function testCreatesInstanceWithUri()
|
public function testCreatesInstanceWithUri()
|
||||||
{
|
{
|
||||||
|
|
@ -38,7 +39,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::__construct
|
* @covers ::__construct
|
||||||
*/
|
*/
|
||||||
public function testCreatesInstanceWithMethod()
|
public function testCreatesInstanceWithMethod()
|
||||||
{
|
{
|
||||||
|
|
@ -48,7 +49,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::__construct
|
* @covers ::__construct
|
||||||
*/
|
*/
|
||||||
public function testSetsHeadersOnConstruction()
|
public function testSetsHeadersOnConstruction()
|
||||||
{
|
{
|
||||||
|
|
@ -59,7 +60,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::__construct
|
* @covers ::__construct
|
||||||
*/
|
*/
|
||||||
public function testSetsBodyOnConstruction()
|
public function testSetsBodyOnConstruction()
|
||||||
{
|
{
|
||||||
|
|
@ -72,9 +73,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
// Request Target
|
// Request Target
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::getRequestTarget
|
* @covers ::getRequestTarget
|
||||||
*/
|
*/
|
||||||
public function testGetRequestTargetPrefersConreteRequestTarget()
|
public function testGetRequestTargetPrefersExplicitRequestTarget()
|
||||||
{
|
{
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$request = $request->withRequestTarget("*");
|
$request = $request->withRequestTarget("*");
|
||||||
|
|
@ -82,7 +83,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::getRequestTarget
|
* @covers ::getRequestTarget
|
||||||
*/
|
*/
|
||||||
public function testGetRequestTargetUsesOriginFormOfUri()
|
public function testGetRequestTargetUsesOriginFormOfUri()
|
||||||
{
|
{
|
||||||
|
|
@ -97,7 +98,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::getRequestTarget
|
* @covers ::getRequestTarget
|
||||||
*/
|
*/
|
||||||
public function testGetRequestTargetReturnsSlashByDefault()
|
public function testGetRequestTargetReturnsSlashByDefault()
|
||||||
{
|
{
|
||||||
|
|
@ -106,8 +107,8 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::withRequestTarget
|
* @covers ::withRequestTarget
|
||||||
* @covers WellRESTed\Message\Request::getRequestTarget
|
* @covers ::getRequestTarget
|
||||||
*/
|
*/
|
||||||
public function testWithRequestTargetCreatesNewInstance()
|
public function testWithRequestTargetCreatesNewInstance()
|
||||||
{
|
{
|
||||||
|
|
@ -120,7 +121,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
// Method
|
// Method
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::getMethod
|
* @covers ::getMethod
|
||||||
*/
|
*/
|
||||||
public function testGetMethodReturnsGetByDefault()
|
public function testGetMethodReturnsGetByDefault()
|
||||||
{
|
{
|
||||||
|
|
@ -129,9 +130,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::withMethod
|
* @covers ::withMethod
|
||||||
* @covers WellRESTed\Message\Request::getValidatedMethod
|
* @covers ::getValidatedMethod
|
||||||
* @covers WellRESTed\Message\Request::getMethod
|
* @covers ::getMethod
|
||||||
*/
|
*/
|
||||||
public function testWithMethodCreatesNewInstance()
|
public function testWithMethodCreatesNewInstance()
|
||||||
{
|
{
|
||||||
|
|
@ -141,12 +142,12 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::withMethod
|
* @covers ::withMethod
|
||||||
* @covers WellRESTed\Message\Request::getValidatedMethod
|
* @covers ::getValidatedMethod
|
||||||
* @dataProvider invalidMethodProvider
|
* @dataProvider invalidMethodProvider
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testWithMethoThrowsExceptionOnInvalidMethod($method)
|
public function testWithMethodThrowsExceptionOnInvalidMethod($method)
|
||||||
{
|
{
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$request->withMethod($method);
|
$request->withMethod($method);
|
||||||
|
|
@ -165,8 +166,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
// Request URI
|
// Request URI
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::getUri
|
* @covers ::getUri
|
||||||
* @
|
|
||||||
*/
|
*/
|
||||||
public function testGetUriReturnsEmptyUriByDefault()
|
public function testGetUriReturnsEmptyUriByDefault()
|
||||||
{
|
{
|
||||||
|
|
@ -176,8 +176,8 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::withUri
|
* @covers ::withUri
|
||||||
* @covers WellRESTed\Message\Request::getUri
|
* @covers ::getUri
|
||||||
*/
|
*/
|
||||||
public function testWithUriCreatesNewInstance()
|
public function testWithUriCreatesNewInstance()
|
||||||
{
|
{
|
||||||
|
|
@ -190,7 +190,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::__clone
|
* @covers ::__clone
|
||||||
*/
|
*/
|
||||||
public function testWithUriPreservesOriginalRequest()
|
public function testWithUriPreservesOriginalRequest()
|
||||||
{
|
{
|
||||||
|
|
@ -215,7 +215,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::withUri
|
* @covers ::withUri
|
||||||
*/
|
*/
|
||||||
public function testWithUriUpdatesHostHeader()
|
public function testWithUriUpdatesHostHeader()
|
||||||
{
|
{
|
||||||
|
|
@ -230,7 +230,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::withUri
|
* @covers ::withUri
|
||||||
*/
|
*/
|
||||||
public function testWithUriDoesNotUpdatesHostHeaderWhenUriHasNoHost()
|
public function testWithUriDoesNotUpdatesHostHeaderWhenUriHasNoHost()
|
||||||
{
|
{
|
||||||
|
|
@ -245,7 +245,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::withUri
|
* @covers ::withUri
|
||||||
*/
|
*/
|
||||||
public function testPreserveHostUpdatesHostHeaderWhenHeaderIsOriginallyMissing()
|
public function testPreserveHostUpdatesHostHeaderWhenHeaderIsOriginallyMissing()
|
||||||
{
|
{
|
||||||
|
|
@ -259,7 +259,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::withUri
|
* @covers ::withUri
|
||||||
*/
|
*/
|
||||||
public function testPreserveHostDoesNotUpdatesWhenBothAreMissingHosts()
|
public function testPreserveHostDoesNotUpdatesWhenBothAreMissingHosts()
|
||||||
{
|
{
|
||||||
|
|
@ -272,7 +272,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Request::withUri
|
* @covers ::withUri
|
||||||
*/
|
*/
|
||||||
public function testPreserveHostDoesNotUpdateHostHeader()
|
public function testPreserveHostDoesNotUpdateHostHeader()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,53 @@ namespace WellRESTed\Test\Unit\Message;
|
||||||
use WellRESTed\Message\Response;
|
use WellRESTed\Message\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @coversDefaultClass WellRESTed\Message\Response
|
||||||
* @uses WellRESTed\Message\Response
|
* @uses WellRESTed\Message\Response
|
||||||
* @uses WellRESTed\Message\Message
|
* @uses WellRESTed\Message\Message
|
||||||
* @uses WellRESTed\Message\HeaderCollection
|
* @uses WellRESTed\Message\HeaderCollection
|
||||||
*/
|
*/
|
||||||
class ResponseTest extends \PHPUnit_Framework_TestCase
|
class ResponseTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Construction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Response::withStatus
|
* @covers ::__construct
|
||||||
* @covers WellRESTed\Message\Response::getStatusCode
|
*/
|
||||||
* @covers WellRESTed\Message\Response::getDefaultReasonPhraseForStatusCode
|
public function testSetsStatusCodeOnConstruction()
|
||||||
|
{
|
||||||
|
$response = new Response(200);
|
||||||
|
$this->assertSame(200, $response->getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::__construct
|
||||||
|
*/
|
||||||
|
public function testSetsHeadersOnConstruction()
|
||||||
|
{
|
||||||
|
$response = new Response(200, [
|
||||||
|
"X-foo" => ["bar","baz"]
|
||||||
|
]);
|
||||||
|
$this->assertEquals(["bar","baz"], $response->getHeader("X-foo"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::__construct
|
||||||
|
*/
|
||||||
|
public function testSetsBodyOnConstruction()
|
||||||
|
{
|
||||||
|
$body = $this->prophesize('\Psr\Http\Message\StreamInterface');
|
||||||
|
$response = new Response(200, [], $body->reveal());
|
||||||
|
$this->assertSame($body->reveal(), $response->getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Status and Reason Phrase
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::withStatus
|
||||||
|
* @covers ::getStatusCode
|
||||||
|
* @covers ::getDefaultReasonPhraseForStatusCode
|
||||||
*/
|
*/
|
||||||
public function testCreatesNewInstanceWithStatusCode()
|
public function testCreatesNewInstanceWithStatusCode()
|
||||||
{
|
{
|
||||||
|
|
@ -24,9 +61,9 @@ class ResponseTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Response::withStatus
|
* @covers ::withStatus
|
||||||
* @covers WellRESTed\Message\Response::getReasonPhrase
|
* @covers ::getReasonPhrase
|
||||||
* @covers WellRESTed\Message\Response::getDefaultReasonPhraseForStatusCode
|
* @covers ::getDefaultReasonPhraseForStatusCode
|
||||||
* @dataProvider statusProvider
|
* @dataProvider statusProvider
|
||||||
*/
|
*/
|
||||||
public function testCreatesNewInstanceWithReasonPhrase($code, $reasonPhrase, $expected)
|
public function testCreatesNewInstanceWithReasonPhrase($code, $reasonPhrase, $expected)
|
||||||
|
|
@ -82,8 +119,8 @@ class ResponseTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Response::withStatus
|
* @covers ::withStatus
|
||||||
* @covers WellRESTed\Message\Response::getStatusCode
|
* @covers ::getStatusCode
|
||||||
*/
|
*/
|
||||||
public function testWithStatusCodePreservesOriginalResponse()
|
public function testWithStatusCodePreservesOriginalResponse()
|
||||||
{
|
{
|
||||||
|
|
@ -100,37 +137,4 @@ class ResponseTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals(404, $response2->getStatusCode());
|
$this->assertEquals(404, $response2->getStatusCode());
|
||||||
$this->assertEquals(["text/plain"], $response2->getHeader("Content-type"));
|
$this->assertEquals(["text/plain"], $response2->getHeader("Content-type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Construction
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers WellRESTed\Message\Response::__construct
|
|
||||||
*/
|
|
||||||
public function testSetsStatusCodeOnConstruction()
|
|
||||||
{
|
|
||||||
$response = new Response(200);
|
|
||||||
$this->assertSame(200, $response->getStatusCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers WellRESTed\Message\Response::__construct
|
|
||||||
*/
|
|
||||||
public function testSetsHeadersOnConstruction()
|
|
||||||
{
|
|
||||||
$response = new Response(200, [
|
|
||||||
"X-foo" => ["bar","baz"]
|
|
||||||
]);
|
|
||||||
$this->assertEquals(["bar","baz"], $response->getHeader("X-foo"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers WellRESTed\Message\Response::__construct
|
|
||||||
*/
|
|
||||||
public function testSetsBodyOnConstruction()
|
|
||||||
{
|
|
||||||
$body = $this->prophesize('\Psr\Http\Message\StreamInterface');
|
|
||||||
$response = new Response(200, [], $body->reveal());
|
|
||||||
$this->assertSame($body->reveal(), $response->getBody());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ use WellRESTed\Message\ServerRequest;
|
||||||
use WellRESTed\Message\UploadedFile;
|
use WellRESTed\Message\UploadedFile;
|
||||||
use WellRESTed\Message\Uri;
|
use WellRESTed\Message\Uri;
|
||||||
|
|
||||||
// TODO Test nested $_FILES with associative array for last level
|
|
||||||
// TODO Remove concrete class used for testing
|
// TODO Remove concrete class used for testing
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,14 +61,14 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Request
|
// Marshalling Request Information
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::readFromServerRequest
|
* @covers ::readFromServerRequest
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider protocolVersionProvider
|
* @dataProvider protocolVersionProvider
|
||||||
*/
|
*/
|
||||||
public function testReadsProtocolVersionFromFromRequest($expectedProtocol, $serverProtocol)
|
public function testGetServerRequestReadsProtocolVersion($expectedProtocol, $serverProtocol)
|
||||||
{
|
{
|
||||||
$_SERVER = [
|
$_SERVER = [
|
||||||
"HTTP_HOST" => "localhost",
|
"HTTP_HOST" => "localhost",
|
||||||
|
|
@ -95,7 +94,7 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider methodProvider
|
* @dataProvider methodProvider
|
||||||
*/
|
*/
|
||||||
public function testReadsMethodFromFromRequest($exectedMethod, $serverMethod)
|
public function testGetServerRequestReadsMethod($exectedMethod, $serverMethod)
|
||||||
{
|
{
|
||||||
$_SERVER = [
|
$_SERVER = [
|
||||||
"HTTP_HOST" => "localhost",
|
"HTTP_HOST" => "localhost",
|
||||||
|
|
@ -122,7 +121,7 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider requestTargetProvider
|
* @dataProvider requestTargetProvider
|
||||||
*/
|
*/
|
||||||
public function testReadsRequestTargetFromServer($exectedRequestTarget, $serverRequestUri)
|
public function testGetServerRequestReadsRequestTargetFromRequest($exectedRequestTarget, $serverRequestUri)
|
||||||
{
|
{
|
||||||
$_SERVER = [
|
$_SERVER = [
|
||||||
"HTTP_HOST" => "localhost",
|
"HTTP_HOST" => "localhost",
|
||||||
|
|
@ -146,7 +145,7 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
* @covers ::getHeader
|
* @covers ::getHeader
|
||||||
* @depends testGetServerRequestReadsFromRequest
|
* @depends testGetServerRequestReadsFromRequest
|
||||||
*/
|
*/
|
||||||
public function testServerRequestProvidesHeaders($request)
|
public function testGetServerRequestReadsHeaders($request)
|
||||||
{
|
{
|
||||||
/** @var ServerRequest $request */
|
/** @var ServerRequest $request */
|
||||||
$this->assertEquals(["application/json"], $request->getHeader("Accept"));
|
$this->assertEquals(["application/json"], $request->getHeader("Accept"));
|
||||||
|
|
@ -155,7 +154,7 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
/**
|
/**
|
||||||
* @covers ::getBody
|
* @covers ::getBody
|
||||||
*/
|
*/
|
||||||
public function testServerRequestProvidesBody()
|
public function testGetServerRequestReadsBody()
|
||||||
{
|
{
|
||||||
$body = $this->prophesize('Psr\Http\Message\StreamInterface');
|
$body = $this->prophesize('Psr\Http\Message\StreamInterface');
|
||||||
MockServerRequest::$bodyStream = $body->reveal();
|
MockServerRequest::$bodyStream = $body->reveal();
|
||||||
|
|
@ -163,128 +162,87 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertSame($body->reveal(), $request->getBody());
|
$this->assertSame($body->reveal(), $request->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Server Params
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::getServerParams
|
* @covers ::getServerRequest
|
||||||
|
* @covers ::getServerRequestHeaders
|
||||||
|
* @covers ::readFromServerRequest
|
||||||
|
* @covers ::readUri
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider uriProvider
|
||||||
*/
|
*/
|
||||||
public function testServerParamsIsEmptyByDefault()
|
public function testGetServerRequestReadsUri($expected, $server)
|
||||||
{
|
{
|
||||||
$request = new ServerRequest();
|
$_SERVER = $server;
|
||||||
$this->assertEquals([], $request->getServerParams());
|
$request = ServerRequest::getServerRequest();
|
||||||
|
$this->assertEquals($expected, $request->getUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function uriProvider()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
new Uri("http://localhost/path"),
|
||||||
|
[
|
||||||
|
"HTTPS" => "off",
|
||||||
|
"HTTP_HOST" => "localhost",
|
||||||
|
"REQUEST_URI" => "/path",
|
||||||
|
"QUERY_STRING" => ""
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
new Uri("https://foo.com/path/to/stuff?cat=molly"),
|
||||||
|
[
|
||||||
|
"HTTPS" => "1",
|
||||||
|
"HTTP_HOST" => "foo.com",
|
||||||
|
"REQUEST_URI" => "/path/to/stuff?cat=molly",
|
||||||
|
"QUERY_STRING" => "cat=molly"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
new Uri("http://foo.com:8080/path/to/stuff?cat=molly"),
|
||||||
|
[
|
||||||
|
"HTTP" => "1",
|
||||||
|
"HTTP_HOST" => "foo.com:8080",
|
||||||
|
"REQUEST_URI" => "/path/to/stuff?cat=molly",
|
||||||
|
"QUERY_STRING" => "cat=molly"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Marshalling ServerRequest Information
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::getServerParams
|
* @covers ::getServerParams
|
||||||
* @depends testGetServerRequestReadsFromRequest
|
* @depends testGetServerRequestReadsFromRequest
|
||||||
*/
|
*/
|
||||||
public function testServerRequestProvidesServerParams($request)
|
public function testGetServerRequestReadsServerParams($request)
|
||||||
{
|
{
|
||||||
/** @var ServerRequest $request */
|
/** @var ServerRequest $request */
|
||||||
$this->assertEquals("localhost", $request->getServerParams()["HTTP_HOST"]);
|
$this->assertEquals("localhost", $request->getServerParams()["HTTP_HOST"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Cookies
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::getCookieParams
|
|
||||||
*/
|
|
||||||
public function testCookieParamsIsEmptyByDefault()
|
|
||||||
{
|
|
||||||
$request = new ServerRequest();
|
|
||||||
$this->assertEquals([], $request->getCookieParams());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::getCookieParams
|
* @covers ::getCookieParams
|
||||||
* @depends testGetServerRequestReadsFromRequest
|
* @depends testGetServerRequestReadsFromRequest
|
||||||
*/
|
*/
|
||||||
public function testServerRequestProvidesCookieParams($request)
|
public function testGetServerRequestReadsCookieParams($request)
|
||||||
{
|
{
|
||||||
/** @var ServerRequest $request */
|
/** @var ServerRequest $request */
|
||||||
$this->assertEquals("Molly", $request->getCookieParams()["cat"]);
|
$this->assertEquals("Molly", $request->getCookieParams()["cat"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::withCookieParams
|
|
||||||
* @depends testGetServerRequestReadsFromRequest
|
|
||||||
*/
|
|
||||||
public function testWithCookieParamsCreatesNewInstance($request1)
|
|
||||||
{
|
|
||||||
/** @var ServerRequest $request1 */
|
|
||||||
$request2 = $request1->withCookieParams([
|
|
||||||
"cat" => "Oscar"
|
|
||||||
]);
|
|
||||||
$this->assertEquals("Molly", $request1->getCookieParams()["cat"]);
|
|
||||||
$this->assertEquals("Oscar", $request2->getCookieParams()["cat"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Query
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::getQueryParams
|
|
||||||
*/
|
|
||||||
public function testQueryParamsIsEmptyByDefault()
|
|
||||||
{
|
|
||||||
$request = new ServerRequest();
|
|
||||||
$this->assertEquals([], $request->getQueryParams());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::getQueryParams
|
* @covers ::getQueryParams
|
||||||
* @depends testGetServerRequestReadsFromRequest
|
* @depends testGetServerRequestReadsFromRequest
|
||||||
*/
|
*/
|
||||||
public function testServerRequestProvidesQueryParams($request)
|
public function testGetServerRequestReadsQueryParams($request)
|
||||||
{
|
{
|
||||||
/** @var ServerRequest $request */
|
/** @var ServerRequest $request */
|
||||||
$this->assertEquals("Claude", $request->getQueryParams()["guinea_pig"]);
|
$this->assertEquals("Claude", $request->getQueryParams()["guinea_pig"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::withQueryParams
|
|
||||||
* @depends testGetServerRequestReadsFromRequest
|
|
||||||
*/
|
|
||||||
public function testWithQueryParamsCreatesNewInstance($request1)
|
|
||||||
{
|
|
||||||
/** @var ServerRequest $request1 */
|
|
||||||
$request2 = $request1->withQueryParams([
|
|
||||||
"guinea_pig" => "Clyde"
|
|
||||||
]);
|
|
||||||
$this->assertEquals("Claude", $request1->getQueryParams()["guinea_pig"]);
|
|
||||||
$this->assertEquals("Clyde", $request2->getQueryParams()["guinea_pig"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Uploaded Files
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::getUploadedFiles
|
|
||||||
*/
|
|
||||||
public function testUploadedFilesIsEmptyByDefault()
|
|
||||||
{
|
|
||||||
$request = new ServerRequest();
|
|
||||||
$this->assertEquals([], $request->getUploadedFiles());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::getUploadedFiles
|
|
||||||
* @preserveGlobalState disabled
|
|
||||||
*/
|
|
||||||
public function testGetUploadedFilesReturnsEmptyArrayWhenNoFilesAreUploaded()
|
|
||||||
{
|
|
||||||
$_SERVER = [
|
|
||||||
"HTTP_HOST" => "localhost",
|
|
||||||
"HTTP_ACCEPT" => "application/json",
|
|
||||||
"HTTP_CONTENT_TYPE" => "application/x-www-form-urlencoded"
|
|
||||||
];
|
|
||||||
$_FILES = [];
|
|
||||||
$request = ServerRequest::getServerRequest();
|
|
||||||
$this->assertSame([], $request->getUploadedFiles());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::getServerRequest
|
* @covers ::getServerRequest
|
||||||
* @covers ::readUploadedFiles
|
* @covers ::readUploadedFiles
|
||||||
|
|
@ -293,7 +251,7 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider uploadedFileProvider
|
* @dataProvider uploadedFileProvider
|
||||||
*/
|
*/
|
||||||
public function testGetServerRequestProvidesUploadedFiles($file, $path)
|
public function testGetServerRequestReadsUploadedFiles($file, $path)
|
||||||
{
|
{
|
||||||
$_SERVER = [
|
$_SERVER = [
|
||||||
"HTTP_HOST" => "localhost",
|
"HTTP_HOST" => "localhost",
|
||||||
|
|
@ -392,6 +350,137 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::getServerRequest
|
||||||
|
* @covers ::getParsedBody
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider formContentTypeProvider
|
||||||
|
*/
|
||||||
|
public function testGetServerRequestParsesFormBody($contentType)
|
||||||
|
{
|
||||||
|
$_SERVER = [
|
||||||
|
"HTTP_HOST" => "localhost",
|
||||||
|
"HTTP_CONTENT_TYPE" => $contentType,
|
||||||
|
];
|
||||||
|
$_COOKIE = [];
|
||||||
|
$_FILES = [];
|
||||||
|
$_POST = [
|
||||||
|
"dog" => "Bear"
|
||||||
|
];
|
||||||
|
$request = ServerRequest::getServerRequest();
|
||||||
|
$this->assertEquals("Bear", $request->getParsedBody()["dog"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function formContentTypeProvider()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["application/x-www-form-urlencoded"],
|
||||||
|
["multipart/form-data"]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::getAttribute
|
||||||
|
* @depends testGetServerRequestReadsFromRequest
|
||||||
|
*/
|
||||||
|
public function testGetServerRequestProvidesAttributesIfPassed($request)
|
||||||
|
{
|
||||||
|
/** @var ServerRequest $request */
|
||||||
|
$this->assertEquals("Claude", $request->getAttribute("guinea_pig"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Server Params
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::getServerParams
|
||||||
|
*/
|
||||||
|
public function testGetServerParamsReturnsEmptyArrayByDefault()
|
||||||
|
{
|
||||||
|
$request = new ServerRequest();
|
||||||
|
$this->assertEquals([], $request->getServerParams());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Cookies
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::getCookieParams
|
||||||
|
*/
|
||||||
|
public function testGetCookieParamsReturnsEmptyArrayByDefault()
|
||||||
|
{
|
||||||
|
$request = new ServerRequest();
|
||||||
|
$this->assertEquals([], $request->getCookieParams());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::withCookieParams
|
||||||
|
* @depends testGetServerRequestReadsFromRequest
|
||||||
|
*/
|
||||||
|
public function testWithCookieParamsCreatesNewInstance($request1)
|
||||||
|
{
|
||||||
|
/** @var ServerRequest $request1 */
|
||||||
|
$request2 = $request1->withCookieParams([
|
||||||
|
"cat" => "Oscar"
|
||||||
|
]);
|
||||||
|
$this->assertEquals("Molly", $request1->getCookieParams()["cat"]);
|
||||||
|
$this->assertEquals("Oscar", $request2->getCookieParams()["cat"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Query
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::getQueryParams
|
||||||
|
*/
|
||||||
|
public function testGetQueryParamsReturnsEmptyArrayByDefault()
|
||||||
|
{
|
||||||
|
$request = new ServerRequest();
|
||||||
|
$this->assertEquals([], $request->getQueryParams());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::withQueryParams
|
||||||
|
* @depends testGetServerRequestReadsFromRequest
|
||||||
|
*/
|
||||||
|
public function testWithQueryParamsCreatesNewInstance($request1)
|
||||||
|
{
|
||||||
|
/** @var ServerRequest $request1 */
|
||||||
|
$request2 = $request1->withQueryParams([
|
||||||
|
"guinea_pig" => "Clyde"
|
||||||
|
]);
|
||||||
|
$this->assertEquals("Claude", $request1->getQueryParams()["guinea_pig"]);
|
||||||
|
$this->assertEquals("Clyde", $request2->getQueryParams()["guinea_pig"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Uploaded Files
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::getUploadedFiles
|
||||||
|
*/
|
||||||
|
public function testGetUploadedFilesReturnsEmptyArrayByDefault()
|
||||||
|
{
|
||||||
|
$request = new ServerRequest();
|
||||||
|
$this->assertEquals([], $request->getUploadedFiles());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::getUploadedFiles
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
*/
|
||||||
|
public function testGetUploadedFilesReturnsEmptyArrayWhenNoFilesAreUploaded()
|
||||||
|
{
|
||||||
|
$_SERVER = [
|
||||||
|
"HTTP_HOST" => "localhost",
|
||||||
|
"HTTP_ACCEPT" => "application/json",
|
||||||
|
"HTTP_CONTENT_TYPE" => "application/x-www-form-urlencoded"
|
||||||
|
];
|
||||||
|
$_FILES = [];
|
||||||
|
$request = ServerRequest::getServerRequest();
|
||||||
|
$this->assertSame([], $request->getUploadedFiles());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::withUploadedFiles
|
* @covers ::withUploadedFiles
|
||||||
* @covers ::isValidUploadedFilesBranch
|
* @covers ::isValidUploadedFilesBranch
|
||||||
|
|
@ -414,7 +503,7 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
* @covers ::isValidUploadedFilesBranch
|
* @covers ::isValidUploadedFilesBranch
|
||||||
* @dataProvider validUploadedFilesProvider
|
* @dataProvider validUploadedFilesProvider
|
||||||
*/
|
*/
|
||||||
public function testWithUploadedFilesReturnsPassedUploadedFiles($uploadedFiles)
|
public function testWithUploadedFilesStoresPassedUploadedFiles($uploadedFiles)
|
||||||
{
|
{
|
||||||
$request = new ServerRequest();
|
$request = new ServerRequest();
|
||||||
$request = $request->withUploadedFiles($uploadedFiles);
|
$request = $request->withUploadedFiles($uploadedFiles);
|
||||||
|
|
@ -524,41 +613,12 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
/**
|
/**
|
||||||
* @covers ::getParsedBody
|
* @covers ::getParsedBody
|
||||||
*/
|
*/
|
||||||
public function testParsedBodyIsNullByDefault()
|
public function testGetParsedBodyReturnsNullByDefault()
|
||||||
{
|
{
|
||||||
$request = new ServerRequest();
|
$request = new ServerRequest();
|
||||||
$this->assertNull($request->getParsedBody());
|
$this->assertNull($request->getParsedBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::getServerRequest
|
|
||||||
* @covers ::getParsedBody
|
|
||||||
* @preserveGlobalState disabled
|
|
||||||
* @dataProvider formContentTypeProvider
|
|
||||||
*/
|
|
||||||
public function testGetServerRequestParsesFormBody($contentType)
|
|
||||||
{
|
|
||||||
$_SERVER = [
|
|
||||||
"HTTP_HOST" => "localhost",
|
|
||||||
"HTTP_CONTENT_TYPE" => $contentType,
|
|
||||||
];
|
|
||||||
$_COOKIE = [];
|
|
||||||
$_FILES = [];
|
|
||||||
$_POST = [
|
|
||||||
"dog" => "Bear"
|
|
||||||
];
|
|
||||||
$request = ServerRequest::getServerRequest();
|
|
||||||
$this->assertEquals("Bear", $request->getParsedBody()["dog"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function formContentTypeProvider()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
["application/x-www-form-urlencoded"],
|
|
||||||
["multipart/form-data"]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::withParsedBody
|
* @covers ::withParsedBody
|
||||||
* @depends testGetServerRequestReadsFromRequest
|
* @depends testGetServerRequestReadsFromRequest
|
||||||
|
|
@ -618,20 +678,23 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
/**
|
/**
|
||||||
* @covers ::getAttributes
|
* @covers ::getAttributes
|
||||||
*/
|
*/
|
||||||
public function testAttributesIsEmptyByDefault()
|
public function testGetAttributesReturnsEmptyArrayByDefault()
|
||||||
{
|
{
|
||||||
$request = new ServerRequest();
|
$request = new ServerRequest();
|
||||||
$this->assertEquals([], $request->getAttributes());
|
$this->assertEquals([], $request->getAttributes());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::getAttribute
|
* @covers ::getAttributes
|
||||||
* @depends testGetServerRequestReadsFromRequest
|
|
||||||
*/
|
*/
|
||||||
public function testServerRequestProvidesAttributesIfPassed($request)
|
public function testGetAttributesReturnsAllAttributes()
|
||||||
{
|
{
|
||||||
/** @var ServerRequest $request */
|
$request = new ServerRequest();
|
||||||
$this->assertEquals("Claude", $request->getAttribute("guinea_pig"));
|
$request = $request->withAttribute("cat", "Molly");
|
||||||
|
$request = $request->withAttribute("dog", "Bear");
|
||||||
|
$attributes = $request->getAttributes();
|
||||||
|
$this->assertEquals("Molly", $attributes["cat"]);
|
||||||
|
$this->assertEquals("Bear", $attributes["dog"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -689,70 +752,6 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals("Bear", $request->getAttribute("dog"));
|
$this->assertEquals("Bear", $request->getAttribute("dog"));
|
||||||
$this->assertEquals("Oscar", $request->getAttribute("cat", "Oscar"));
|
$this->assertEquals("Oscar", $request->getAttribute("cat", "Oscar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::getAttributes
|
|
||||||
*/
|
|
||||||
public function testGetAttributesReturnsAllAttributes()
|
|
||||||
{
|
|
||||||
$request = new ServerRequest();
|
|
||||||
$request = $request->withAttribute("cat", "Molly");
|
|
||||||
$request = $request->withAttribute("dog", "Bear");
|
|
||||||
$attributes = $request->getAttributes();
|
|
||||||
$this->assertEquals("Molly", $attributes["cat"]);
|
|
||||||
$this->assertEquals("Bear", $attributes["dog"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// URI
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::getServerRequest
|
|
||||||
* @covers ::getServerRequestHeaders
|
|
||||||
* @covers ::readFromServerRequest
|
|
||||||
* @covers ::readUri
|
|
||||||
* @preserveGlobalState disabled
|
|
||||||
* @dataProvider uriProvider
|
|
||||||
*/
|
|
||||||
public function testGetServerRequestProvidesUri($expected, $server)
|
|
||||||
{
|
|
||||||
$_SERVER = $server;
|
|
||||||
$request = ServerRequest::getServerRequest();
|
|
||||||
$this->assertEquals($expected, $request->getUri());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function uriProvider()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
new Uri("http://localhost/path"),
|
|
||||||
[
|
|
||||||
"HTTPS" => "off",
|
|
||||||
"HTTP_HOST" => "localhost",
|
|
||||||
"REQUEST_URI" => "/path",
|
|
||||||
"QUERY_STRING" => ""
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
new Uri("https://foo.com/path/to/stuff?cat=molly"),
|
|
||||||
[
|
|
||||||
"HTTPS" => "1",
|
|
||||||
"HTTP_HOST" => "foo.com",
|
|
||||||
"REQUEST_URI" => "/path/to/stuff?cat=molly",
|
|
||||||
"QUERY_STRING" => "cat=molly"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
new Uri("http://foo.com:8080/path/to/stuff?cat=molly"),
|
|
||||||
[
|
|
||||||
"HTTP" => "1",
|
|
||||||
"HTTP_HOST" => "foo.com:8080",
|
|
||||||
"REQUEST_URI" => "/path/to/stuff?cat=molly",
|
|
||||||
"QUERY_STRING" => "cat=molly"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace WellRESTed\Test\Message;
|
||||||
use WellRESTed\Message\Stream;
|
use WellRESTed\Message\Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @coversDefaultClass WellRESTed\Message\Stream
|
||||||
* @uses WellRESTed\Message\Stream
|
* @uses WellRESTed\Message\Stream
|
||||||
*/
|
*/
|
||||||
class StreamTest extends \PHPUnit_Framework_TestCase
|
class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
@ -26,7 +27,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::__construct()
|
* @covers ::__construct
|
||||||
*/
|
*/
|
||||||
public function testCreatesInstanceWithStreamResource()
|
public function testCreatesInstanceWithStreamResource()
|
||||||
{
|
{
|
||||||
|
|
@ -41,7 +42,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::__construct()
|
* @covers ::__construct
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
* @dataProvider invalidResourceProvider
|
* @dataProvider invalidResourceProvider
|
||||||
*/
|
*/
|
||||||
|
|
@ -61,7 +62,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::__toString()
|
* @covers ::__toString
|
||||||
*/
|
*/
|
||||||
public function testCastsToString()
|
public function testCastsToString()
|
||||||
{
|
{
|
||||||
|
|
@ -70,7 +71,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::close()
|
* @covers ::close
|
||||||
*/
|
*/
|
||||||
public function testClosesHandle()
|
public function testClosesHandle()
|
||||||
{
|
{
|
||||||
|
|
@ -80,7 +81,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::detach()
|
* @covers ::detach
|
||||||
*/
|
*/
|
||||||
public function testDetachReturnsHandle()
|
public function testDetachReturnsHandle()
|
||||||
{
|
{
|
||||||
|
|
@ -89,7 +90,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::detach()
|
* @covers ::detach
|
||||||
*/
|
*/
|
||||||
public function testDetachUnsetsInstanceVariable()
|
public function testDetachUnsetsInstanceVariable()
|
||||||
{
|
{
|
||||||
|
|
@ -99,7 +100,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::getSize
|
* @covers ::getSize
|
||||||
*/
|
*/
|
||||||
public function testReturnsSize()
|
public function testReturnsSize()
|
||||||
{
|
{
|
||||||
|
|
@ -108,7 +109,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::tell
|
* @covers ::tell
|
||||||
*/
|
*/
|
||||||
public function testTellReturnsHandlePosition()
|
public function testTellReturnsHandlePosition()
|
||||||
{
|
{
|
||||||
|
|
@ -118,7 +119,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::eof
|
* @covers ::eof
|
||||||
*/
|
*/
|
||||||
public function testReturnsOef()
|
public function testReturnsOef()
|
||||||
{
|
{
|
||||||
|
|
@ -130,7 +131,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::isSeekable
|
* @covers ::isSeekable
|
||||||
*/
|
*/
|
||||||
public function testReadsSeekableStatusFromMetadata()
|
public function testReadsSeekableStatusFromMetadata()
|
||||||
{
|
{
|
||||||
|
|
@ -141,7 +142,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::seek
|
* @covers ::seek
|
||||||
*/
|
*/
|
||||||
public function testSeeksToPosition()
|
public function testSeeksToPosition()
|
||||||
{
|
{
|
||||||
|
|
@ -151,7 +152,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::rewind
|
* @covers ::rewind
|
||||||
*/
|
*/
|
||||||
public function testRewindReturnsToBeginning()
|
public function testRewindReturnsToBeginning()
|
||||||
{
|
{
|
||||||
|
|
@ -162,7 +163,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::write
|
* @covers ::write
|
||||||
*/
|
*/
|
||||||
public function testWritesToHandle()
|
public function testWritesToHandle()
|
||||||
{
|
{
|
||||||
|
|
@ -173,7 +174,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::write
|
* @covers ::write
|
||||||
* @expectedException \RuntimeException
|
* @expectedException \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testThrowsExceptionOnErrorWriting()
|
public function testThrowsExceptionOnErrorWriting()
|
||||||
|
|
@ -185,7 +186,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::read
|
* @covers ::read
|
||||||
* @expectedException \RuntimeException
|
* @expectedException \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testThrowsExceptionOnErrorReading()
|
public function testThrowsExceptionOnErrorReading()
|
||||||
|
|
@ -197,7 +198,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::read
|
* @covers ::read
|
||||||
*/
|
*/
|
||||||
public function testReadsFromStream()
|
public function testReadsFromStream()
|
||||||
{
|
{
|
||||||
|
|
@ -208,7 +209,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::getContents
|
* @covers ::getContents
|
||||||
* @expectedException \RuntimeException
|
* @expectedException \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testThrowsExceptionOnErrorReadingToEnd()
|
public function testThrowsExceptionOnErrorReadingToEnd()
|
||||||
|
|
@ -220,7 +221,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::getContents
|
* @covers ::getContents
|
||||||
*/
|
*/
|
||||||
public function testReadsToEnd()
|
public function testReadsToEnd()
|
||||||
{
|
{
|
||||||
|
|
@ -231,7 +232,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::getMetadata
|
* @covers ::getMetadata
|
||||||
*/
|
*/
|
||||||
public function testReturnsMetadataArray()
|
public function testReturnsMetadataArray()
|
||||||
{
|
{
|
||||||
|
|
@ -240,7 +241,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::getMetadata
|
* @covers ::getMetadata
|
||||||
*/
|
*/
|
||||||
public function testReturnsMetadataItem()
|
public function testReturnsMetadataItem()
|
||||||
{
|
{
|
||||||
|
|
@ -250,7 +251,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::isReadable
|
* @covers ::isReadable
|
||||||
* @dataProvider modeProvider
|
* @dataProvider modeProvider
|
||||||
*/
|
*/
|
||||||
public function testReturnsIsReadableForReadableStreams($mode, $readable, $writeable)
|
public function testReturnsIsReadableForReadableStreams($mode, $readable, $writeable)
|
||||||
|
|
@ -265,7 +266,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Stream::isWritable
|
* @covers ::isWritable
|
||||||
* @dataProvider modeProvider
|
* @dataProvider modeProvider
|
||||||
*/
|
*/
|
||||||
public function testReturnsIsWritableForWritableStreams($mode, $readable, $writeable)
|
public function testReturnsIsWritableForWritableStreams($mode, $readable, $writeable)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace WellRESTed\Test\Message;
|
||||||
use WellRESTed\Message\Uri;
|
use WellRESTed\Message\Uri;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @coversDefaultClass WellRESTed\Message\Uri
|
||||||
* @uses WellRESTed\Message\Uri
|
* @uses WellRESTed\Message\Uri
|
||||||
*/
|
*/
|
||||||
class UriTest extends \PHPUnit_Framework_TestCase
|
class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
@ -13,7 +14,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
// Scheme
|
// Scheme
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getScheme
|
* @covers ::getScheme
|
||||||
*/
|
*/
|
||||||
public function testDefaultSchemeIsEmpty()
|
public function testDefaultSchemeIsEmpty()
|
||||||
{
|
{
|
||||||
|
|
@ -22,7 +23,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::withScheme
|
* @covers ::withScheme
|
||||||
* @dataProvider schemeProvider
|
* @dataProvider schemeProvider
|
||||||
* @param string $expected The expected result of getScheme
|
* @param string $expected The expected result of getScheme
|
||||||
* @param string $scheme The scheme to pass to withScheme
|
* @param string $scheme The scheme to pass to withScheme
|
||||||
|
|
@ -47,7 +48,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::withScheme
|
* @covers ::withScheme
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testInvalidSchemeThrowsException()
|
public function testInvalidSchemeThrowsException()
|
||||||
|
|
@ -60,7 +61,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
// Authority
|
// Authority
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getAuthority
|
* @covers ::getAuthority
|
||||||
*/
|
*/
|
||||||
public function testDefaultAuthorityIsEmpty()
|
public function testDefaultAuthorityIsEmpty()
|
||||||
{
|
{
|
||||||
|
|
@ -68,13 +69,13 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertSame("", $uri->getAuthority());
|
$this->assertSame("", $uri->getAuthority());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRespectsMyAuthoritai()
|
public function testRespectsMyAuthoritah()
|
||||||
{
|
{
|
||||||
$this->assertTrue(true);
|
$this->assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getAuthority
|
* @covers ::getAuthority
|
||||||
* @dataProvider authorityProvider
|
* @dataProvider authorityProvider
|
||||||
* @param string $expected
|
* @param string $expected
|
||||||
* @param array $components
|
* @param array $components
|
||||||
|
|
@ -187,7 +188,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
// User Info
|
// User Info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getUserInfo
|
* @covers ::getUserInfo
|
||||||
*/
|
*/
|
||||||
public function testDefaultUserInfoIsEmpty()
|
public function testDefaultUserInfoIsEmpty()
|
||||||
{
|
{
|
||||||
|
|
@ -196,8 +197,8 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getUserInfo
|
* @covers ::getUserInfo
|
||||||
* @covers WellRESTed\Message\Uri::withUserInfo
|
* @covers ::withUserInfo
|
||||||
* @dataProvider userInfoProvider
|
* @dataProvider userInfoProvider
|
||||||
*
|
*
|
||||||
* @param string $expected The combined user:password value
|
* @param string $expected The combined user:password value
|
||||||
|
|
@ -226,7 +227,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
// Host
|
// Host
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getHost
|
* @covers ::getHost
|
||||||
*/
|
*/
|
||||||
public function testDefaultHostIsEmpty()
|
public function testDefaultHostIsEmpty()
|
||||||
{
|
{
|
||||||
|
|
@ -235,8 +236,8 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getHost
|
* @covers ::getHost
|
||||||
* @covers WellRESTed\Message\Uri::withHost
|
* @covers ::withHost
|
||||||
* @dataProvider hostProvider
|
* @dataProvider hostProvider
|
||||||
* @param $expected
|
* @param $expected
|
||||||
* @param $host
|
* @param $host
|
||||||
|
|
@ -259,7 +260,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::withHost
|
* @covers ::withHost
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
* @dataProvider invalidHostProvider
|
* @dataProvider invalidHostProvider
|
||||||
* @param $host
|
* @param $host
|
||||||
|
|
@ -283,7 +284,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
// Port
|
// Port
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getPort
|
* @covers ::getPort
|
||||||
*/
|
*/
|
||||||
public function testDefaultPortWithNoSchemeIsNull()
|
public function testDefaultPortWithNoSchemeIsNull()
|
||||||
{
|
{
|
||||||
|
|
@ -292,7 +293,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getPort
|
* @covers ::getPort
|
||||||
*/
|
*/
|
||||||
public function testDefaultPortForHttpSchemeIs80()
|
public function testDefaultPortForHttpSchemeIs80()
|
||||||
{
|
{
|
||||||
|
|
@ -301,7 +302,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getPort
|
* @covers ::getPort
|
||||||
*/
|
*/
|
||||||
public function testDefaultPortForHttpsSchemeIs443()
|
public function testDefaultPortForHttpsSchemeIs443()
|
||||||
{
|
{
|
||||||
|
|
@ -310,8 +311,8 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getPort
|
* @covers ::getPort
|
||||||
* @covers WellRESTed\Message\Uri::withPort
|
* @covers ::withPort
|
||||||
* @dataProvider portAndSchemeProvider
|
* @dataProvider portAndSchemeProvider
|
||||||
*
|
*
|
||||||
* @param int|null $expectedPort
|
* @param int|null $expectedPort
|
||||||
|
|
@ -338,7 +339,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::withPort
|
* @covers ::withPort
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
* @dataProvider invalidPortProvider
|
* @dataProvider invalidPortProvider
|
||||||
* @param int $port
|
* @param int $port
|
||||||
|
|
@ -363,7 +364,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
// Path
|
// Path
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getPath
|
* @covers ::getPath
|
||||||
*/
|
*/
|
||||||
public function testDefaultPathIsEmpty()
|
public function testDefaultPathIsEmpty()
|
||||||
{
|
{
|
||||||
|
|
@ -372,9 +373,9 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getPath
|
* @covers ::getPath
|
||||||
* @covers WellRESTed\Message\Uri::withPath
|
* @covers ::withPath
|
||||||
* @covers WellRESTed\Message\Uri::percentEncode
|
* @covers ::percentEncode
|
||||||
* @dataProvider pathProvider
|
* @dataProvider pathProvider
|
||||||
* @param $expected
|
* @param $expected
|
||||||
* @param $path
|
* @param $path
|
||||||
|
|
@ -387,9 +388,9 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getPath
|
* @covers ::getPath
|
||||||
* @covers WellRESTed\Message\Uri::withPath
|
* @covers ::withPath
|
||||||
* @covers WellRESTed\Message\Uri::percentEncode
|
* @covers ::percentEncode
|
||||||
* @dataProvider pathProvider
|
* @dataProvider pathProvider
|
||||||
* @param $expected
|
* @param $expected
|
||||||
* @param $path
|
* @param $path
|
||||||
|
|
@ -419,7 +420,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
// Query
|
// Query
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getQuery
|
* @covers ::getQuery
|
||||||
*/
|
*/
|
||||||
public function testDefaultQueryIsEmpty()
|
public function testDefaultQueryIsEmpty()
|
||||||
{
|
{
|
||||||
|
|
@ -428,9 +429,9 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getQuery
|
* @covers ::getQuery
|
||||||
* @covers WellRESTed\Message\Uri::withQuery
|
* @covers ::withQuery
|
||||||
* @covers WellRESTed\Message\Uri::percentEncode
|
* @covers ::percentEncode
|
||||||
* @dataProvider queryProvider
|
* @dataProvider queryProvider
|
||||||
* @param $expected
|
* @param $expected
|
||||||
* @param $query
|
* @param $query
|
||||||
|
|
@ -443,9 +444,9 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getQuery
|
* @covers ::getQuery
|
||||||
* @covers WellRESTed\Message\Uri::withQuery
|
* @covers ::withQuery
|
||||||
* @covers WellRESTed\Message\Uri::percentEncode
|
* @covers ::percentEncode
|
||||||
* @dataProvider queryProvider
|
* @dataProvider queryProvider
|
||||||
* @param $expected
|
* @param $expected
|
||||||
* @param $query
|
* @param $query
|
||||||
|
|
@ -468,7 +469,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::withPath
|
* @covers ::withPath
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
* @dataProvider invalidPathProvider
|
* @dataProvider invalidPathProvider
|
||||||
* @param $path
|
* @param $path
|
||||||
|
|
@ -492,7 +493,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
// Fragment
|
// Fragment
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getFragment
|
* @covers ::getFragment
|
||||||
*/
|
*/
|
||||||
public function testDefaultFragmentIsEmpty()
|
public function testDefaultFragmentIsEmpty()
|
||||||
{
|
{
|
||||||
|
|
@ -501,9 +502,9 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getFragment
|
* @covers ::getFragment
|
||||||
* @covers WellRESTed\Message\Uri::withFragment
|
* @covers ::withFragment
|
||||||
* @covers WellRESTed\Message\Uri::percentEncode
|
* @covers ::percentEncode
|
||||||
* @dataProvider fragmentProvider
|
* @dataProvider fragmentProvider
|
||||||
* @param $expected
|
* @param $expected
|
||||||
* @param $fragment
|
* @param $fragment
|
||||||
|
|
@ -516,9 +517,9 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::getFragment
|
* @covers ::getFragment
|
||||||
* @covers WellRESTed\Message\Uri::withFragment
|
* @covers ::withFragment
|
||||||
* @covers WellRESTed\Message\Uri::percentEncode
|
* @covers ::percentEncode
|
||||||
* @dataProvider fragmentProvider
|
* @dataProvider fragmentProvider
|
||||||
* @param $expected
|
* @param $expected
|
||||||
* @param $fragment
|
* @param $fragment
|
||||||
|
|
@ -544,7 +545,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
// Concatenation
|
// Concatenation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::__toString
|
* @covers ::__toString
|
||||||
* @dataProvider componentProvider
|
* @dataProvider componentProvider
|
||||||
* @param string $expected
|
* @param string $expected
|
||||||
* @param array $components
|
* @param array $components
|
||||||
|
|
@ -652,8 +653,8 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers WellRESTed\Message\Uri::__construct()
|
* @covers ::__construct()
|
||||||
* @covers WellRESTed\Message\Uri::__toString()
|
* @covers ::__toString()
|
||||||
* @dataProvider stringUriProvider
|
* @dataProvider stringUriProvider
|
||||||
*/
|
*/
|
||||||
public function testUriCreatedFromStringNormalizesString($expected, $input)
|
public function testUriCreatedFromStringNormalizesString($expected, $input)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue