Skip to content

Commit

Permalink
Revert back to checking isLiveVersion. Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Penny committed Aug 15, 2022
1 parent 5a27c41 commit 284c171
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/DataObject/DataObjectDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function shouldIndex(): bool
}

// Dataobject is only in draft
if ($dataObject->hasExtension(Versioned::class) && !$dataObject->isPublished()) {
if ($dataObject->hasExtension(Versioned::class) && !$dataObject->isLiveVersion()) {
return false;
}

Expand Down
27 changes: 16 additions & 11 deletions tests/DataObject/DataObjectDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,27 @@ public function testShouldIndex(): void
$dataObjectTwo = $this->objFromFixture(DataObjectFakeVersioned::class, 'two');
$dataObjectThree = $this->objFromFixture(DataObjectFakePrivate::class, 'one');

// Make sure both Versioned DOs are published
// DocOne and Two represent DOs that have not yet been published
$docOne = DataObjectDocument::create($dataObjectOne);
$docTwo = DataObjectDocument::create($dataObjectTwo);
$docThree = DataObjectDocument::create($dataObjectThree);

// All should be unavailable to index initially
$this->assertFalse($docOne->shouldIndex());
$this->assertFalse($docTwo->shouldIndex());
$this->assertFalse($docThree->shouldIndex());

// Make sure both Versioned DOs are now published
$dataObjectOne->publishRecursive();
$dataObjectTwo->publishRecursive();

// Need to re-fetch these DOs as their Versioned data will have changes
$dataObjectOne = $this->objFromFixture(DataObjectFakeVersioned::class, 'one');
$dataObjectTwo = $this->objFromFixture(DataObjectFakeVersioned::class, 'two');

// Recreate the Documents as well
$docOne = DataObjectDocument::create($dataObjectOne);
$docTwo = DataObjectDocument::create($dataObjectTwo);
$docThree = DataObjectDocument::create($dataObjectThree);

$config->set('getIndexesForDocument', [
$docOne->getIdentifier() => [
Expand All @@ -79,15 +93,6 @@ public function testShouldIndex(): void
$this->assertFalse($docTwo->shouldIndex());
// Document three should NOT be indexable (canView(): false)
$this->assertFalse($docThree->shouldIndex());

// Now test that unpublishing makes them unavailable to index
$dataObjectOne->doUnpublish();
$dataObjectTwo->doUnpublish();

// All should now be unavailable to index
$this->assertFalse($docOne->shouldIndex());
$this->assertFalse($docTwo->shouldIndex());
$this->assertFalse($docThree->shouldIndex());
}

public function testMarkIndexed(): void
Expand Down

0 comments on commit 284c171

Please sign in to comment.