silverstripe-fulltextsearch/tests/SolrIndexVersionedTest/SolrDocumentMatcher.php
2017-04-21 13:18:37 +12:00

40 lines
848 B
PHP

<?php
namespace SilverStripe\FullTextSearch\Tests\SolrVersionedTest;
if (!class_exists('Phockito')) {
return;
}
Phockito::include_hamcrest(false);
class SolrDocumentMatcher extends Hamcrest_BaseMatcher
{
protected $properties;
public function __construct($properties)
{
$this->properties = $properties;
}
public function describeTo(\Hamcrest_Description $description)
{
$description->appendText('Apache_Solr_Document with properties '.var_export($this->properties, true));
}
public function matches($item)
{
if (! ($item instanceof Apache_Solr_Document)) {
return false;
}
foreach ($this->properties as $key => $value) {
if ($item->{$key} != $value) {
return false;
}
}
return true;
}
}