Skip to content

Commit

Permalink
Adding TagHandler::hasTags method
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed May 8, 2015
1 parent 93803c6 commit 0703555
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Handler/TagHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Handler/TagHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 0703555

Please sign in to comment.