mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
40 lines
858 B
PHP
40 lines
858 B
PHP
<?php
|
|
|
|
namespace SilverStripe\FullTextSearch\Tests\SolrIndexVersionedTest;
|
|
|
|
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;
|
|
}
|
|
}
|