Skip to content

Commit

Permalink
Add unit test for ::from
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianallgeier committed Jun 25, 2024
1 parent 17cf412 commit 50e5daf
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/Content/ContentStorageHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,50 @@ public function testDynamicVersionsForUser()
$this->assertSame(VersionId::PUBLISHED, $versions[1]->value());
}

/**
* @covers ::from
*/
public function testFrom()
{
$this->setUpMultiLanguage();

$handlerA = new PlainTextContentStorageHandler(
model: $this->model
);

$versionPublished = VersionId::published();
$versionChanges = VersionId::changes();

$en = $this->app->language('en');
$de = $this->app->language('de');

// create all possible versions
$handlerA->create($versionPublished, $en, $publishedEN = [
'title' => 'Published EN'
]);

$handlerA->create($versionPublished, $de, $publishedDE = [
'title' => 'Published DE'
]);

$handlerA->create($versionChanges, $en, $changesEN = [
'title' => 'Changes EN'
]);

$handlerA->create($versionChanges, $de, $changesDE = [
'title' => 'Changes DE'
]);

// create a new handler with all the versions from the first one
$handlerB = TestContentStorageHandler::from($handlerA);

$this->assertSame($publishedEN, $handlerB->read($versionPublished, $en));
$this->assertSame($publishedDE, $handlerB->read($versionPublished, $de));

$this->assertSame($changesEN, $handlerB->read($versionChanges, $en));
$this->assertSame($changesDE, $handlerB->read($versionChanges, $de));
}

/**
* @covers ::model
*/
Expand Down

0 comments on commit 50e5daf

Please sign in to comment.