Implemented Character->getCharacterModel()

This commit is contained in:
Basilius Sauter
2016-04-25 19:25:25 +02:00
parent 7590247f89
commit 6edd4cf9b1
6 changed files with 152 additions and 14 deletions
+3 -3
View File
@@ -8,9 +8,7 @@ use LotGD\Core\Models\CharacterProperty;
use LotGD\Core\Tests\ModelTestCase;
/**
* Description of CharacterModelTest
*
* @author Basilius Sauter
* Tests the management of Characters
*/
class CharacterModelTest extends ModelTestCase {
/** @var string default data set */
@@ -65,6 +63,8 @@ class CharacterModelTest extends ModelTestCase {
$characterEntity->save($em);
$this->assertInternalType("int", $characterEntity->getId());
$em->flush();
}
/**
+31
View File
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Tests\Models;
use LotGD\Core\Models\Character;
use LotGD\Core\Models\CharacterScene;
use LotGD\Core\Tests\ModelTestCase;
/**
* Tests the management of CharacterScenes
*/
class CharacterSceneModelTest extends ModelTestCase
{
/** @var string default data set */
protected $dataset = "characterScenes";
public function testGetters() {
$em = $this->getEntityManager();
$testCharacter = $em->getRepository(Character::class)->find(2);
$this->assertSame(2, $testCharacter->getId());
$characterScene = $testCharacter->getCharacterScene($em);
/*$this->assertInstanceOf(CharacterScene::class, $characterScene);
$this->assertSame("The Village", $characterScene->getTitle());
$this->assertSame("This is the village.", $characterScene->getDescription());*/
$em->flush();
}
}
+7 -1
View File
@@ -7,7 +7,7 @@ use LotGD\Core\Models\Scene;
use LotGD\Core\Tests\ModelTestCase;
/**
* Description of CharacterModelTest
* Tests for creating scenes and moving them around.
*/
class SceneModelTest extends ModelTestCase
{
@@ -27,6 +27,8 @@ class SceneModelTest extends ModelTestCase
$this->assertInstanceOf(Scene::class, $scene->getParent());
$this->assertEquals(true, $scene->hasParent());
$this->assertEquals(false, $scene->hasChildren());
$em->flush();
}
/**
@@ -41,6 +43,8 @@ class SceneModelTest extends ModelTestCase
$this->assertEquals($parentScene, $childScene->getParent());
$this->assertContains($childScene, $parentScene->getChildren());
$em->flush();
}
/**
@@ -81,5 +85,7 @@ class SceneModelTest extends ModelTestCase
$this->assertEquals(false, $orphanScene->hasParent());
$this->assertNotContains($orphanScene, $parentScene1->getChildren());
$this->assertNotContains($orphanScene, $parentScene2->getChildren());
$em->flush();
}
}
+33
View File
@@ -0,0 +1,33 @@
characters:
-
id: 1
name: "Char without a Scene"
displayName: "A"
-
id: 2
name: "Char with a Scene"
displayName: "B"
character_scenes:
-
owner_id: 2
title: "The Village"
description: "This is the village."
data: "a:0:{}"
attachements: "a:0:{}"
actions: "a:0:{}"
scenes:
-
id: 1
title: "The Village"
description: "This is the village."
parent:
-
id: 2
title: "The Forest"
description: "This is a very dangerous and dark forest"
parent: 1
-
id: 3
title: "The Weaponry"
description: "This is the place where you can buy awesome weapons"
parent: 1