diff --git a/src/Handler/TagHandler.php b/src/Handler/TagHandler.php index 6aa506ec..cf03cd63 100644 --- a/src/Handler/TagHandler.php +++ b/src/Handler/TagHandler.php @@ -77,9 +77,19 @@ public function getTagsHeaderValue() } /** - * Add tags to be sent. + * Check whether the tag handler has any tags to set on the response. * - * This must be called before any response is sent to the client. + * @return bool True if this handler will set at least one tag. + */ + public function hasTags() + { + return 0 < count($this->tags); + } + + /** + * Add tags to be set on the response. + * + * This must be called before any HTTP response is sent to the client. * * @param array $tags List of tags to add. * diff --git a/tests/Unit/Handler/TagHandlerTest.php b/tests/Unit/Handler/TagHandlerTest.php index f21b4781..ac56be2e 100644 --- a/tests/Unit/Handler/TagHandlerTest.php +++ b/tests/Unit/Handler/TagHandlerTest.php @@ -90,7 +90,9 @@ public function testTagResponse() ->getMock(); $tagHandler = new TagHandler($cacheInvalidator); + $this->assertFalse($tagHandler->hasTags()); $tagHandler->addTags(array('post-1', 'test,post')); + $this->assertTrue($tagHandler->hasTags()); $this->assertEquals('post-1,test_post', $tagHandler->getTagsHeaderValue()); } }