Skip to content

Adding TagHandler::hasTags method #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}