diff --git a/src/Message/HeaderCollection.php b/src/Message/HeaderCollection.php index 2384f37..51a8f03 100644 --- a/src/Message/HeaderCollection.php +++ b/src/Message/HeaderCollection.php @@ -5,6 +5,19 @@ namespace WellRESTed\Message; use ArrayAccess; 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 { /** diff --git a/test/tests/unit/Message/HeaderCollectionTest.php b/test/tests/unit/Message/HeaderCollectionTest.php index 8094558..a13d589 100644 --- a/test/tests/unit/Message/HeaderCollectionTest.php +++ b/test/tests/unit/Message/HeaderCollectionTest.php @@ -4,10 +4,14 @@ namespace WellRESTed\Test\Message; use WellRESTed\Message\HeaderCollection; +/** + * @coversDefaultClass WellRESTed\Message\HeaderCollection + * @uses WellRESTed\Message\HeaderCollection + */ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase { /** - * @covers WellRESTed\Message\HeaderCollection::__construct + * @covers ::__construct */ public function testCreatesInstance() { @@ -16,9 +20,8 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\HeaderCollection::offsetSet - * @covers WellRESTed\Message\HeaderCollection::offsetExists - * @uses WellRESTed\Message\HeaderCollection::__construct + * @covers ::offsetSet + * @covers ::offsetExists */ public function testAddsSingleHeaderAndIndicatesCaseInsensitiveIsset() { @@ -28,9 +31,8 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\HeaderCollection::offsetSet - * @covers WellRESTed\Message\HeaderCollection::offsetExists - * @uses WellRESTed\Message\HeaderCollection::__construct + * @covers ::offsetSet + * @covers ::offsetExists */ public function testAddsMultipleHeadersAndIndicatesCaseInsensitiveIsset() { @@ -41,9 +43,7 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\HeaderCollection::offsetGet - * @uses WellRESTed\Message\HeaderCollection::offsetSet - * @uses WellRESTed\Message\HeaderCollection::__construct + * @covers ::offsetGet */ public function testReturnsHeadersWithCaseInsensitiveHeaderName() { @@ -57,10 +57,7 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\HeaderCollection::offsetUnset - * @uses WellRESTed\Message\HeaderCollection::__construct - * @uses WellRESTed\Message\HeaderCollection::offsetSet - * @uses WellRESTed\Message\HeaderCollection::offsetExists + * @covers ::offsetUnset */ public function testRemovesHeadersWithCaseInsensitiveHeaderName() { @@ -72,10 +69,7 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase } /** - * @uses WellRESTed\Message\HeaderCollection::__construct - * @uses WellRESTed\Message\HeaderCollection::offsetSet - * @uses WellRESTed\Message\HeaderCollection::offsetExists - * @uses WellRESTed\Message\HeaderCollection::offsetUnset + * @coversNothing */ public function testCloneMakesDeepCopyOfHeaders() { @@ -90,15 +84,11 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\HeaderCollection::current - * @covers WellRESTed\Message\HeaderCollection::next - * @covers WellRESTed\Message\HeaderCollection::key - * @covers WellRESTed\Message\HeaderCollection::valid - * @covers WellRESTed\Message\HeaderCollection::rewind - * @uses WellRESTed\Message\HeaderCollection::__construct - * @uses WellRESTed\Message\HeaderCollection::offsetSet - * @uses WellRESTed\Message\HeaderCollection::offsetExists - * @uses WellRESTed\Message\HeaderCollection::offsetUnset + * @covers ::current + * @covers ::next + * @covers ::key + * @covers ::valid + * @covers ::rewind */ public function testIteratesWithOriginalKeys() { @@ -121,15 +111,11 @@ class HeaderCollectionTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\HeaderCollection::current - * @covers WellRESTed\Message\HeaderCollection::next - * @covers WellRESTed\Message\HeaderCollection::key - * @covers WellRESTed\Message\HeaderCollection::valid - * @covers WellRESTed\Message\HeaderCollection::rewind - * @uses WellRESTed\Message\HeaderCollection::__construct - * @uses WellRESTed\Message\HeaderCollection::offsetSet - * @uses WellRESTed\Message\HeaderCollection::offsetExists - * @uses WellRESTed\Message\HeaderCollection::offsetUnset + * @covers ::current + * @covers ::next + * @covers ::key + * @covers ::valid + * @covers ::rewind */ public function testIteratesWithOriginalKeysAndValues() { diff --git a/test/tests/unit/Message/MessageTest.php b/test/tests/unit/Message/MessageTest.php index 6e575d7..b081a56 100644 --- a/test/tests/unit/Message/MessageTest.php +++ b/test/tests/unit/Message/MessageTest.php @@ -3,13 +3,14 @@ namespace WellRESTed\Test\Unit\Message; /** + * @coversDefaultClass WellRESTed\Message\Message * @uses WellRESTed\Message\Message * @uses WellRESTed\Message\HeaderCollection */ class MessageTest extends \PHPUnit_Framework_TestCase { /** - * @covers WellRESTed\Message\Message::__construct + * @covers ::__construct */ public function testCreatesInstance() { @@ -18,7 +19,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Message::__construct + * @covers ::__construct */ public function testSetsHeadersOnConstruction() { @@ -29,7 +30,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Message::__construct + * @covers ::__construct */ public function testSetsBodyOnConstruction() { @@ -40,7 +41,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Message::__clone + * @covers ::__clone */ public function testCloneMakesDeepCopyOfHeaders() { @@ -55,18 +56,18 @@ class MessageTest extends \PHPUnit_Framework_TestCase // Protocol Version /** - * @covers WellRESTed\Message\Message::getProtocolVersion + * @covers ::getProtocolVersion */ - public function testReturnsProtocolVersion1Point1ByDefault() + public function testGetProtocolVersionReturnsProtocolVersion1Point1ByDefault() { $message = $this->getMockForAbstractClass('\WellRESTed\Message\Message'); $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 = $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 = $message->withProtocolVersion("1.0"); @@ -87,8 +88,8 @@ class MessageTest extends \PHPUnit_Framework_TestCase // Headers /** - * @covers WellRESTed\Message\Message::withHeader - * @covers WellRESTed\Message\Message::getValidatedHeaders + * @covers ::withHeader + * @covers ::getValidatedHeaders * @dataProvider validHeaderValueProvider */ public function testWithHeaderReplacesHeader($expected, $value) @@ -108,12 +109,12 @@ class MessageTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Message::withHeader - * @covers WellRESTed\Message\Message::getValidatedHeaders + * @covers ::withHeader + * @covers ::getValidatedHeaders * @expectedException \InvalidArgumentException * @dataProvider invalidHeaderProvider */ - public function testWithHeaderThrowExceptionWithInvalidArgument($name, $value) + public function testWithHeaderThrowsExceptionWithInvalidArgument($name, $value) { $message = $this->getMockForAbstractClass('\WellRESTed\Message\Message'); $message->withHeader($name, $value); @@ -124,12 +125,12 @@ class MessageTest extends \PHPUnit_Framework_TestCase return [ [0, 1024], ["Content-length", false], - ["Content-length", [false]], + ["Content-length", [false]] ]; } /** - * @covers WellRESTed\Message\Message::withAddedHeader + * @covers ::withAddedHeader */ public function testWithAddedHeaderSetsHeader() { @@ -139,7 +140,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Message::withAddedHeader + * @covers ::withAddedHeader */ public function testWithAddedHeaderAppendsValue() { @@ -152,7 +153,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Message::withoutHeader + * @covers ::withoutHeader */ 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() { @@ -173,27 +183,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Message::getHeaderLine - */ - 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 + * @covers ::getHeader */ 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'); - $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() { @@ -223,7 +224,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Message::hasHeader + * @covers ::hasHeader */ public function testHasHeaderReturnsFalseWhenHeaderIsNotSet() { @@ -232,7 +233,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Message::getHeaders + * @covers ::getHeaders */ public function testGetHeadersReturnOriginalHeaderNamesAsKeys() { @@ -252,7 +253,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Message::getHeaders + * @covers ::getHeaders */ public function testGetHeadersReturnOriginalHeaderNamesAndValues() { @@ -285,7 +286,7 @@ class MessageTest extends \PHPUnit_Framework_TestCase // Body /** - * @covers WellRESTed\Message\Message::getBody + * @covers ::getBody * @uses WellRESTed\Message\NullStream */ public function testGetBodyReturnsEmptyStreamByDefault() @@ -295,8 +296,8 @@ class MessageTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Message::getBody - * @covers WellRESTed\Message\Message::withBody + * @covers ::getBody + * @covers ::withBody */ public function testGetBodyReturnsAttachedStream() { diff --git a/test/tests/unit/Message/NullStreamTest.php b/test/tests/unit/Message/NullStreamTest.php index 11e61b4..69ded1b 100644 --- a/test/tests/unit/Message/NullStreamTest.php +++ b/test/tests/unit/Message/NullStreamTest.php @@ -4,10 +4,14 @@ namespace WellRESTed\Test\Message; use WellRESTed\Message\NullStream; +/** + * @coversDefaultClass WellRESTed\Message\NullStream + * @uses WellRESTed\Message\NullStream + */ class NullStreamTest extends \PHPUnit_Framework_TestCase { /** - * @covers WellRESTed\Message\NullStream::__toString() + * @covers ::__toString() */ public function testCastsToString() { @@ -18,12 +22,12 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase public function testCloseDoesNothing() { $stream = new \WellRESTed\Message\NullStream(); - $this->assertNull($stream->close()); + $stream->close(); + $this->assertTrue(true); // Asserting no exception occured. } /** - * @covers WellRESTed\Message\NullStream::detach() - * @uses WellRESTed\Message\Stream + * @covers ::detach() */ public function testDetachReturnsNull() { @@ -32,8 +36,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\NullStream::getSize - * @uses WellRESTed\Message\Stream + * @covers ::getSize */ public function testSizeReturnsZero() { @@ -42,7 +45,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\NullStream::tell + * @covers ::tell */ 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(); $this->assertTrue($stream->eof()); } /** - * @covers WellRESTed\Message\NullStream::isSeekable - * @uses WellRESTed\Message\Stream + * @covers ::isSeekable */ public function testIsSeekableReturnsFalse() { @@ -70,7 +72,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\NullStream::seek + * @covers ::seek * @expectedException \RuntimeException */ public function testSeekReturnsFalse() @@ -80,17 +82,17 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\NullStream::rewind + * @covers ::rewind * @expectedException \RuntimeException */ - public function testRewindReturnsFalse() + public function testRewindThrowsException() { $stream = new \WellRESTed\Message\NullStream(); $stream->rewind(); } /** - * @covers WellRESTed\Message\NullStream::isWritable + * @covers ::isWritable */ public function testIsWritableReturnsFalse() { @@ -99,7 +101,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\NullStream::write + * @covers ::write * @expectedException \RuntimeException */ 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(); $this->assertTrue($stream->isReadable()); } /** - * @covers WellRESTed\Message\NullStream::read + * @covers ::read */ public function testReadReturnsEmptyString() { @@ -127,7 +129,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\NullStream::getContents + * @covers ::getContents */ public function testGetContentsReturnsEmptyString() { @@ -136,7 +138,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\NullStream::getMetadata + * @covers ::getMetadata */ public function testGetMetadataReturnsNull() { @@ -145,7 +147,7 @@ class NullStreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\NullStream::getMetadata + * @covers ::getMetadata */ public function testGetMetadataReturnsNullWithKey() { diff --git a/test/tests/unit/Message/RequestTest.php b/test/tests/unit/Message/RequestTest.php index e88092d..a46ad79 100644 --- a/test/tests/unit/Message/RequestTest.php +++ b/test/tests/unit/Message/RequestTest.php @@ -6,6 +6,7 @@ use WellRESTed\Message\Request; use WellRESTed\Message\Uri; /** + * @coversDefaultClass WellRESTed\Message\Request * @uses WellRESTed\Message\Request * @uses WellRESTed\Message\Request * @uses WellRESTed\Message\Message @@ -18,7 +19,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase // Construction /** - * @covers WellRESTed\Message\Request::__construct + * @covers ::__construct */ public function testCreatesInstance() { @@ -27,7 +28,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::__construct + * @covers ::__construct */ public function testCreatesInstanceWithUri() { @@ -38,7 +39,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::__construct + * @covers ::__construct */ public function testCreatesInstanceWithMethod() { @@ -48,7 +49,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::__construct + * @covers ::__construct */ public function testSetsHeadersOnConstruction() { @@ -59,7 +60,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::__construct + * @covers ::__construct */ public function testSetsBodyOnConstruction() { @@ -72,9 +73,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase // Request Target /** - * @covers WellRESTed\Message\Request::getRequestTarget + * @covers ::getRequestTarget */ - public function testGetRequestTargetPrefersConreteRequestTarget() + public function testGetRequestTargetPrefersExplicitRequestTarget() { $request = new Request(); $request = $request->withRequestTarget("*"); @@ -82,7 +83,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::getRequestTarget + * @covers ::getRequestTarget */ public function testGetRequestTargetUsesOriginFormOfUri() { @@ -97,7 +98,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::getRequestTarget + * @covers ::getRequestTarget */ public function testGetRequestTargetReturnsSlashByDefault() { @@ -106,8 +107,8 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::withRequestTarget - * @covers WellRESTed\Message\Request::getRequestTarget + * @covers ::withRequestTarget + * @covers ::getRequestTarget */ public function testWithRequestTargetCreatesNewInstance() { @@ -120,7 +121,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase // Method /** - * @covers WellRESTed\Message\Request::getMethod + * @covers ::getMethod */ public function testGetMethodReturnsGetByDefault() { @@ -129,9 +130,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::withMethod - * @covers WellRESTed\Message\Request::getValidatedMethod - * @covers WellRESTed\Message\Request::getMethod + * @covers ::withMethod + * @covers ::getValidatedMethod + * @covers ::getMethod */ public function testWithMethodCreatesNewInstance() { @@ -141,12 +142,12 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::withMethod - * @covers WellRESTed\Message\Request::getValidatedMethod + * @covers ::withMethod + * @covers ::getValidatedMethod * @dataProvider invalidMethodProvider * @expectedException \InvalidArgumentException */ - public function testWithMethoThrowsExceptionOnInvalidMethod($method) + public function testWithMethodThrowsExceptionOnInvalidMethod($method) { $request = new Request(); $request->withMethod($method); @@ -165,8 +166,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase // Request URI /** - * @covers WellRESTed\Message\Request::getUri - * @ + * @covers ::getUri */ public function testGetUriReturnsEmptyUriByDefault() { @@ -176,8 +176,8 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::withUri - * @covers WellRESTed\Message\Request::getUri + * @covers ::withUri + * @covers ::getUri */ public function testWithUriCreatesNewInstance() { @@ -190,7 +190,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::__clone + * @covers ::__clone */ public function testWithUriPreservesOriginalRequest() { @@ -215,7 +215,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::withUri + * @covers ::withUri */ public function testWithUriUpdatesHostHeader() { @@ -230,7 +230,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::withUri + * @covers ::withUri */ public function testWithUriDoesNotUpdatesHostHeaderWhenUriHasNoHost() { @@ -245,7 +245,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::withUri + * @covers ::withUri */ public function testPreserveHostUpdatesHostHeaderWhenHeaderIsOriginallyMissing() { @@ -259,7 +259,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::withUri + * @covers ::withUri */ public function testPreserveHostDoesNotUpdatesWhenBothAreMissingHosts() { @@ -272,7 +272,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Request::withUri + * @covers ::withUri */ public function testPreserveHostDoesNotUpdateHostHeader() { diff --git a/test/tests/unit/Message/ResponseTest.php b/test/tests/unit/Message/ResponseTest.php index e1295e1..0d3f94a 100644 --- a/test/tests/unit/Message/ResponseTest.php +++ b/test/tests/unit/Message/ResponseTest.php @@ -5,16 +5,53 @@ namespace WellRESTed\Test\Unit\Message; use WellRESTed\Message\Response; /** + * @coversDefaultClass WellRESTed\Message\Response * @uses WellRESTed\Message\Response * @uses WellRESTed\Message\Message * @uses WellRESTed\Message\HeaderCollection */ class ResponseTest extends \PHPUnit_Framework_TestCase { + // ------------------------------------------------------------------------ + // Construction + /** - * @covers WellRESTed\Message\Response::withStatus - * @covers WellRESTed\Message\Response::getStatusCode - * @covers WellRESTed\Message\Response::getDefaultReasonPhraseForStatusCode + * @covers ::__construct + */ + 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() { @@ -24,9 +61,9 @@ class ResponseTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Response::withStatus - * @covers WellRESTed\Message\Response::getReasonPhrase - * @covers WellRESTed\Message\Response::getDefaultReasonPhraseForStatusCode + * @covers ::withStatus + * @covers ::getReasonPhrase + * @covers ::getDefaultReasonPhraseForStatusCode * @dataProvider statusProvider */ public function testCreatesNewInstanceWithReasonPhrase($code, $reasonPhrase, $expected) @@ -82,8 +119,8 @@ class ResponseTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Response::withStatus - * @covers WellRESTed\Message\Response::getStatusCode + * @covers ::withStatus + * @covers ::getStatusCode */ public function testWithStatusCodePreservesOriginalResponse() { @@ -100,37 +137,4 @@ class ResponseTest extends \PHPUnit_Framework_TestCase $this->assertEquals(404, $response2->getStatusCode()); $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()); - } } diff --git a/test/tests/unit/Message/ServerRequestTest.php b/test/tests/unit/Message/ServerRequestTest.php index 25b3f35..21f16c3 100644 --- a/test/tests/unit/Message/ServerRequestTest.php +++ b/test/tests/unit/Message/ServerRequestTest.php @@ -6,7 +6,6 @@ use WellRESTed\Message\ServerRequest; use WellRESTed\Message\UploadedFile; use WellRESTed\Message\Uri; -// TODO Test nested $_FILES with associative array for last level // TODO Remove concrete class used for testing /** @@ -62,14 +61,14 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase } // ------------------------------------------------------------------------ - // Request + // Marshalling Request Information /** * @covers ::readFromServerRequest * @preserveGlobalState disabled * @dataProvider protocolVersionProvider */ - public function testReadsProtocolVersionFromFromRequest($expectedProtocol, $serverProtocol) + public function testGetServerRequestReadsProtocolVersion($expectedProtocol, $serverProtocol) { $_SERVER = [ "HTTP_HOST" => "localhost", @@ -95,7 +94,7 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase * @preserveGlobalState disabled * @dataProvider methodProvider */ - public function testReadsMethodFromFromRequest($exectedMethod, $serverMethod) + public function testGetServerRequestReadsMethod($exectedMethod, $serverMethod) { $_SERVER = [ "HTTP_HOST" => "localhost", @@ -122,7 +121,7 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase * @preserveGlobalState disabled * @dataProvider requestTargetProvider */ - public function testReadsRequestTargetFromServer($exectedRequestTarget, $serverRequestUri) + public function testGetServerRequestReadsRequestTargetFromRequest($exectedRequestTarget, $serverRequestUri) { $_SERVER = [ "HTTP_HOST" => "localhost", @@ -146,7 +145,7 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase * @covers ::getHeader * @depends testGetServerRequestReadsFromRequest */ - public function testServerRequestProvidesHeaders($request) + public function testGetServerRequestReadsHeaders($request) { /** @var ServerRequest $request */ $this->assertEquals(["application/json"], $request->getHeader("Accept")); @@ -155,7 +154,7 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase /** * @covers ::getBody */ - public function testServerRequestProvidesBody() + public function testGetServerRequestReadsBody() { $body = $this->prophesize('Psr\Http\Message\StreamInterface'); MockServerRequest::$bodyStream = $body->reveal(); @@ -163,128 +162,87 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase $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(); - $this->assertEquals([], $request->getServerParams()); + $_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" + ] + ] + ]; + } + + // ------------------------------------------------------------------------ + // Marshalling ServerRequest Information + /** * @covers ::getServerParams * @depends testGetServerRequestReadsFromRequest */ - public function testServerRequestProvidesServerParams($request) + public function testGetServerRequestReadsServerParams($request) { /** @var ServerRequest $request */ $this->assertEquals("localhost", $request->getServerParams()["HTTP_HOST"]); } - // ------------------------------------------------------------------------ - // Cookies - - /** - * @covers ::getCookieParams - */ - public function testCookieParamsIsEmptyByDefault() - { - $request = new ServerRequest(); - $this->assertEquals([], $request->getCookieParams()); - } - /** * @covers ::getCookieParams * @depends testGetServerRequestReadsFromRequest */ - public function testServerRequestProvidesCookieParams($request) + public function testGetServerRequestReadsCookieParams($request) { /** @var ServerRequest $request */ $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 * @depends testGetServerRequestReadsFromRequest */ - public function testServerRequestProvidesQueryParams($request) + public function testGetServerRequestReadsQueryParams($request) { /** @var ServerRequest $request */ $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 ::readUploadedFiles @@ -293,7 +251,7 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase * @preserveGlobalState disabled * @dataProvider uploadedFileProvider */ - public function testGetServerRequestProvidesUploadedFiles($file, $path) + public function testGetServerRequestReadsUploadedFiles($file, $path) { $_SERVER = [ "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 ::isValidUploadedFilesBranch @@ -414,7 +503,7 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase * @covers ::isValidUploadedFilesBranch * @dataProvider validUploadedFilesProvider */ - public function testWithUploadedFilesReturnsPassedUploadedFiles($uploadedFiles) + public function testWithUploadedFilesStoresPassedUploadedFiles($uploadedFiles) { $request = new ServerRequest(); $request = $request->withUploadedFiles($uploadedFiles); @@ -524,41 +613,12 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase /** * @covers ::getParsedBody */ - public function testParsedBodyIsNullByDefault() + public function testGetParsedBodyReturnsNullByDefault() { $request = new ServerRequest(); $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 * @depends testGetServerRequestReadsFromRequest @@ -618,20 +678,23 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase /** * @covers ::getAttributes */ - public function testAttributesIsEmptyByDefault() + public function testGetAttributesReturnsEmptyArrayByDefault() { $request = new ServerRequest(); $this->assertEquals([], $request->getAttributes()); } /** - * @covers ::getAttribute - * @depends testGetServerRequestReadsFromRequest + * @covers ::getAttributes */ - public function testServerRequestProvidesAttributesIfPassed($request) + public function testGetAttributesReturnsAllAttributes() { - /** @var ServerRequest $request */ - $this->assertEquals("Claude", $request->getAttribute("guinea_pig")); + $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"]); } /** @@ -689,70 +752,6 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase $this->assertEquals("Bear", $request->getAttribute("dog")); $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" - ] - ] - ]; - } } // ---------------------------------------------------------------------------- diff --git a/test/tests/unit/Message/StreamTest.php b/test/tests/unit/Message/StreamTest.php index 17a7358..287a386 100644 --- a/test/tests/unit/Message/StreamTest.php +++ b/test/tests/unit/Message/StreamTest.php @@ -5,6 +5,7 @@ namespace WellRESTed\Test\Message; use WellRESTed\Message\Stream; /** + * @coversDefaultClass WellRESTed\Message\Stream * @uses WellRESTed\Message\Stream */ 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() { @@ -41,7 +42,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::__construct() + * @covers ::__construct * @expectedException \InvalidArgumentException * @dataProvider invalidResourceProvider */ @@ -61,7 +62,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::__toString() + * @covers ::__toString */ public function testCastsToString() { @@ -70,7 +71,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::close() + * @covers ::close */ public function testClosesHandle() { @@ -80,7 +81,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::detach() + * @covers ::detach */ public function testDetachReturnsHandle() { @@ -89,7 +90,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::detach() + * @covers ::detach */ public function testDetachUnsetsInstanceVariable() { @@ -99,7 +100,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::getSize + * @covers ::getSize */ public function testReturnsSize() { @@ -108,7 +109,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::tell + * @covers ::tell */ public function testTellReturnsHandlePosition() { @@ -118,7 +119,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::eof + * @covers ::eof */ public function testReturnsOef() { @@ -130,7 +131,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::isSeekable + * @covers ::isSeekable */ public function testReadsSeekableStatusFromMetadata() { @@ -141,7 +142,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::seek + * @covers ::seek */ public function testSeeksToPosition() { @@ -151,7 +152,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::rewind + * @covers ::rewind */ public function testRewindReturnsToBeginning() { @@ -162,7 +163,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::write + * @covers ::write */ public function testWritesToHandle() { @@ -173,7 +174,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::write + * @covers ::write * @expectedException \RuntimeException */ public function testThrowsExceptionOnErrorWriting() @@ -185,7 +186,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::read + * @covers ::read * @expectedException \RuntimeException */ public function testThrowsExceptionOnErrorReading() @@ -197,7 +198,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::read + * @covers ::read */ public function testReadsFromStream() { @@ -208,7 +209,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::getContents + * @covers ::getContents * @expectedException \RuntimeException */ public function testThrowsExceptionOnErrorReadingToEnd() @@ -220,7 +221,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::getContents + * @covers ::getContents */ public function testReadsToEnd() { @@ -231,7 +232,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::getMetadata + * @covers ::getMetadata */ public function testReturnsMetadataArray() { @@ -240,7 +241,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::getMetadata + * @covers ::getMetadata */ public function testReturnsMetadataItem() { @@ -250,7 +251,7 @@ class StreamTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Stream::isReadable + * @covers ::isReadable * @dataProvider modeProvider */ 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 */ public function testReturnsIsWritableForWritableStreams($mode, $readable, $writeable) diff --git a/test/tests/unit/Message/UriTest.php b/test/tests/unit/Message/UriTest.php index be14261..2e5e6e8 100644 --- a/test/tests/unit/Message/UriTest.php +++ b/test/tests/unit/Message/UriTest.php @@ -5,6 +5,7 @@ namespace WellRESTed\Test\Message; use WellRESTed\Message\Uri; /** + * @coversDefaultClass WellRESTed\Message\Uri * @uses WellRESTed\Message\Uri */ class UriTest extends \PHPUnit_Framework_TestCase @@ -13,7 +14,7 @@ class UriTest extends \PHPUnit_Framework_TestCase // Scheme /** - * @covers WellRESTed\Message\Uri::getScheme + * @covers ::getScheme */ public function testDefaultSchemeIsEmpty() { @@ -22,7 +23,7 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::withScheme + * @covers ::withScheme * @dataProvider schemeProvider * @param string $expected The expected result of getScheme * @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 */ public function testInvalidSchemeThrowsException() @@ -60,7 +61,7 @@ class UriTest extends \PHPUnit_Framework_TestCase // Authority /** - * @covers WellRESTed\Message\Uri::getAuthority + * @covers ::getAuthority */ public function testDefaultAuthorityIsEmpty() { @@ -68,13 +69,13 @@ class UriTest extends \PHPUnit_Framework_TestCase $this->assertSame("", $uri->getAuthority()); } - public function testRespectsMyAuthoritai() + public function testRespectsMyAuthoritah() { $this->assertTrue(true); } /** - * @covers WellRESTed\Message\Uri::getAuthority + * @covers ::getAuthority * @dataProvider authorityProvider * @param string $expected * @param array $components @@ -187,7 +188,7 @@ class UriTest extends \PHPUnit_Framework_TestCase // User Info /** - * @covers WellRESTed\Message\Uri::getUserInfo + * @covers ::getUserInfo */ public function testDefaultUserInfoIsEmpty() { @@ -196,8 +197,8 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::getUserInfo - * @covers WellRESTed\Message\Uri::withUserInfo + * @covers ::getUserInfo + * @covers ::withUserInfo * @dataProvider userInfoProvider * * @param string $expected The combined user:password value @@ -226,7 +227,7 @@ class UriTest extends \PHPUnit_Framework_TestCase // Host /** - * @covers WellRESTed\Message\Uri::getHost + * @covers ::getHost */ public function testDefaultHostIsEmpty() { @@ -235,8 +236,8 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::getHost - * @covers WellRESTed\Message\Uri::withHost + * @covers ::getHost + * @covers ::withHost * @dataProvider hostProvider * @param $expected * @param $host @@ -259,7 +260,7 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::withHost + * @covers ::withHost * @expectedException \InvalidArgumentException * @dataProvider invalidHostProvider * @param $host @@ -283,7 +284,7 @@ class UriTest extends \PHPUnit_Framework_TestCase // Port /** - * @covers WellRESTed\Message\Uri::getPort + * @covers ::getPort */ public function testDefaultPortWithNoSchemeIsNull() { @@ -292,7 +293,7 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::getPort + * @covers ::getPort */ public function testDefaultPortForHttpSchemeIs80() { @@ -301,7 +302,7 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::getPort + * @covers ::getPort */ public function testDefaultPortForHttpsSchemeIs443() { @@ -310,8 +311,8 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::getPort - * @covers WellRESTed\Message\Uri::withPort + * @covers ::getPort + * @covers ::withPort * @dataProvider portAndSchemeProvider * * @param int|null $expectedPort @@ -338,7 +339,7 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::withPort + * @covers ::withPort * @expectedException \InvalidArgumentException * @dataProvider invalidPortProvider * @param int $port @@ -363,7 +364,7 @@ class UriTest extends \PHPUnit_Framework_TestCase // Path /** - * @covers WellRESTed\Message\Uri::getPath + * @covers ::getPath */ public function testDefaultPathIsEmpty() { @@ -372,9 +373,9 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::getPath - * @covers WellRESTed\Message\Uri::withPath - * @covers WellRESTed\Message\Uri::percentEncode + * @covers ::getPath + * @covers ::withPath + * @covers ::percentEncode * @dataProvider pathProvider * @param $expected * @param $path @@ -387,9 +388,9 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::getPath - * @covers WellRESTed\Message\Uri::withPath - * @covers WellRESTed\Message\Uri::percentEncode + * @covers ::getPath + * @covers ::withPath + * @covers ::percentEncode * @dataProvider pathProvider * @param $expected * @param $path @@ -419,7 +420,7 @@ class UriTest extends \PHPUnit_Framework_TestCase // Query /** - * @covers WellRESTed\Message\Uri::getQuery + * @covers ::getQuery */ public function testDefaultQueryIsEmpty() { @@ -428,9 +429,9 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::getQuery - * @covers WellRESTed\Message\Uri::withQuery - * @covers WellRESTed\Message\Uri::percentEncode + * @covers ::getQuery + * @covers ::withQuery + * @covers ::percentEncode * @dataProvider queryProvider * @param $expected * @param $query @@ -443,9 +444,9 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::getQuery - * @covers WellRESTed\Message\Uri::withQuery - * @covers WellRESTed\Message\Uri::percentEncode + * @covers ::getQuery + * @covers ::withQuery + * @covers ::percentEncode * @dataProvider queryProvider * @param $expected * @param $query @@ -468,7 +469,7 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::withPath + * @covers ::withPath * @expectedException \InvalidArgumentException * @dataProvider invalidPathProvider * @param $path @@ -492,7 +493,7 @@ class UriTest extends \PHPUnit_Framework_TestCase // Fragment /** - * @covers WellRESTed\Message\Uri::getFragment + * @covers ::getFragment */ public function testDefaultFragmentIsEmpty() { @@ -501,9 +502,9 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::getFragment - * @covers WellRESTed\Message\Uri::withFragment - * @covers WellRESTed\Message\Uri::percentEncode + * @covers ::getFragment + * @covers ::withFragment + * @covers ::percentEncode * @dataProvider fragmentProvider * @param $expected * @param $fragment @@ -516,9 +517,9 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::getFragment - * @covers WellRESTed\Message\Uri::withFragment - * @covers WellRESTed\Message\Uri::percentEncode + * @covers ::getFragment + * @covers ::withFragment + * @covers ::percentEncode * @dataProvider fragmentProvider * @param $expected * @param $fragment @@ -544,7 +545,7 @@ class UriTest extends \PHPUnit_Framework_TestCase // Concatenation /** - * @covers WellRESTed\Message\Uri::__toString + * @covers ::__toString * @dataProvider componentProvider * @param string $expected * @param array $components @@ -652,8 +653,8 @@ class UriTest extends \PHPUnit_Framework_TestCase } /** - * @covers WellRESTed\Message\Uri::__construct() - * @covers WellRESTed\Message\Uri::__toString() + * @covers ::__construct() + * @covers ::__toString() * @dataProvider stringUriProvider */ public function testUriCreatedFromStringNormalizesString($expected, $input)