2017-04-21 03:18:37 +02:00
|
|
|
<?php
|
|
|
|
|
2017-04-26 12:52:20 +02:00
|
|
|
namespace SilverStripe\FullTextSearch\Tests\SolrIndexVersionedTest;
|
2017-04-21 03:18:37 +02:00
|
|
|
|
2017-04-26 12:52:20 +02:00
|
|
|
if (!class_exists('\Phockito')) {
|
2017-04-21 03:18:37 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-26 12:52:20 +02:00
|
|
|
\Phockito::include_hamcrest(false);
|
2017-04-21 03:18:37 +02:00
|
|
|
|
2017-04-26 12:52:20 +02:00
|
|
|
class SolrDocumentMatcher extends \Hamcrest_BaseMatcher
|
2017-04-21 03:18:37 +02:00
|
|
|
{
|
|
|
|
protected $properties;
|
|
|
|
|
|
|
|
public function __construct($properties)
|
|
|
|
{
|
|
|
|
$this->properties = $properties;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function describeTo(\Hamcrest_Description $description)
|
|
|
|
{
|
2017-04-22 11:25:41 +02:00
|
|
|
$description->appendText('\Apache_Solr_Document with properties '.var_export($this->properties, true));
|
2017-04-21 03:18:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function matches($item)
|
|
|
|
{
|
2017-04-22 11:25:41 +02:00
|
|
|
if (! ($item instanceof \Apache_Solr_Document)) {
|
2017-04-21 03:18:37 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($this->properties as $key => $value) {
|
|
|
|
if ($item->{$key} != $value) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|