Adds a test for null-template scenes.
This commit is contained in:
@@ -31,9 +31,12 @@ class ViewpointRestorationTest extends CoreModelTestCase
|
||||
return $actionGroup;
|
||||
}
|
||||
|
||||
protected function getViewpoint()
|
||||
protected function getViewpoint($useNullTemplate = false)
|
||||
{
|
||||
$sceneTemplateMock = $this->createMock(SceneTemplate::class);
|
||||
$sceneTemplateMock = null;
|
||||
if ($useNullTemplate === false) {
|
||||
$sceneTemplateMock = $this->createMock(SceneTemplate::class);
|
||||
}
|
||||
|
||||
$sceneMock = $this->createMock(Scene::class);
|
||||
$sceneMock->method("getTitle")->willReturn("Scene Mock Title");
|
||||
@@ -55,9 +58,12 @@ class ViewpointRestorationTest extends CoreModelTestCase
|
||||
return [$entityManager, $viewpoint];
|
||||
}
|
||||
|
||||
protected function getAlternativeViewpoint()
|
||||
protected function getAlternativeViewpoint($useNullTemplate = false)
|
||||
{
|
||||
$sceneTemplateMock = $this->createMock(SceneTemplate::class);
|
||||
$sceneTemplateMock = null;
|
||||
if ($useNullTemplate === false) {
|
||||
$sceneTemplateMock = $this->createMock(SceneTemplate::class);
|
||||
}
|
||||
|
||||
$sceneMock = $this->createMock(Scene::class);
|
||||
$sceneMock->method("getTitle")->willReturn("Another Scene Mock Title");
|
||||
@@ -93,4 +99,22 @@ class ViewpointRestorationTest extends CoreModelTestCase
|
||||
$this->assertSame($viewpoint->getData(), $newViewpoint->getData());
|
||||
$this->assertSame($viewpoint->getAttachments(), $newViewpoint->getAttachments());
|
||||
}
|
||||
|
||||
public function testIfViewpointAfterUnserializationIsEqualToBeforeItsSerializationWhenTemplateIsNull()
|
||||
{
|
||||
[$entityManager, $viewpoint] = $this->getViewpoint(useNullTemplate: true);
|
||||
$viewpointRestoration = $viewpoint->getSnapshot();
|
||||
$serialized = serialize($viewpointRestoration);
|
||||
$viewpointRestored = unserialize($serialized);
|
||||
|
||||
[$entityManager2, $newViewpoint] = $this->getAlternativeViewpoint(useNullTemplate: true);
|
||||
$newViewpoint->changeFromSnapshot($entityManager, $viewpointRestored);
|
||||
|
||||
$this->assertSame($viewpoint->getTitle(), $newViewpoint->getTitle());
|
||||
$this->assertSame($viewpoint->getDescription(), $newViewpoint->getDescription());
|
||||
$this->assertSame($viewpoint->getTemplate(), $newViewpoint->getTemplate());
|
||||
$this->assertEquals($viewpoint->getActionGroups(), $newViewpoint->getActionGroups());;
|
||||
$this->assertSame($viewpoint->getData(), $newViewpoint->getData());
|
||||
$this->assertSame($viewpoint->getAttachments(), $newViewpoint->getAttachments());
|
||||
}
|
||||
}
|
||||
@@ -32,10 +32,18 @@ scenes:
|
||||
title: "The Weaponry"
|
||||
description: "This is the place where you can buy awesome weapons"
|
||||
template: "lotgd/tests/weaponry"
|
||||
|
||||
-
|
||||
id: "30000000-0000-0000-0000-000000000004"
|
||||
title: "Template-less scene"
|
||||
description: "This scene does not have a template"
|
||||
scene_connections:
|
||||
-
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000001"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000002"
|
||||
-
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000001"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000003"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000003"
|
||||
-
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000001"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000004"
|
||||
Reference in New Issue
Block a user