Skip to content

Commit

Permalink
Trying test DataObjectDocumentTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Anthony Adriano committed May 13, 2022
1 parent bfac7dc commit c500f1d
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions tests/DataObject/DataObjectDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
namespace SilverStripe\SearchService\Tests\DataObject;

use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\RelationList;
use SilverStripe\SearchService\DataObject\DataObjectDocument;
use SilverStripe\SearchService\Exception\IndexConfigurationException;
use SilverStripe\SearchService\Extensions\SearchServiceExtension;
use SilverStripe\SearchService\Interfaces\DocumentAddHandler;
use SilverStripe\SearchService\Interfaces\DocumentRemoveHandler;
use SilverStripe\SearchService\Schema\Field;
Expand Down Expand Up @@ -91,22 +93,24 @@ public function testSubsiteShouldIndex()
{
$config = $this->mockConfig();

Config::modify()->merge(
IndexConfiguration::class,
$config->set(
'indexes',
[
'index4' => [
'index0' => [
'subsite_id' => 0,
'includeClasses' => [
VersionedDataObjectFake::class => true
]
],
'index1' => [
'subsite_id' => 1,
'includeClasses' => [
DataObjectFake::class => true
]
],
]
);

$classes = $config->getSearchableBaseClasses();
$this->assertCount(1, $classes);
$this->assertContains(VersionedDataObjectFake::class, $classes);

/** @var Versioned $dataobject */
$dataobject = new VersionedDataObjectFake([
'ID' => 5,
Expand Down Expand Up @@ -200,24 +204,24 @@ public function testToArray()
// of a method, e.g. getMyArray(): array, so it isn't coerced into a DBField.


// // exceptions
// $config->set('getFieldsForClass', [
// DataObjectFake::class => [
// new Field('customgettermap', 'CustomGetterMap'),
// ]
// ]);
// $this->expectException(IndexConfigurationException::class);
// $this->expectExceptionMessageRegExp('/associative/');
// $doc->toArray();
//
// $this->expectException(IndexConfigurationException::class);
// $this->expectExceptionMessageRegExp('/non scalar/');
// $config->set('getFieldsForClass', [
// DataObjectFake::class => [
// new Field('customgettermixed', 'CustomGetterMixedArray'),
// ]
// ]);
// $doc->toArray();
// // exceptions
// $config->set('getFieldsForClass', [
// DataObjectFake::class => [
// new Field('customgettermap', 'CustomGetterMap'),
// ]
// ]);
// $this->expectException(IndexConfigurationException::class);
// $this->expectExceptionMessageRegExp('/associative/');
// $doc->toArray();
//
// $this->expectException(IndexConfigurationException::class);
// $this->expectExceptionMessageRegExp('/non scalar/');
// $config->set('getFieldsForClass', [
// DataObjectFake::class => [
// new Field('customgettermixed', 'CustomGetterMixedArray'),
// ]
// ]);
// $doc->toArray();

$this->expectException(IndexConfigurationException::class);
$this->expectExceptionMessageRegExp('/DataObject or RelationList/');
Expand Down

0 comments on commit c500f1d

Please sign in to comment.