Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
satrun77 committed Sep 9, 2022
1 parent 4023774 commit 9529cba
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions tests/DataObject/DataObjectDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public function testSubsiteDataObjectShouldIndex(): void
// Mocked indexes:
// - index0: allows all data without subsite filter
// - index1: for subsite2 and Page class and Data object that does not implement subsite
// - index2: for subsite2 and Data object that does not implement subsite
$config->set(
'indexes',
[
Expand All @@ -199,6 +200,13 @@ public function testSubsiteDataObjectShouldIndex(): void
'includeClasses' => [
Page::class => true,
DataObjectFake::class => true,
DataObjectFakeVersioned::class => true,
],
],
'index2' => [
'subsite_id' => $subsite2->ID,
'includeClasses' => [
DataObjectFake::class => true,
],
],
]
Expand Down Expand Up @@ -239,14 +247,32 @@ public function testSubsiteDataObjectShouldIndex(): void
$this->assertTrue($doc3->shouldIndex());

// Get an object without subsite filter
$object = $this->objFromFixture(DataObjectFake::class, 'one');
$object1 = $this->objFromFixture(DataObjectFake::class, 'one');

// Prepare object for index
$doc4 = DataObjectDocument::create($object);
$doc4 = DataObjectDocument::create($object1);

// Assert that the object without subsite ID and that it can be indexed, because configuration allows it
$this->assertNull($object->SubsiteID);
$this->assertNull($object1->SubsiteID);
$this->assertTrue($doc4->shouldIndex());
$this->assertArrayHasKey('index1', $doc4->getIndexes());
$this->assertArrayHasKey('index2', $doc4->getIndexes());
$this->assertArrayNotHasKey('index0', $doc4->getIndexes());

// Get an object without subsite filter
$object2 = $this->objFromFixture(DataObjectFakeVersioned::class, 'one');
$object2->publishRecursive();
$object2 = $this->objFromFixture(DataObjectFakeVersioned::class, 'one');

// Prepare object for index
$doc5 = DataObjectDocument::create($object2);

// Assert that the object without subsite ID and that it can be indexed, because configuration allows it
$this->assertNull($object2->SubsiteID);
$this->assertTrue($doc5->shouldIndex());
$this->assertArrayHasKey('index1', $doc5->getIndexes());
$this->assertArrayNotHasKey('index2', $doc5->getIndexes());
$this->assertArrayNotHasKey('index0', $doc5->getIndexes());
}

public function testMarkIndexed(): void
Expand Down

0 comments on commit 9529cba

Please sign in to comment.