1 Commits

Author SHA1 Message Date
Basilius Sauter 25341a677d Adjusted version number 2018-04-26 17:31:42 +02:00
37 changed files with 432 additions and 840 deletions
+2 -3
View File
@@ -2,7 +2,7 @@
"name": "lotgd/core", "name": "lotgd/core",
"description": "Core functionality for Legend of the Green Dragon, a text-based RPG game.", "description": "Core functionality for Legend of the Green Dragon, a text-based RPG game.",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"version": "0.5.0", "version": "0.4.1",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"LotGD\\Core\\": "src/", "LotGD\\Core\\": "src/",
@@ -20,8 +20,7 @@
"monolog/monolog": "^1.12", "monolog/monolog": "^1.12",
"symfony/console": "^3.0", "symfony/console": "^3.0",
"symfony/yaml": "^3.0", "symfony/yaml": "^3.0",
"d11wtq/boris": "^1.0", "d11wtq/boris": "^1.0"
"ramsey/uuid-doctrine": "^1.5"
}, },
"repositories": [ "repositories": [
{ {
Generated
+157 -407
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -20,7 +20,7 @@ class Action
* @param string|null $title * @param string|null $title
* @param array $parameters * @param array $parameters
*/ */
public function __construct(string $destinationSceneId, ?string $title = null, array $parameters = []) public function __construct(int $destinationSceneId, ?string $title = null, array $parameters = [])
{ {
$this->id = bin2hex(random_bytes(8)); $this->id = bin2hex(random_bytes(8));
$this->destinationSceneId = $destinationSceneId; $this->destinationSceneId = $destinationSceneId;
@@ -43,7 +43,7 @@ class Action
* go if they take this action. * go if they take this action.
* @return int * @return int
*/ */
public function getDestinationSceneId(): string public function getDestinationSceneId(): int
{ {
return $this->destinationSceneId; return $this->destinationSceneId;
} }
-6
View File
@@ -6,7 +6,6 @@ namespace LotGD\Core;
use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\EventManager as DoctrineEventManager; use Doctrine\Common\EventManager as DoctrineEventManager;
use Doctrine\Common\Util\Debug; use Doctrine\Common\Util\Debug;
use Doctrine\DBAL\DBALException;
use Doctrine\ORM\Events as DoctrineEvents; use Doctrine\ORM\Events as DoctrineEvents;
use Doctrine\ORM\ { use Doctrine\ORM\ {
EntityManager, EntityManager,
@@ -174,11 +173,6 @@ class Bootstrap
// Create entity manager // Create entity manager
$entityManager = EntityManager::create(["pdo" => $pdo], $configuration); $entityManager = EntityManager::create(["pdo" => $pdo], $configuration);
// Register uuid type
try {
\Doctrine\DBAL\Types\Type::addType('uuid', 'Ramsey\Uuid\Doctrine\UuidType');
} catch (DBALException $e) {}
// Create Schema and update database if needed // Create Schema and update database if needed
$metaData = $entityManager->getMetadataFactory()->getAllMetadata(); $metaData = $entityManager->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($entityManager); $schemaTool = new SchemaTool($entityManager);
+1 -2
View File
@@ -111,8 +111,7 @@ class EventManager
'class' => $class, 'class' => $class,
'library' => $library 'library' => $library
]); ]);
$e->save($this->g->getEntityManager());
$this->g->getEntityManager()->persist($e);
} }
/** /**
+1 -1
View File
@@ -60,7 +60,7 @@ class Game
*/ */
public static function getVersion(): string public static function getVersion(): string
{ {
return '0.5.0'; return '0.1.0';
} }
/** /**
+2 -12
View File
@@ -4,15 +4,13 @@ declare(strict_types=1);
namespace LotGD\Core\Models; namespace LotGD\Core\Models;
use Doctrine\ORM\Mapping\MappedSuperclass; use Doctrine\ORM\Mapping\MappedSuperclass;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/** /**
* @MappedSuperclass * @MappedSuperclass
*/ */
abstract class BasicEnemy implements FighterInterface abstract class BasicEnemy implements FighterInterface
{ {
/** @Id @Column(type="uuid", unique=True) */ /** @Id @Column(type="integer") @GeneratedValue */
protected $id; protected $id;
/** @Column(type="string", length=50); */ /** @Column(type="string", length=50); */
protected $name; protected $name;
@@ -20,20 +18,12 @@ abstract class BasicEnemy implements FighterInterface
protected $level; protected $level;
/** @var int */ /** @var int */
protected $health; protected $health;
/**
* BasicEnemy constructor. Sets uuid upon creation.
* @throws \Exception
*/
public function __construct() {
$this->id = Uuid::uuid4();
}
/** /**
* Returns the enemy's id * Returns the enemy's id
* @return int * @return int
*/ */
public function getId(): UuidInterface public function getId(): int
{ {
return $this->id; return $this->id;
} }
+6 -10
View File
@@ -7,8 +7,6 @@ use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Mapping\Table;
use LotGD\Core\Exceptions\ArgumentException; use LotGD\Core\Exceptions\ArgumentException;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/** /**
* A model representing a buff used to modify the flow of the battle. * A model representing a buff used to modify the flow of the battle.
@@ -25,7 +23,7 @@ class Buff
const ACTIVATE_NONE = 0b0000; const ACTIVATE_NONE = 0b0000;
const ACTIVATE_ANY = 0b1111; const ACTIVATE_ANY = 0b1111;
/** @Id @Column(type="uuid", unique=True) */ /** @Id @Column(type="integer") @GeneratedValue */
private $id; private $id;
/** /**
* @ManyToOne(targetEntity="Character", inversedBy="buffs") * @ManyToOne(targetEntity="Character", inversedBy="buffs")
@@ -233,7 +231,7 @@ class Buff
* Allowed buff values and their type * Allowed buff values and their type
* @var array * @var array
*/ */
private static $buffArrayTemplate = [ private $buffArrayTemplate = [
"slot" => "string", "slot" => "string",
"name" => "string", "name" => "string",
"startMessage" => "string", "startMessage" => "string",
@@ -284,15 +282,13 @@ class Buff
*/ */
public function __construct(array $buffArray) public function __construct(array $buffArray)
{ {
$this->id = Uuid::uuid4();
foreach ($buffArray as $attribute => $value) { foreach ($buffArray as $attribute => $value) {
// Throw exception if an attribute does not exist (to prevent spelling errors) // Throw exception if an attribute does not exist (to prevent spelling errors)
if (!isset(self::$buffArrayTemplate[$attribute])) { if (!isset($this->buffArrayTemplate[$attribute])) {
throw new ArgumentException("{$attribute} is not a valid key for a buff."); throw new ArgumentException("{$attribute} is not a valid key for a buff.");
} }
switch (self::$buffArrayTemplate[$attribute]) { switch ($this->buffArrayTemplate[$attribute]) {
case "string": case "string":
if (is_string($value) === false) { if (is_string($value) === false) {
throw new ArgumentException("{$attribute} needs to be a string."); throw new ArgumentException("{$attribute} needs to be a string.");
@@ -342,7 +338,7 @@ class Buff
{ {
$buffArray = []; $buffArray = [];
foreach (self::$buffArrayTemplate as $attribute => $type) { foreach ($this->buffArrayTemplate as $attribute => $type) {
$buffArray[$attribute] = $buff->$attribute; $buffArray[$attribute] = $buff->$attribute;
} }
@@ -353,7 +349,7 @@ class Buff
* Returns the id of the buff * Returns the id of the buff
* @return int * @return int
*/ */
public function getId(): UuidInterface public function getId(): int
{ {
return $this->id; return $this->id;
} }
+2 -6
View File
@@ -17,8 +17,6 @@ use LotGD\Core\Exceptions\BuffSlotOccupiedException;
use LotGD\Core\Tools\Model\{ use LotGD\Core\Tools\Model\{
Creator, ExtendableModel, GameAware, PropertyManager, SoftDeletable Creator, ExtendableModel, GameAware, PropertyManager, SoftDeletable
}; };
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/** /**
* Model for a character * Model for a character
@@ -34,7 +32,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
use GameAware; use GameAware;
use ExtendableModel; use ExtendableModel;
/** @Id @Column(type="uuid", unique=True) */ /** @Id @Column(type="integer") @GeneratedValue */
private $id; private $id;
/** @Column(type="string", length=50); */ /** @Column(type="string", length=50); */
private $name; private $name;
@@ -92,8 +90,6 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
*/ */
public function __construct() public function __construct()
{ {
$this->id = Uuid::uuid4();
$this->properties = new ArrayCollection(); $this->properties = new ArrayCollection();
$this->buffs = new ArrayCollection(); $this->buffs = new ArrayCollection();
$this->messageThreads = new ArrayCollection(); $this->messageThreads = new ArrayCollection();
@@ -103,7 +99,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
* Returns the entity's id * Returns the entity's id
* @return int The id * @return int The id
*/ */
public function getId(): UuidInterface public function getId(): int
{ {
return $this->id; return $this->id;
} }
+1 -3
View File
@@ -3,14 +3,12 @@ declare(strict_types=1);
namespace LotGD\Core\Models; namespace LotGD\Core\Models;
use Ramsey\Uuid\UuidInterface;
/** /**
* Interface for the character model and all objects that mimick such a model. * Interface for the character model and all objects that mimick such a model.
*/ */
interface CharacterInterface extends FighterInterface interface CharacterInterface extends FighterInterface
{ {
public function getId(): UuidInterface; public function getId(): int;
public function getName(): string; public function getName(): string;
public function getDisplayName(): string; public function getDisplayName(): string;
public function getHealth(): int; public function getHealth(): int;
+3
View File
@@ -39,6 +39,9 @@ class Message
private $systemMessage = false; private $systemMessage = false;
/** /**
* Constructs the message. * Constructs the message.
* Use the Message Manager methods send() and sendSystemMessage() instead. * Use the Message Manager methods send() and sendSystemMessage() instead.
+2 -5
View File
@@ -8,8 +8,6 @@ use Doctrine\ORM\Mapping\Table;
use LotGD\Core\Tools\Model\Creator; use LotGD\Core\Tools\Model\Creator;
use LotGD\Core\Tools\Model\Deletor; use LotGD\Core\Tools\Model\Deletor;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/** /**
* Model for the message of the day * Model for the message of the day
@@ -22,7 +20,7 @@ class MotD implements CreateableInterface
use Creator; use Creator;
use Deletor; use Deletor;
/** @Id @Column(type="uuid", unique=True) */ /** @Id @Column(type="integer") @GeneratedValue */
private $id; private $id;
/** /**
* @ManyToOne(targetEntity="Character", cascade={"persist"}, fetch="EAGER") * @ManyToOne(targetEntity="Character", cascade={"persist"}, fetch="EAGER")
@@ -51,7 +49,6 @@ class MotD implements CreateableInterface
*/ */
public function __construct() public function __construct()
{ {
$this->id = Uuid::uuid4();
$this->creationTime = new \DateTime("now"); $this->creationTime = new \DateTime("now");
} }
@@ -59,7 +56,7 @@ class MotD implements CreateableInterface
* Returns the entities ID * Returns the entities ID
* @return int * @return int
*/ */
public function getId(): UuidInterface public function getId(): int
{ {
return $this->id; return $this->id;
} }
@@ -43,9 +43,9 @@ class CharacterRepository extends EntityRepository
} }
/** /**
* Find a character by ID, excluding soft deleted ones. * Find a character by ID.
*/ */
public function find($id, $lockMode=null, $lockVersion=null) public function find($id, $lockMode = NULL, $lockVersion = NULL, int $deletes = self::SKIP_SOFTDELETED)
{ {
$queryBuilder = $this->getEntityManager()->createQueryBuilder(); $queryBuilder = $this->getEntityManager()->createQueryBuilder();
$queryBuilder->select("c") $queryBuilder->select("c")
@@ -53,29 +53,7 @@ class CharacterRepository extends EntityRepository
->where($queryBuilder->expr()->eq("c.id", ":id")) ->where($queryBuilder->expr()->eq("c.id", ":id"))
->setParameter("id", $id); ->setParameter("id", $id);
$this->modifyQuery($queryBuilder, self::SKIP_SOFTDELETED); $this->modifyQuery($queryBuilder, $deletes);
try {
return $queryBuilder->getQuery()->getSingleResult();
} catch (NoResultException $e) {
return null;
}
}
/**
* Finds a character id ID, including soft deleted ones.
* @param $id
* @return mixed|null
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findWithSoftDeleted($id) {
$queryBuilder = $this->getEntityManager()->createQueryBuilder();
$queryBuilder->select("c")
->from(Character::class, "c")
->where($queryBuilder->expr()->eq("c.id", ":id"))
->setParameter("id", $id);
$this->modifyQuery($queryBuilder, self::INCLUDE_SOFTDELETED);
try { try {
return $queryBuilder->getQuery()->getSingleResult(); return $queryBuilder->getQuery()->getSingleResult();
+3 -7
View File
@@ -12,8 +12,6 @@ use LotGD\Core\Exceptions\ArgumentException;
use LotGD\Core\Tools\Model\Creator; use LotGD\Core\Tools\Model\Creator;
use LotGD\Core\Tools\Model\Deletor; use LotGD\Core\Tools\Model\Deletor;
use LotGD\Core\Tools\Model\SceneBasics; use LotGD\Core\Tools\Model\SceneBasics;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/** /**
* A scene is a location within the game, such as the Village or the Tavern. Designed * A scene is a location within the game, such as the Village or the Tavern. Designed
@@ -28,8 +26,8 @@ class Scene implements CreateableInterface, SceneConnectable
use Deletor; use Deletor;
use SceneBasics; use SceneBasics;
/** @Id @Column(type="string", length=36, unique=True, name="id", options={"fixed" = true}) */ /** @Id @Column(type="integer") @GeneratedValue */
protected $id; private $id;
/** /**
* @OneToMany(targetEntity="SceneConnectionGroup", mappedBy="scene", cascade={"persist", "remove"}) * @OneToMany(targetEntity="SceneConnectionGroup", mappedBy="scene", cascade={"persist", "remove"})
@@ -63,8 +61,6 @@ class Scene implements CreateableInterface, SceneConnectable
*/ */
public function __construct() public function __construct()
{ {
$this->id = Uuid::uuid4()->toString();
$this->connectionGroups = new ArrayCollection(); $this->connectionGroups = new ArrayCollection();
$this->outgoingConnections = new ArrayCollection(); $this->outgoingConnections = new ArrayCollection();
$this->incomingConnections = new ArrayCollection(); $this->incomingConnections = new ArrayCollection();
@@ -74,7 +70,7 @@ class Scene implements CreateableInterface, SceneConnectable
* Returns the primary ID for this scene. * Returns the primary ID for this scene.
* @return int * @return int
*/ */
public function getId(): string public function getId(): int
{ {
return $this->id; return $this->id;
} }
+2 -2
View File
@@ -15,14 +15,14 @@ class SceneConnection
{ {
/** /**
* @Id * @Id
* @ManyToOne(targetEntity="Scene", inversedBy="outgoingConnections") * @ManyToOne(targetEntity="Scene")
* @JoinColumn(name="outgoingScene", referencedColumnName="id") * @JoinColumn(name="outgoingScene", referencedColumnName="id")
*/ */
private $outgoingScene; private $outgoingScene;
/** /**
* @Id * @Id
* @ManyToOne(targetEntity="Scene", inversedBy="incomingConnections") * @ManyToOne(targetEntity="Scene")
* @JoinColumn(name="incomingScene", referencedColumnName="id") * @JoinColumn(name="incomingScene", referencedColumnName="id")
*/ */
private $incomingScene; private $incomingScene;
+1 -1
View File
@@ -329,7 +329,7 @@ class Viewpoint implements CreateableInterface
* Removes any actions that correspond to a given scene ID, if present. * Removes any actions that correspond to a given scene ID, if present.
* @param int $id * @param int $id
*/ */
public function removeActionsWithSceneId(string $id) public function removeActionsWithSceneId(int $id)
{ {
foreach ($this->getActionGroups() as $group) { foreach ($this->getActionGroups() as $group) {
$actions = $group->getActions(); $actions = $group->getActions();
+4 -24
View File
@@ -42,7 +42,6 @@ class ModuleManager
{ {
$name = $library->getName(); $name = $library->getName();
$package = $library->getComposerPackage(); $package = $library->getComposerPackage();
$em = $this->g->getEntityManager();
$this->g->getLogger()->debug("Registering module {$name}..."); $this->g->getLogger()->debug("Registering module {$name}...");
@@ -54,8 +53,6 @@ class ModuleManager
$this->g->getLogger()->debug("Creating module model for {$name}"); $this->g->getLogger()->debug("Creating module model for {$name}");
$m = new ModuleModel($name); $m = new ModuleModel($name);
$em->beginTransaction();
$class = $library->getRootNamespace() . 'Module'; $class = $library->getRootNamespace() . 'Module';
try { try {
$klass = new \ReflectionClass($class); $klass = new \ReflectionClass($class);
@@ -72,16 +69,9 @@ class ModuleManager
} }
// Subscribe to the module's events. // Subscribe to the module's events.
try { $subscriptions = $library->getSubscriptionPatterns();
$subscriptions = $library->getSubscriptionPatterns(); foreach ($subscriptions as $s) {
foreach ($subscriptions as $s) { $this->g->getEventManager()->subscribe($s, $class, $name);
$this->g->getEventManager()->subscribe($s, $class, $name);
}
} catch (\Throwable $e) {
$em->rollBack();
$em->clear();
throw $e;
} }
// Run the module's onRegister handler. // Run the module's onRegister handler.
@@ -89,20 +79,10 @@ class ModuleManager
try { try {
$class::onRegister($this->g, $m); $class::onRegister($this->g, $m);
$this->g->getEntityManager()->persist($m); $m->save($this->g->getEntityManager());
$this->g->getEntityManager()->flush();
$em->commit();
return;
} catch (Throwable $e) { } catch (Throwable $e) {
$em->rollBack();
$em->clear();
$this->g->getLogger()->error("Calling {$class}::onRegister failed with exception: {$e->getMessage()}"); $this->g->getLogger()->error("Calling {$class}::onRegister failed with exception: {$e->getMessage()}");
unset($m); unset($m);
// Propagate the exception.
throw $e;
} }
} }
} }
+1 -2
View File
@@ -10,7 +10,6 @@ use LotGD\Core\{
}; };
use LotGD\Core\Exceptions\IsNullException; use LotGD\Core\Exceptions\IsNullException;
use LotGD\Core\Models\Viewpoint; use LotGD\Core\Models\Viewpoint;
use Ramsey\Uuid\UuidInterface;
/** /**
* Provides basic implementation to mock CharacterInterface. * Provides basic implementation to mock CharacterInterface.
@@ -22,7 +21,7 @@ trait MockCharacter
throw new IsNullException(); throw new IsNullException();
} }
public function getId(): UuidInterface public function getId(): int
{ {
throw new IsNullException(); throw new IsNullException();
} }
+30 -34
View File
@@ -5,7 +5,6 @@ namespace LotGD\Core\Tests\Models;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Util\Debug;
use LotGD\Core\{ use LotGD\Core\{
Battle, Battle,
DiceBag, DiceBag,
@@ -26,9 +25,6 @@ use LotGD\Core\Models\BattleEvents\{
}; };
use LotGD\Core\Tests\CoreModelTestCase; use LotGD\Core\Tests\CoreModelTestCase;
use Ramsey\Uuid\Codec\OrderedTimeCodec;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidFactory;
class BattleTest extends CoreModelTestCase class BattleTest extends CoreModelTestCase
{ {
@@ -56,8 +52,8 @@ class BattleTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $character = $em->getRepository(Character::class)->find(1);
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f"); $monster = $em->getRepository(Monster::class)->find(1);
$this->assertSame(5, $monster->getLevel()); $this->assertSame(5, $monster->getLevel());
$this->assertSame(52, $monster->getMaxHealth()); $this->assertSame(52, $monster->getMaxHealth());
@@ -73,8 +69,8 @@ class BattleTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $character = $em->getRepository(Character::class)->find(1);
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f"); $monster = $em->getRepository(Monster::class)->find(1);
$battle = new Battle($this->getMockGame($character), $character, $monster); $battle = new Battle($this->getMockGame($character), $character, $monster);
@@ -110,8 +106,8 @@ class BattleTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $character = $em->getRepository(Character::class)->find(1);
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f"); $monster = $em->getRepository(Monster::class)->find(1);
$battle = new Battle($this->getMockGame($character), $character, $monster); $battle = new Battle($this->getMockGame($character), $character, $monster);
$battle = $battle->serialize(); $battle = $battle->serialize();
@@ -143,8 +139,8 @@ class BattleTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$highLevelPlayer = $em->getRepository(Character::class)->find("4d01c29b-d825-4bc7-9e6e-63525155fd37"); $highLevelPlayer = $em->getRepository(Character::class)->find(2);
$lowLevelMonster = $em->getRepository(Monster::class)->find("c004bcb6-a7c1-4f9a-abc2-1711c64e23a0"); $lowLevelMonster = $em->getRepository(Monster::class)->find(3);
$battle = new Battle($this->getMockGame($highLevelPlayer), $highLevelPlayer, $lowLevelMonster); $battle = new Battle($this->getMockGame($highLevelPlayer), $highLevelPlayer, $lowLevelMonster);
@@ -176,8 +172,8 @@ class BattleTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$lowLevelPlayer = $em->getRepository(Character::class)->find("c3792b61-4e34-4710-9871-65a68ac30bb4"); $lowLevelPlayer = $em->getRepository(Character::class)->find(3);
$highLevelMonster = $em->getRepository(Monster::class)->find("b636df29-f72d-4e2d-9850-982e783a9e94"); $highLevelMonster = $em->getRepository(Monster::class)->find(2);
$battle = new Battle($this->getMockGame($lowLevelPlayer), $lowLevelPlayer, $highLevelMonster); $battle = new Battle($this->getMockGame($lowLevelPlayer), $lowLevelPlayer, $highLevelMonster);
@@ -209,8 +205,8 @@ class BattleTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $character = $em->getRepository(Character::class)->find(1);
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f"); $monster = $em->getRepository(Monster::class)->find(1);
$battle = new Battle($this->getMockGame($character), $character, $monster); $battle = new Battle($this->getMockGame($character), $character, $monster);
@@ -224,8 +220,8 @@ class BattleTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $character = $em->getRepository(Character::class)->find(1);
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f"); $monster = $em->getRepository(Monster::class)->find(1);
$battle = new Battle($this->getMockGame($character), $character, $monster); $battle = new Battle($this->getMockGame($character), $character, $monster);
@@ -240,8 +236,8 @@ class BattleTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $character = $em->getRepository(Character::class)->find(1);
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f"); $monster = $em->getRepository(Monster::class)->find(1);
$battle = new Battle($this->getMockGame($character), $character, $monster); $battle = new Battle($this->getMockGame($character), $character, $monster);
@@ -261,23 +257,23 @@ class BattleTest extends CoreModelTestCase
default: default:
case 0: case 0:
// Fair Battle // Fair Battle
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $character = $em->getRepository(Character::class)->find(1);
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f"); $monster = $em->getRepository(Monster::class)->find(1);
break; break;
case 1: case 1:
// very long battle // very long battle
$character = $em->getRepository(Character::class)->find("6565b418-55f5-4a6b-8d92-a9ef81329912"); $character = $em->getRepository(Character::class)->find(4);
$monster = $em->getRepository(Monster::class)->find("c004bcb6-a7c1-4f9a-abc2-1711c64e23a0"); $monster = $em->getRepository(Monster::class)->find(3);
break; break;
case 2: case 2:
// player should win battle // player should win battle
$character = $em->getRepository(Character::class)->find("1a9f63f2-3006-4e12-b272-4fd6be518a93"); $character = $em->getRepository(Character::class)->find(13);
$monster = $em->getRepository(Monster::class)->find("7ca9c141-aaf8-44a5-9d04-b6f9923f3c66"); $monster = $em->getRepository(Monster::class)->find(11);
break; break;
case 3: case 3:
// player should lose battle // player should lose battle
$character = $em->getRepository(Character::class)->find("24d71c26-f915-401c-8b3e-1932edf650ce"); $character = $em->getRepository(Character::class)->find(11);
$monster = $em->getRepository(Monster::class)->find("09540b93-63c9-4d82-8501-f569f63dfc4c"); $monster = $em->getRepository(Monster::class)->find(13);
break; break;
} }
@@ -1335,7 +1331,7 @@ class BattleTest extends CoreModelTestCase
public function testBufflistGoodguyAttackModifier() public function testBufflistGoodguyAttackModifier()
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$player = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $player = $em->getRepository(Character::class)->find(1);
$game = $this->getMockGame($player); $game = $this->getMockGame($player);
$player->addBuff(new Buff([ $player->addBuff(new Buff([
@@ -1364,7 +1360,7 @@ class BattleTest extends CoreModelTestCase
public function testBufflistGoodguyDefenseModifier() public function testBufflistGoodguyDefenseModifier()
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$player = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $player = $em->getRepository(Character::class)->find(1);
$game = $this->getMockGame($player); $game = $this->getMockGame($player);
$player->addBuff(new Buff([ $player->addBuff(new Buff([
@@ -1393,7 +1389,7 @@ class BattleTest extends CoreModelTestCase
public function testBufflistGoodguyDamageModifier() public function testBufflistGoodguyDamageModifier()
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$player = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $player = $em->getRepository(Character::class)->find(1);
$game = $this->getMockGame($player); $game = $this->getMockGame($player);
$player->addBuff(new Buff([ $player->addBuff(new Buff([
@@ -1422,7 +1418,7 @@ class BattleTest extends CoreModelTestCase
public function testBufflistBadguyAttackModifier() public function testBufflistBadguyAttackModifier()
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$player = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $player = $em->getRepository(Character::class)->find(1);
$game = $this->getMockGame($player); $game = $this->getMockGame($player);
$player->addBuff(new Buff([ $player->addBuff(new Buff([
@@ -1451,7 +1447,7 @@ class BattleTest extends CoreModelTestCase
public function testBufflistBadguyDefenseModifier() public function testBufflistBadguyDefenseModifier()
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$player = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $player = $em->getRepository(Character::class)->find(1);
$game = $this->getMockGame($player); $game = $this->getMockGame($player);
$player->addBuff(new Buff([ $player->addBuff(new Buff([
@@ -1480,7 +1476,7 @@ class BattleTest extends CoreModelTestCase
public function testBufflistBadguyDamageModifier() public function testBufflistBadguyDamageModifier()
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$player = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8"); $player = $em->getRepository(Character::class)->find(1);
$game = $this->getMockGame($player); $game = $this->getMockGame($player);
$player->addBuff(new Buff([ $player->addBuff(new Buff([
-4
View File
@@ -5,7 +5,6 @@ namespace LotGD\Core\Tests\DefectiveModule;
use LotGD\Core\Exceptions\CoreException; use LotGD\Core\Exceptions\CoreException;
use LotGD\Core\Game; use LotGD\Core\Game;
use LotGD\Core\Events\EventContext; use LotGD\Core\Events\EventContext;
use LotGD\Core\Models\Character;
use LotGD\Core\Module as ModuleInterface; use LotGD\Core\Module as ModuleInterface;
use LotGD\Core\Models\Module as ModuleModel; use LotGD\Core\Models\Module as ModuleModel;
@@ -19,9 +18,6 @@ class Module implements ModuleInterface {
public static function onRegister(Game $g, ModuleModel $module) public static function onRegister(Game $g, ModuleModel $module)
{ {
$character = Character::create(["name" => "Test"]);
$character->save($g->getEntityManager());
throw new DefectiveModuleException("Exception"); throw new DefectiveModuleException("Exception");
} }
+1 -2
View File
@@ -1,4 +1,3 @@
entityNamespace: "LotGD\\Core\\Tests\\FakeModule\\Models\\" entityNamespace: "LotGD\\Core\\Tests\\FakeModule\\Models\\"
subscriptionPatterns: subscriptionPatterns:
- "e/lotgd/core/tests/defective-event" - "e/lotgd/core/tests/event"
- "e/lotgd/core/tests/gom-event"
-1
View File
@@ -96,7 +96,6 @@ class EventManagerTest extends CoreModelTestCase
$library = 'lotgd/tests'; $library = 'lotgd/tests';
$em->subscribe($pattern, $class, $library); $em->subscribe($pattern, $class, $library);
$this->getEntityManager()->flush();
$sub = EventSubscription::create([ $sub = EventSubscription::create([
'pattern' => $pattern, 'pattern' => $pattern,
+19 -26
View File
@@ -37,16 +37,15 @@ class DefaultSceneProvider implements EventHandler
)); ));
} }
$context->setDataField("scene", $g->getEntityManager()->getRepository(Scene::class) $context->setDataField("scene", $g->getEntityManager()->getRepository(Scene::class)->find(1));
->find("30000000-0000-0000-0000-000000000001"));
break; break;
case 'h/lotgd/core/navigate-to/lotgd/tests/village': case 'h/lotgd/core/navigate-to/lotgd/tests/village':
$v = $context->getDataField('viewpoint'); $v = $context->getDataField('viewpoint');
self::$actionGroups = [new ActionGroup('default', 'Title', 0)]; self::$actionGroups = [new ActionGroup('default', 'Title', 0)];
self::$actionGroups[0]->setActions([ self::$actionGroups[0]->setActions([
new Action("30000000-0000-0000-0000-000000000002"), // This is a real sceneId in game.yml new Action(2), // This is a real sceneId in game.yml
new Action("30000000-0000-0000-0000-000000000101"), new Action(101),
]); ]);
$v->setActionGroups(self::$actionGroups); $v->setActionGroups(self::$actionGroups);
@@ -129,7 +128,7 @@ class GameTest extends CoreModelTestCase
public function testSetGetCharacter() public function testSetGetCharacter()
{ {
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $c = $this->getEntityManager()->getRepository(Character::class)->find(1);
$this->g->setCharacter($c); $this->g->setCharacter($c);
$this->assertEquals($c, $this->g->getCharacter()); $this->assertEquals($c, $this->g->getCharacter());
@@ -137,7 +136,7 @@ class GameTest extends CoreModelTestCase
public function testGetViewpointException() public function testGetViewpointException()
{ {
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $c = $this->getEntityManager()->getRepository(Character::class)->find(1);
$this->g->setCharacter($c); $this->g->setCharacter($c);
// There should'nt be any listeners to provide a default scene. // There should'nt be any listeners to provide a default scene.
@@ -147,7 +146,7 @@ class GameTest extends CoreModelTestCase
public function testGetViewpointStored() public function testGetViewpointStored()
{ {
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $c = $this->getEntityManager()->getRepository(Character::class)->find(2);
$this->g->setCharacter($c); $this->g->setCharacter($c);
$this->assertNotNull($this->g->getViewpoint()); $this->assertNotNull($this->g->getViewpoint());
@@ -155,12 +154,11 @@ class GameTest extends CoreModelTestCase
public function testGetViewpointDefault() public function testGetViewpointDefault()
{ {
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $c = $this->getEntityManager()->getRepository(Character::class)->find(1);
$this->g->setCharacter($c); $this->g->setCharacter($c);
$this->g->getEventManager()->subscribe('/h\/lotgd\/core\/default-scene/', DefaultSceneProvider::class, 'lotgd/core/tests'); $this->g->getEventManager()->subscribe('/h\/lotgd\/core\/default-scene/', DefaultSceneProvider::class, 'lotgd/core/tests');
$this->g->getEventManager()->subscribe('/h\/lotgd\/core\/navigate-to\/.*/', DefaultSceneProvider::class, 'lotgd/core/tests'); $this->g->getEventManager()->subscribe('/h\/lotgd\/core\/navigate-to\/.*/', DefaultSceneProvider::class, 'lotgd/core/tests');
$this->getEntityManager()->flush();
$v = $this->g->getViewpoint(); $v = $this->g->getViewpoint();
// Run it twice to make sure no additional DB operations happen. // Run it twice to make sure no additional DB operations happen.
@@ -177,7 +175,7 @@ class GameTest extends CoreModelTestCase
public function testTakeActionNonExistant() public function testTakeActionNonExistant()
{ {
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $c = $this->getEntityManager()->getRepository(Character::class)->find(1);
$this->g->setCharacter($c); $this->g->setCharacter($c);
// For now, I cant seem to serialize a proper ActionGroup to store in // For now, I cant seem to serialize a proper ActionGroup to store in
@@ -190,7 +188,7 @@ class GameTest extends CoreModelTestCase
public function testTakeActionNavigate() public function testTakeActionNavigate()
{ {
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000003"); $c = $this->getEntityManager()->getRepository(Character::class)->find(3);
$this->g->setCharacter($c); $this->g->setCharacter($c);
// For now, I cant seem to serialize a proper ActionGroup to store in // For now, I cant seem to serialize a proper ActionGroup to store in
@@ -211,14 +209,13 @@ class GameTest extends CoreModelTestCase
public function testIfActionParametersAreRelayedToEvent() public function testIfActionParametersAreRelayedToEvent()
{ {
/* @var $c Character */ /* @var $c Character */
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $c = $this->getEntityManager()->getRepository(Character::class)->find(2);
$this->g->setCharacter($c); $this->g->setCharacter($c);
// subscribe event // subscribe event
$this->g->getEventManager()->subscribe('#h/lotgd/core/navigate-to/lotgd/tests/paramaters#', DefaultSceneProvider::class, 'lotgd/core/tests'); $this->g->getEventManager()->subscribe('#h/lotgd/core/navigate-to/lotgd/tests/paramaters#', DefaultSceneProvider::class, 'lotgd/core/tests');
$this->getEntityManager()->flush();
$action = new Action("30000000-0000-0000-0000-000000000007", null, ["foo" => "baz"]); $action = new Action(7, null, ["foo" => "baz"]);
$actionId = $action->getId(); $actionId = $action->getId();
$ag = new ActionGroup("group1", "Group 1", 5); $ag = new ActionGroup("group1", "Group 1", 5);
@@ -241,14 +238,13 @@ class GameTest extends CoreModelTestCase
public function testIfActionParametersTakePriorityToOtherParameters() public function testIfActionParametersTakePriorityToOtherParameters()
{ {
/* @var $c Character */ /* @var $c Character */
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $c = $this->getEntityManager()->getRepository(Character::class)->find(2);
$this->g->setCharacter($c); $this->g->setCharacter($c);
// subscribe event // subscribe event
$this->g->getEventManager()->subscribe('#h/lotgd/core/navigate-to/lotgd/tests/paramaters#', DefaultSceneProvider::class, 'lotgd/core/tests'); $this->g->getEventManager()->subscribe('#h/lotgd/core/navigate-to/lotgd/tests/paramaters#', DefaultSceneProvider::class, 'lotgd/core/tests');
$this->getEntityManager()->flush();
$action = new Action("30000000-0000-0000-0000-000000000007", null, ["foo" => "baz"]); $action = new Action(7, null, ["foo" => "baz"]);
$actionId = $action->getId(); $actionId = $action->getId();
$ag = new ActionGroup("group1", "Group 1", 5); $ag = new ActionGroup("group1", "Group 1", 5);
@@ -289,7 +285,7 @@ class GameTest extends CoreModelTestCase
return $values; return $values;
}; };
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000003"); $c = $this->getEntityManager()->getRepository(Character::class)->find(3);
$this->g->setCharacter($c); $this->g->setCharacter($c);
$v0 = $this->g->getViewpoint(); $v0 = $this->g->getViewpoint();
@@ -299,9 +295,9 @@ class GameTest extends CoreModelTestCase
$this->assertSame([ $this->assertSame([
"Parent Scene", "Parent Scene",
[ [
ActionGroup::DefaultGroup => ["30000000-0000-0000-0000-000000000001"], ActionGroup::DefaultGroup => [1],
"lotgd/tests/none/child1" => ["30000000-0000-0000-0000-000000000005"], "lotgd/tests/none/child1" => [5],
"lotgd/tests/none/child2" => ["30000000-0000-0000-0000-000000000006"], "lotgd/tests/none/child2" => [6],
ActionGroup::HiddenGroup => [], ActionGroup::HiddenGroup => [],
] ]
], $viewpointToArray($v1)); ], $viewpointToArray($v1));
@@ -311,10 +307,7 @@ class GameTest extends CoreModelTestCase
$this->assertSame([ $this->assertSame([
"Child Scene 1", "Child Scene 1",
[ [
ActionGroup::DefaultGroup => [ ActionGroup::DefaultGroup => [6, 4],
"30000000-0000-0000-0000-000000000006",
"30000000-0000-0000-0000-000000000004"
],
ActionGroup::HiddenGroup => [], ActionGroup::HiddenGroup => [],
] ]
], $viewpointToArray($v2)); ], $viewpointToArray($v2));
@@ -324,7 +317,7 @@ class GameTest extends CoreModelTestCase
$this->assertSame([ $this->assertSame([
"Child Scene 2", "Child Scene 2",
[ [
ActionGroup::DefaultGroup => ["30000000-0000-0000-0000-000000000004"], ActionGroup::DefaultGroup => [4],
ActionGroup::HiddenGroup => [], ActionGroup::HiddenGroup => [],
] ]
], $viewpointToArray($v3)); ], $viewpointToArray($v3));
-3
View File
@@ -63,9 +63,6 @@ abstract class ModelTestCase extends \PHPUnit_Extensions_Database_TestCase
self::$em = EntityManager::create(["pdo" => self::$pdo], $configuration); self::$em = EntityManager::create(["pdo" => self::$pdo], $configuration);
// Register uuid type
\Doctrine\DBAL\Types\Type::addType('uuid', 'Ramsey\Uuid\Doctrine\UuidType');
// Create Schema // Create Schema
$metaData = self::$em->getMetadataFactory()->getAllMetadata(); $metaData = self::$em->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool(self::$em); $schemaTool = new SchemaTool(self::$em);
+5 -7
View File
@@ -12,7 +12,6 @@ use LotGD\Core\Models\Character;
use LotGD\Core\Models\CharacterProperty; use LotGD\Core\Models\CharacterProperty;
use LotGD\Core\Tests\CoreModelTestCase; use LotGD\Core\Tests\CoreModelTestCase;
use LotGD\Core\Models\Repositories\CharacterRepository; use LotGD\Core\Models\Repositories\CharacterRepository;
use Ramsey\Uuid\UuidInterface;
/** /**
* Tests the management of Characters * Tests the management of Characters
@@ -27,13 +26,13 @@ class CharacterModelTest extends CoreModelTestCase
*/ */
public function testSoftDeletion() public function testSoftDeletion()
{ {
$chars = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000003"); $chars = $this->getEntityManager()->getRepository(Character::class)->find(3);
$this->assertSame(null, $chars); $this->assertSame(null, $chars);
$allChars = $this->getEntityManager()->getRepository(Character::class)->findAll(); $allChars = $this->getEntityManager()->getRepository(Character::class)->findAll();
$this->assertSame(2, count($allChars)); $this->assertSame(2, count($allChars));
$char = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $char = $this->getEntityManager()->getRepository(Character::class)->find(1);
$char->delete($this->getEntityManager()); $char->delete($this->getEntityManager());
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();
$this->getEntityManager()->clear(); $this->getEntityManager()->clear();
@@ -102,7 +101,7 @@ class CharacterModelTest extends CoreModelTestCase
$em->flush(); $em->flush();
$this->assertInstanceOf(UuidInterface::class, $characterEntity->getId()); $this->assertInternalType("int", $characterEntity->getId());
$this->assertSame(16, $characterEntity->getProperty("a property")); $this->assertSame(16, $characterEntity->getProperty("a property"));
$em->flush(); $em->flush();
@@ -143,7 +142,7 @@ class CharacterModelTest extends CoreModelTestCase
$rowsBefore = count($em->getRepository(Character::class)->findAll()); $rowsBefore = count($em->getRepository(Character::class)->findAll());
// Delete one row // Delete one row
$character = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $character = $em->getRepository(Character::class)->find(1);
$character->delete($em); $character->delete($em);
$em->clear(); $em->clear();
@@ -164,7 +163,7 @@ class CharacterModelTest extends CoreModelTestCase
$em = $this->getEntityManager(); $em = $this->getEntityManager();
// test default values // test default values
$firstCharacter = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $firstCharacter = $em->getRepository(Character::class)->find(1);
$this->assertSame(5, $firstCharacter->getProperty("dragonkills", 5)); $this->assertSame(5, $firstCharacter->getProperty("dragonkills", 5));
$this->assertNotSame(5, $firstCharacter->getProperty("dragonkills", "5")); $this->assertNotSame(5, $firstCharacter->getProperty("dragonkills", "5"));
$this->assertSame("hanniball", $firstCharacter->getProperty("petname", "hanniball")); $this->assertSame("hanniball", $firstCharacter->getProperty("petname", "hanniball"));
@@ -227,7 +226,6 @@ class CharacterModelTest extends CoreModelTestCase
$eventManager->subscribe("#h/lotgd/core/getCharacterAttack#", get_class($detectionClass), "test"); $eventManager->subscribe("#h/lotgd/core/getCharacterAttack#", get_class($detectionClass), "test");
$eventManager->subscribe("#h/lotgd/core/getCharacterDefense#", get_class($detectionClass), "test"); $eventManager->subscribe("#h/lotgd/core/getCharacterDefense#", get_class($detectionClass), "test");
$this->getEntityManager()->flush();
$this->assertSame($level*2, $character1->getAttack()); $this->assertSame($level*2, $character1->getAttack());
$this->assertSame($level*4, $character2->getDefense()); $this->assertSame($level*4, $character2->getDefense());
+23 -23
View File
@@ -24,8 +24,8 @@ class MessageModelTest extends CoreModelTestCase
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$mm=new MessageManager(); $mm=new MessageManager();
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $character1 = $em->getRepository(Character::class)->find(1);
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000004"); $character2 = $em->getRepository(Character::class)->find(4);
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2]); $thread1 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2]);
$thread2 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character2, $character1]); $thread2 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character2, $character1]);
@@ -42,8 +42,8 @@ class MessageModelTest extends CoreModelTestCase
$em->flush(); $em->flush();
$em->clear(); $em->clear();
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $character1 = $em->getRepository(Character::class)->find(1);
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000004"); $character2 = $em->getRepository(Character::class)->find(4);
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2]); $thread1 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2]);
@@ -62,10 +62,10 @@ class MessageModelTest extends CoreModelTestCase
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$mm=new MessageManager(); $mm=new MessageManager();
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $character1 = $em->getRepository(Character::class)->find(1);
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $character2 = $em->getRepository(Character::class)->find(2);
$character3 = $em->getRepository(Character::class)->findWithSoftDeleted("10000000-0000-0000-0000-000000000003"); $character3 = $em->getRepository(Character::class)->find(3, NULL, NULL, CharacterRepository::INCLUDE_SOFTDELETED);
$character4 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000004"); $character4 = $em->getRepository(Character::class)->find(4);
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2, $character3, $character4]); $thread1 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2, $character3, $character4]);
$thread2 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character4, $character2, $character1, $character3]); $thread2 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character4, $character2, $character1, $character3]);
@@ -89,11 +89,11 @@ class MessageModelTest extends CoreModelTestCase
$this->assertSame(1, count($character4->getMessageThreads())); $this->assertSame(1, count($character4->getMessageThreads()));
$em->flush(); $em->flush();
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $character1 = $em->getRepository(Character::class)->find(1);
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $character2 = $em->getRepository(Character::class)->find(2);
$character3 = $em->getRepository(Character::class)->findWithSoftDeleted("10000000-0000-0000-0000-000000000003"); $character3 = $em->getRepository(Character::class)->find(3, NULL, NULL, CharacterRepository::INCLUDE_SOFTDELETED);
$character4 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000004"); $character4 = $em->getRepository(Character::class)->find(4);
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2, $character3, $character4]); $thread1 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2, $character3, $character4]);
@@ -111,8 +111,8 @@ class MessageModelTest extends CoreModelTestCase
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$mm=new MessageManager(); $mm=new MessageManager();
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $character1 = $em->getRepository(Character::class)->find(1);
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $character2 = $em->getRepository(Character::class)->find(2);
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character1]); $thread1 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character1]);
$thread2 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character2]); $thread2 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character2]);
@@ -124,9 +124,9 @@ class MessageModelTest extends CoreModelTestCase
$em->flush(); $em->flush();
$em->clear(); $em->clear();
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $character1 = $em->getRepository(Character::class)->find(1);
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $character2 = $em->getRepository(Character::class)->find(2);
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character1]); $thread1 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character1]);
$thread2 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character2]); $thread2 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character2]);
@@ -154,8 +154,8 @@ class MessageModelTest extends CoreModelTestCase
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$mm=new MessageManager(); $mm=new MessageManager();
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $character1 = $em->getRepository(Character::class)->find(1);
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $character2 = $em->getRepository(Character::class)->find(2);
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character1, $character2]); $thread1 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character1, $character2]);
$thread2 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2]); $thread2 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2]);
@@ -166,9 +166,9 @@ class MessageModelTest extends CoreModelTestCase
$em->flush(); $em->flush();
$em->clear(); $em->clear();
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $character1 = $em->getRepository(Character::class)->find(1);
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $character2 = $em->getRepository(Character::class)->find(2);
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character1, $character2]); $thread1 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character1, $character2]);
+10 -9
View File
@@ -19,10 +19,10 @@ class MotDModelTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$author = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $author = $em->getRepository(Character::class)->find(1);
// Test normal message // Test normal message
$motd1 = $em->getRepository(MotD::class)->find("20000000-0000-0000-0000-000000000001"); $motd1 = $em->getRepository(MotD::class)->find(1);
$this->assertSame("This is the title", $motd1->getTitle()); $this->assertSame("This is the title", $motd1->getTitle());
$this->assertSame("This is the body of the message", $motd1->getBody()); $this->assertSame("This is the body of the message", $motd1->getBody());
$this->assertSame($author, $motd1->getAuthor()); $this->assertSame($author, $motd1->getAuthor());
@@ -30,14 +30,14 @@ class MotDModelTest extends CoreModelTestCase
$this->assertFalse($motd1->getSystemMessage()); $this->assertFalse($motd1->getSystemMessage());
// Test System message // Test System message
$motd2 = $em->getRepository(MotD::class)->find("20000000-0000-0000-0000-000000000002"); $motd2 = $em->getRepository(MotD::class)->find(2);
$this->assertTrue($motd2->getSystemMessage()); $this->assertTrue($motd2->getSystemMessage());
$this->assertNotSame($motd2->getAuthor(), $motd2->getApparantAuthor()); $this->assertNotSame($motd2->getAuthor(), $motd2->getApparantAuthor());
$this->assertSame($author, $motd2->getAuthor()); $this->assertSame($author, $motd2->getAuthor());
$this->assertNotSame("Deleted Character Name", $motd2->getAuthor()->getDisplayName()); $this->assertNotSame("Deleted Character Name", $motd2->getAuthor()->getDisplayName());
// Test message with unknown author // Test message with unknown author
$motd3 = $em->getRepository(Motd::class)->find("20000000-0000-0000-0000-000000000003"); $motd3 = $em->getRepository(Motd::class)->find(3);
$this->assertSame("Deleted Testcharacter", $motd3->getAuthor()->getDisplayName()); $this->assertSame("Deleted Testcharacter", $motd3->getAuthor()->getDisplayName());
} }
@@ -45,7 +45,7 @@ class MotDModelTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$time1 = $em->getRepository(MotD::class)->find("20000000-0000-0000-0000-000000000001")->getCreationTime(); $time1 = $em->getRepository(MotD::class)->find(1)->getCreationTime();
$time2 = new \DateTime("2016-05-03 14:19:12"); $time2 = new \DateTime("2016-05-03 14:19:12");
$time3 = $time2->setTimezone(new \DateTimeZone("Europe/Zurich")); $time3 = $time2->setTimezone(new \DateTimeZone("Europe/Zurich"));
$time4 = new \DateTime("2016-05-03 14:19:12"); $time4 = new \DateTime("2016-05-03 14:19:12");
@@ -63,13 +63,13 @@ class MotDModelTest extends CoreModelTestCase
{ {
return [ return [
[[ [[
"author" => "10000000-0000-0000-0000-000000000001", "author" => 1,
"title" => "ABC_\"EFG", "title" => "ABC_\"EFG",
"body" => "Lorem îpsum etc pp", "body" => "Lorem îpsum etc pp",
"systemMessage" => false, "systemMessage" => false,
]], ]],
[[ [[
"author" => "10000000-0000-0000-0000-000000000001", "author" => 1,
"title" => "AnotherOne", "title" => "AnotherOne",
"body" => "Test a Second One", "body" => "Test a Second One",
"systemMessage" => true, "systemMessage" => true,
@@ -87,9 +87,10 @@ class MotDModelTest extends CoreModelTestCase
$motdCreationArguments["author"] = $em->getRepository(Character::class)->find($motdCreationArguments["author"]); $motdCreationArguments["author"] = $em->getRepository(Character::class)->find($motdCreationArguments["author"]);
$motd = MotD::create($motdCreationArguments); $motd = MotD::create($motdCreationArguments);
$motd->save($em);
$id = $motd->getId(); $id = $motd->getId();
$em->persist($motd);
$em->flush(); $em->flush();
$em->clear(); $em->clear();
+33 -37
View File
@@ -3,6 +3,8 @@ declare(strict_types=1);
namespace LotGD\Core\Tests\Models; namespace LotGD\Core\Tests\Models;
use Doctrine\Common\Collections\ArrayCollection;
use LotGD\Core\Exceptions\ArgumentException; use LotGD\Core\Exceptions\ArgumentException;
use LotGD\Core\Models\{Scene, SceneConnection, SceneConnectionGroup}; use LotGD\Core\Models\{Scene, SceneConnection, SceneConnectionGroup};
use LotGD\Core\Tests\CoreModelTestCase; use LotGD\Core\Tests\CoreModelTestCase;
@@ -52,8 +54,6 @@ class SceneModelTest extends CoreModelTestCase
// create new scene, flush and clear. Number of scenes in db should be +1 // create new scene, flush and clear. Number of scenes in db should be +1
$newScene = Scene::create($this->getTestSceneData()); $newScene = Scene::create($this->getTestSceneData());
$id = $newScene->getId();
$newScene->save($em); $newScene->save($em);
$this->flushAndClear(); $this->flushAndClear();
unset($newScene); unset($newScene);
@@ -63,7 +63,7 @@ class SceneModelTest extends CoreModelTestCase
$this->assertSame($n1 + 1, $n2); $this->assertSame($n1 + 1, $n2);
// fetch new scene, delete, flush and clear. // fetch new scene, delete, flush and clear.
$newScene = $em->getRepository(Scene::class)->find($id); $newScene = $em->getRepository(Scene::class)->findOneBy($this->getTestSceneData());
$newScene->delete($em); $newScene->delete($em);
$this->flushAndClear(); $this->flushAndClear();
@@ -87,7 +87,7 @@ class SceneModelTest extends CoreModelTestCase
// create new scene, connect to another one. Number of scenes must be +1, number of connections must be +1 // create new scene, connect to another one. Number of scenes must be +1, number of connections must be +1
// this tests for cascade=persist // this tests for cascade=persist
$scene = Scene::create($this->getTestSceneData()); $scene = Scene::create($this->getTestSceneData());
$scene->connect($em->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001")); $scene->connect($em->getRepository(Scene::class)->find(1));
$scene->save($em); $scene->save($em);
$this->flushAndClear(); $this->flushAndClear();
unset($scene); unset($scene);
@@ -144,7 +144,7 @@ class SceneModelTest extends CoreModelTestCase
public function testGetters() public function testGetters()
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$scene = $em->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002"); $scene = $em->getRepository(Scene::class)->find(2);
$this->assertEquals("The Forest", $scene->getTitle()); $this->assertEquals("The Forest", $scene->getTitle());
$this->assertEquals("This is a very dangerous and dark forest", $scene->getDescription()); $this->assertEquals("This is a very dangerous and dark forest", $scene->getDescription());
@@ -154,7 +154,7 @@ class SceneModelTest extends CoreModelTestCase
public function testIfHasConnectionGroupReturnsTrueIfConnectionGroupExists() public function testIfHasConnectionGroupReturnsTrueIfConnectionGroupExists()
{ {
$scene = $this->getEntityManager()->getRepository(Scene::class)->find( "30000000-0000-0000-0000-000000000001"); $scene = $this->getEntityManager()->getRepository(Scene::class)->find(1);
$this->assertTrue($scene->hasConnectionGroup("lotgd/tests/village/outside")); $this->assertTrue($scene->hasConnectionGroup("lotgd/tests/village/outside"));
$this->assertTrue($scene->hasConnectionGroup("lotgd/tests/village/market")); $this->assertTrue($scene->hasConnectionGroup("lotgd/tests/village/market"));
@@ -163,14 +163,14 @@ class SceneModelTest extends CoreModelTestCase
public function testIfHasConnectionGroupReturnsFalseIfConnectionGroupDoesNotExist() public function testIfHasConnectionGroupReturnsFalseIfConnectionGroupDoesNotExist()
{ {
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find( "30000000-0000-0000-0000-000000000002"); $scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(2);
$this->assertFalse($scene2->hasConnectionGroup("lotgd/tests/village/outside")); $this->assertFalse($scene2->hasConnectionGroup("lotgd/tests/village/outside"));
$this->assertFalse($scene2->hasConnectionGroup("lotgd/tests/village/market")); $this->assertFalse($scene2->hasConnectionGroup("lotgd/tests/village/market"));
$this->assertFalse($scene2->hasConnectionGroup("lotgd/tests/village/empty")); $this->assertFalse($scene2->hasConnectionGroup("lotgd/tests/village/empty"));
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001"); $scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
$this->assertFalse($scene1->hasConnectionGroup("lotgd/tests/village/23426")); $this->assertFalse($scene1->hasConnectionGroup("lotgd/tests/village/23426"));
} }
@@ -178,7 +178,7 @@ class SceneModelTest extends CoreModelTestCase
public function testIfAddConnectionGroupWorks() public function testIfAddConnectionGroupWorks()
{ {
$connectionGroup = new SceneConnectionGroup("lotgd/tests/village/new", "New Street"); $connectionGroup = new SceneConnectionGroup("lotgd/tests/village/new", "New Street");
$scene = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001"); $scene = $this->getEntityManager()->getRepository(Scene::class)->find(1);
$this->assertFalse($scene->hasConnectionGroup("lotgd/tests/village/new")); $this->assertFalse($scene->hasConnectionGroup("lotgd/tests/village/new"));
@@ -191,9 +191,8 @@ class SceneModelTest extends CoreModelTestCase
public function testIfAddConnectionGroupThrowsArgumentExceptionIfGroupIsAlreadyAssignedToItself() public function testIfAddConnectionGroupThrowsArgumentExceptionIfGroupIsAlreadyAssignedToItself()
{ {
$scene = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001"); $scene = $this->getEntityManager()->getRepository(Scene::class)->find(1);
$connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class) $connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class)->findOneBy(["scene" => 1, "name" => "lotgd/tests/village/outside"]);
->findOneBy(["scene" => "30000000-0000-0000-0000-000000000001", "name" => "lotgd/tests/village/outside"]);
$this->expectException(ArgumentException::class); $this->expectException(ArgumentException::class);
$scene->addConnectionGroup($connectionGroup); $scene->addConnectionGroup($connectionGroup);
@@ -201,9 +200,8 @@ class SceneModelTest extends CoreModelTestCase
public function testIfAddConnectionGroupThrowsArgumentExceptionIfGroupIsAlreadyAssignedToSomwhereElse() public function testIfAddConnectionGroupThrowsArgumentExceptionIfGroupIsAlreadyAssignedToSomwhereElse()
{ {
$scene = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002"); $scene = $this->getEntityManager()->getRepository(Scene::class)->find(2);
$connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class) $connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class)->findOneBy(["scene" => 1, "name" => "lotgd/tests/village/outside"]);
->findOneBy(["scene" => "30000000-0000-0000-0000-000000000001", "name" => "lotgd/tests/village/outside"]);
$this->expectException(ArgumentException::class); $this->expectException(ArgumentException::class);
$scene->addConnectionGroup($connectionGroup); $scene->addConnectionGroup($connectionGroup);
@@ -211,9 +209,8 @@ class SceneModelTest extends CoreModelTestCase
public function testifDropConnectionGroupWorks() public function testifDropConnectionGroupWorks()
{ {
$scene = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001"); $scene = $this->getEntityManager()->getRepository(Scene::class)->find(1);
$connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class) $connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class)->findOneBy(["scene" => 1, "name" => "lotgd/tests/village/outside"]);
->findOneBy(["scene" => "30000000-0000-0000-0000-000000000001", "name" => "lotgd/tests/village/outside"]);
$this->assertTrue($scene->hasConnectionGroup("lotgd/tests/village/outside")); $this->assertTrue($scene->hasConnectionGroup("lotgd/tests/village/outside"));
@@ -226,9 +223,8 @@ class SceneModelTest extends CoreModelTestCase
public function testIfDropConnectionGroupThrowsArgumentExceptionIfEntityIsRemovedFromNonOwningScene() public function testIfDropConnectionGroupThrowsArgumentExceptionIfEntityIsRemovedFromNonOwningScene()
{ {
$scene = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002"); $scene = $this->getEntityManager()->getRepository(Scene::class)->find(2);
$connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class) $connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class)->findOneBy(["scene" => 1, "name" => "lotgd/tests/village/outside"]);
->findOneBy(["scene" => "30000000-0000-0000-0000-000000000001", "name" => "lotgd/tests/village/outside"]);
$this->expectException(ArgumentException::class); $this->expectException(ArgumentException::class);
$scene->dropConnectionGroup($connectionGroup); $scene->dropConnectionGroup($connectionGroup);
@@ -236,8 +232,8 @@ class SceneModelTest extends CoreModelTestCase
public function testIfGetConnectedScenesReturnsConnectedScenes() public function testIfGetConnectedScenesReturnsConnectedScenes()
{ {
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001"); $scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002"); $scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(2);
$this->assertCount(3, $scene1->getConnectedScenes()); $this->assertCount(3, $scene1->getConnectedScenes());
$this->assertCount(1, $scene2->getConnectedScenes()); $this->assertCount(1, $scene2->getConnectedScenes());
@@ -250,9 +246,9 @@ class SceneModelTest extends CoreModelTestCase
public function testIfIsConnectedToReturnsExpectedReturnValue() public function testIfIsConnectedToReturnsExpectedReturnValue()
{ {
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001"); $scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002"); $scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(2);
$scene5 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000005"); $scene5 = $this->getEntityManager()->getRepository(Scene::class)->find(5);
$this->assertTrue($scene1->isConnectedTo($scene2)); $this->assertTrue($scene1->isConnectedTo($scene2));
$this->assertTrue($scene2->isConnectedTo($scene1)); $this->assertTrue($scene2->isConnectedTo($scene1));
@@ -264,8 +260,8 @@ class SceneModelTest extends CoreModelTestCase
public function testIfTwoScenesCanGetConnected() public function testIfTwoScenesCanGetConnected()
{ {
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002"); $scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(2);
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000005"); $scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(5);
$scene1->connect($scene2); $scene1->connect($scene2);
@@ -279,8 +275,8 @@ class SceneModelTest extends CoreModelTestCase
public function testIfASceneConnectionGroupCanGetConnectedToAScene() public function testIfASceneConnectionGroupCanGetConnectedToAScene()
{ {
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001"); $scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000005"); $scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(5);
$scene1->getConnectionGroup("lotgd/tests/village/outside")->connect($scene2); $scene1->getConnectionGroup("lotgd/tests/village/outside")->connect($scene2);
@@ -294,8 +290,8 @@ class SceneModelTest extends CoreModelTestCase
public function testIfASceneCanGetConnectedToASceneConnectionGroup() public function testIfASceneCanGetConnectedToASceneConnectionGroup()
{ {
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001"); $scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000005"); $scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(5);
$scene2->connect($scene1->getConnectionGroup("lotgd/tests/village/outside")); $scene2->connect($scene1->getConnectionGroup("lotgd/tests/village/outside"));
@@ -309,8 +305,8 @@ class SceneModelTest extends CoreModelTestCase
public function testIfASceneConnectionGroupCanGetConnectedToAnotherSceneConnectionGroup() public function testIfASceneConnectionGroupCanGetConnectedToAnotherSceneConnectionGroup()
{ {
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001"); $scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000005"); $scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(5);
$scene2->addConnectionGroup(new SceneConnectionGroup("test/orphaned", "Orphan group")); $scene2->addConnectionGroup(new SceneConnectionGroup("test/orphaned", "Orphan group"));
$scene1 $scene1
@@ -329,7 +325,7 @@ class SceneModelTest extends CoreModelTestCase
public function testIfConnectingASceneToItselfThrowsAnException() public function testIfConnectingASceneToItselfThrowsAnException()
{ {
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001"); $scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
$this->expectException(ArgumentException::class); $this->expectException(ArgumentException::class);
$scene1->connect($scene1); $scene1->connect($scene1);
@@ -348,8 +344,8 @@ class SceneModelTest extends CoreModelTestCase
public function testIfConnectingASceneToAnotherAlreadyConnectedSceneThrowsAnException() public function testIfConnectingASceneToAnotherAlreadyConnectedSceneThrowsAnException()
{ {
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001"); $scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002"); $scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(2);
$this->expectException(ArgumentException::class); $this->expectException(ArgumentException::class);
$scene1->connect($scene2); $scene1->connect($scene2);
+30 -30
View File
@@ -40,8 +40,8 @@ class ViewpointTest extends CoreModelTestCase
$em = $this->getEntityManager(); $em = $this->getEntityManager();
// Test character with a characterScene // Test character with a characterScene
$testCharacter = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $testCharacter = $em->getRepository(Character::class)->find(2);
$this->assertSame("10000000-0000-0000-0000-000000000002", (string)$testCharacter->getId()); $this->assertSame(2, $testCharacter->getId());
$characterScene = $testCharacter->getViewpoint(); $characterScene = $testCharacter->getViewpoint();
$this->assertInstanceOf(Viewpoint::class, $characterScene); $this->assertInstanceOf(Viewpoint::class, $characterScene);
@@ -49,8 +49,8 @@ class ViewpointTest extends CoreModelTestCase
$this->assertSame("This is the village.", $characterScene->getDescription()); $this->assertSame("This is the village.", $characterScene->getDescription());
// Test character without a characterScene // Test character without a characterScene
$testCharacter = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001"); $testCharacter = $em->getRepository(Character::class)->find(1);
$this->assertSame("10000000-0000-0000-0000-000000000001", (string)$testCharacter->getId()); $this->assertSame(1, $testCharacter->getId());
$characterScene = $testCharacter->getViewpoint(); $characterScene = $testCharacter->getViewpoint();
$this->assertNull($characterScene); $this->assertNull($characterScene);
@@ -63,9 +63,9 @@ class ViewpointTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$testCharacter = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $testCharacter = $em->getRepository(Character::class)->find(2);
$testScene = $em->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002"); $testScene = $em->getRepository(Scene::class)->find(2);
$this->assertSame("The Village", $testCharacter->getViewpoint()->getTitle()); $this->assertSame("The Village", $testCharacter->getViewpoint()->getTitle());
@@ -82,12 +82,12 @@ class ViewpointTest extends CoreModelTestCase
$ag1 = new ActionGroup('id1', 'title1', 42); $ag1 = new ActionGroup('id1', 'title1', 42);
$ag1->setActions([ $ag1->setActions([
new Action("30000000-0000-0000-0000-000000000001"), new Action(1),
new Action("30000000-0000-0000-0000-000000000002") new Action(2)
]); ]);
$ag2 = new ActionGroup('id2', 'title2', 101); $ag2 = new ActionGroup('id2', 'title2', 101);
$ag2->setActions([ $ag2->setActions([
new Action("30000000-0000-0000-0000-000000000003") new Action(3)
]); ]);
$actionGroups = [ $actionGroups = [
@@ -95,19 +95,19 @@ class ViewpointTest extends CoreModelTestCase
$ag2 $ag2
]; ];
$input = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002"); $input = $em->getRepository(Viewpoint::class)->find(2);
$input->setActionGroups($actionGroups); $input->setActionGroups($actionGroups);
$input->save($em); $input->save($em);
$em->clear(); $em->clear();
$output = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002"); $output = $em->getRepository(Viewpoint::class)->find(2);
$this->assertEquals($actionGroups, $output->getActionGroups()); $this->assertEquals($actionGroups, $output->getActionGroups());
$this->assertEquals($ag2, $input->findActionGroupById('id2')); $this->assertEquals($ag2, $input->findActionGroupById('id2'));
$this->assertNull($input->findActionGroupById('not-there')); $this->assertNull($input->findActionGroupById('not-there'));
$testAction = new Action("30000000-0000-0000-0000-000000000004"); $testAction = new Action(4);
$input->addActionToGroupId($testAction, 'not-there'); $input->addActionToGroupId($testAction, 'not-there');
$this->assertNull($input->findActionById($testAction->getId())); $this->assertNull($input->findActionById($testAction->getId()));
@@ -124,13 +124,13 @@ class ViewpointTest extends CoreModelTestCase
$attachments = [$a1, $a2]; $attachments = [$a1, $a2];
$input = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002"); $input = $em->getRepository(Viewpoint::class)->find(2);
$input->setAttachments($attachments); $input->setAttachments($attachments);
$input->save($em); $input->save($em);
$em->clear(); $em->clear();
$output = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002"); $output = $em->getRepository(Viewpoint::class)->find(2);
$this->assertEquals($attachments, $output->getAttachments()); $this->assertEquals($attachments, $output->getAttachments());
$this->assertEquals('baz', $output->getAttachments()[0]->getFoo()); $this->assertEquals('baz', $output->getAttachments()[0]->getFoo());
$this->assertEquals('fiz', $output->getAttachments()[1]->getFoo()); $this->assertEquals('fiz', $output->getAttachments()[1]->getFoo());
@@ -140,9 +140,9 @@ class ViewpointTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$a1 = new Action("30000000-0000-0000-0000-000000000001"); $a1 = new Action(1);
$a2 = new Action("30000000-0000-0000-0000-000000000002"); $a2 = new Action(2);
$a3 = new Action("30000000-0000-0000-0000-000000000003"); $a3 = new Action(3);
$ag1 = new ActionGroup('id1', 'title1', 42); $ag1 = new ActionGroup('id1', 'title1', 42);
$ag1->setActions([ $ag1->setActions([
@@ -152,7 +152,7 @@ class ViewpointTest extends CoreModelTestCase
]); ]);
$ag2 = new ActionGroup('id2', 'title2', 101); $ag2 = new ActionGroup('id2', 'title2', 101);
$ag2->setActions([ $ag2->setActions([
new Action("30000000-0000-0000-0000-000000000004") new Action(4)
]); ]);
$actionGroups = [ $actionGroups = [
@@ -160,16 +160,16 @@ class ViewpointTest extends CoreModelTestCase
$ag2 $ag2
]; ];
$input = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002"); $input = $em->getRepository(Viewpoint::class)->find(2);
$input->setActionGroups($actionGroups); $input->setActionGroups($actionGroups);
$input->save($em); $input->save($em);
$em->clear(); $em->clear();
$output = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002"); $output = $em->getRepository(Viewpoint::class)->find(2);
// Not finding the scene ID should change nothing. // Not finding the scene ID should change nothing.
$output->removeActionsWithSceneId("30000000-0000-0000-0000-000000001000"); $output->removeActionsWithSceneId(1000);
$this->assertEquals($actionGroups, $output->getActionGroups()); $this->assertEquals($actionGroups, $output->getActionGroups());
$ag1_output = new ActionGroup('id1', 'title1', 42); $ag1_output = new ActionGroup('id1', 'title1', 42);
@@ -182,14 +182,14 @@ class ViewpointTest extends CoreModelTestCase
$ag1_output, $ag1_output,
$ag2 $ag2
]; ];
$output->removeActionsWithSceneId("30000000-0000-0000-0000-000000000002"); $output->removeActionsWithSceneId(2);
$this->assertEquals($actionGroupsWithout2, $output->getActionGroups()); $this->assertEquals($actionGroupsWithout2, $output->getActionGroups());
} }
public function testChangingSceneDescription() public function testChangingSceneDescription()
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$testCharacter = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $testCharacter = $em->getRepository(Character::class)->find(2);
$characterScene = $testCharacter->getViewpoint(); $characterScene = $testCharacter->getViewpoint();
$this->assertSame("This is the village.", $characterScene->getDescription()); $this->assertSame("This is the village.", $characterScene->getDescription());
@@ -201,7 +201,7 @@ class ViewpointTest extends CoreModelTestCase
public function testClearingSceneDescription() public function testClearingSceneDescription()
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$testCharacter = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002"); $testCharacter = $em->getRepository(Character::class)->find(2);
$characterScene = $testCharacter->getViewpoint(); $characterScene = $testCharacter->getViewpoint();
$characterScene->clearDescription(); $characterScene->clearDescription();
@@ -215,9 +215,9 @@ class ViewpointTest extends CoreModelTestCase
{ {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$a1 = new Action("30000000-0000-0000-0000-000000000001"); $a1 = new Action(1);
$a2 = new Action("30000000-0000-0000-0000-000000000002"); $a2 = new Action(2);
$a3 = new Action("30000000-0000-0000-0000-000000000003"); $a3 = new Action(3);
$ag1 = new ActionGroup('id1', 'title1', 42); $ag1 = new ActionGroup('id1', 'title1', 42);
$ag1->setActions([ $ag1->setActions([
@@ -227,7 +227,7 @@ class ViewpointTest extends CoreModelTestCase
]); ]);
$ag2 = new ActionGroup('id2', 'title2', 101); $ag2 = new ActionGroup('id2', 'title2', 101);
$ag2->setActions([ $ag2->setActions([
new Action("30000000-0000-0000-0000-000000000004") new Action(4)
]); ]);
$actionGroups = [ $actionGroups = [
@@ -235,14 +235,14 @@ class ViewpointTest extends CoreModelTestCase
$ag2 $ag2
]; ];
$input = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002"); $input = $em->getRepository(Viewpoint::class)->find(2);
$input->setActionGroups($actionGroups); $input->setActionGroups($actionGroups);
$input->save($em); $input->save($em);
$em->clear(); $em->clear();
/** @var Viewpoint $viewpoint */ /** @var Viewpoint $viewpoint */
$viewpoint = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002"); $viewpoint = $em->getRepository(Viewpoint::class)->find(2);
$actionGroupId1 = $viewpoint->findActionGroupById("id1"); $actionGroupId1 = $viewpoint->findActionGroupById("id1");
$actionGroupId2 = $viewpoint->findActionGroupById("id2"); $actionGroupId2 = $viewpoint->findActionGroupById("id2");
+5 -63
View File
@@ -13,7 +13,6 @@ use LotGD\Core\EventHandler;
use LotGD\Core\EventManager; use LotGD\Core\EventManager;
use LotGD\Core\EventSubscription; use LotGD\Core\EventSubscription;
use LotGD\Core\LibraryConfiguration; use LotGD\Core\LibraryConfiguration;
use LotGD\Core\Models\Character;
use LotGD\Core\ModuleManager; use LotGD\Core\ModuleManager;
use LotGD\Core\Module; use LotGD\Core\Module;
use LotGD\Core\Exceptions\ModuleAlreadyExistsException; use LotGD\Core\Exceptions\ModuleAlreadyExistsException;
@@ -202,53 +201,11 @@ class ModuleManagerTest extends CoreModelTestCase
$this->assertEquals($name, $modules[1]->getLibrary()); $this->assertEquals($name, $modules[1]->getLibrary());
} }
public function testRegisterWithFailedEvents()
{
$class = FakeModule::class;
$name = 'lotgd/tests2';
$subscriptions = array(
'/pattern1/',
'#asasd/',
);
$library = $this->getMockBuilder(LibraryConfiguration::class)
->disableOriginalConstructor()
->getMock();
$library->method('getName')->willReturn($name);
$library->method('getRootNamespace')->willReturn('LotGD\\Core\\Tests\\FakeModule\\');
$library->method('getSubscriptionPatterns')->willReturn($subscriptions);
$eventManager = new EventManager($this->g);
$this->game->method('getEventManager')->willReturn($eventManager);
$eventsBefore = count($eventManager->getSubscriptions());
$subscriptionThrownException = false;
try {
$this->mm->register($library);
} catch(\Throwable $e) {
$subscriptionThrownException = true;
}
$this->assertTrue($subscriptionThrownException);
// Assert module has not been installed.
$modules = $this->mm->getModules();
$this->assertArrayNotHasKey(1, $modules);
// Assert events are not registered
$eventsAfter = count($eventManager->getSubscriptions());
// Randomly flush
$this->getEntityManager()->flush();
$this->assertSame($eventsBefore, $eventsAfter, "Events after failed subscription are actually more.");
}
public function testRegisteringDefectiveModule() public function testRegisteringDefectiveModule()
{ {
$class = DefectiveModule::class; $class = DefectiveModule::class;
$name = "lotgd/tests3"; $name = "lotgd/tests3";
$subscriptions = ["#e/lotgd/core/tests/dat-event#"]; $subscriptions = [];
$library = $this->getMockBuilder(LibraryConfiguration::class) $library = $this->getMockBuilder(LibraryConfiguration::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@@ -256,12 +213,11 @@ class ModuleManagerTest extends CoreModelTestCase
$library->method('getRootNamespace')->willReturn('LotGD\\Core\\Tests\\DefectiveModule\\'); $library->method('getRootNamespace')->willReturn('LotGD\\Core\\Tests\\DefectiveModule\\');
$library->method('getSubscriptionPatterns')->willReturn($subscriptions); $library->method('getSubscriptionPatterns')->willReturn($subscriptions);
// Defective Module adds a character. Count the characters before. $eventManager = $this->getMockBuilder(EventManager::class)
$charactersBefore = count($this->getEntityManager()->getRepository(Character::class)->findAll()); ->disableOriginalConstructor()
->getMock();
$eventManager = new EventManager($this->g);
$this->game->method('getEventManager')->willReturn($eventManager); $this->game->method('getEventManager')->willReturn($eventManager);
$modulesBefore = $this->mm->getModules(); $modulesBefore = $this->mm->getModules();
try { try {
// onRegister throws an exception. This exception needs to be captured and handled by mm->register without actually // onRegister throws an exception. This exception needs to be captured and handled by mm->register without actually
@@ -273,21 +229,7 @@ class ModuleManagerTest extends CoreModelTestCase
} }
$modulesAfter = $this->mm->getModules(); $modulesAfter = $this->mm->getModules();
$this->assertTrue($exceptionCaptured); $this->assertFalse($exceptionCaptured);
$this->assertCount(count($modulesBefore), $modulesAfter); $this->assertCount(count($modulesBefore), $modulesAfter);
// Make sure there are no event leftovers.
$subscriptions_db = $eventManager->getSubscriptions();
$found = 0;
foreach($subscriptions_db as $subscription) {
if (in_array($subscription->getPattern(), $subscriptions)) {
$found++;
}
}
$this->assertSame(0, $found);
// Count characters. Must stay the same!
$charactersAfter = count($this->getEntityManager()->getRepository(Character::class)->findAll());
$this->assertSame($charactersBefore, $charactersAfter, "Modules flushed did not get not added to the database.");
} }
} }
+13 -13
View File
@@ -1,48 +1,48 @@
characters: characters:
- -
id: "d363c077-234a-433d-834e-f1a1d3b281d8" id: 1
name: "Player" name: "Player"
displayName: "The Player" displayName: "The Player"
health: 100 health: 100
maxhealth: 100 maxhealth: 100
level: 10 level: 10
- -
id: "4d01c29b-d825-4bc7-9e6e-63525155fd37" id: 2
name: "High Level Char" name: "High Level Char"
displayName: "High Level Char" displayName: "High Level Char"
health: 1000 health: 1000
maxhealth: 1000 maxhealth: 1000
level: 100 level: 100
- -
id: "c3792b61-4e34-4710-9871-65a68ac30bb4" id: 3
name: "Low Level Char" name: "Low Level Char"
displayName: "Low Level Char" displayName: "Low Level Char"
health: 10 health: 10
maxhealth: 10 maxhealth: 10
level: 1 level: 1
- -
id: "6565b418-55f5-4a6b-8d92-a9ef81329912" id: 4
name: "Low Damage Char" name: "Low Damage Char"
displayName: "Low Damage Char" displayName: "Low Damage Char"
health: 500 health: 500
maxhealth: 500 maxhealth: 500
level: 0 level: 0
- -
id: "539e4bb0-84d1-49ed-a697-ff449991e9b7" id: 10
name: "Level 10 Character" name: "Level 10 Character"
displayName: "Level 10 Character" displayName: "Level 10 Character"
health: 100 health: 100
maxhealth: 100 maxhealth: 100
level: 10 level: 10
- -
id: "24d71c26-f915-401c-8b3e-1932edf650ce" id: 11
name: "Level 11 Character" name: "Level 11 Character"
displayName: "Level 11 Character" displayName: "Level 11 Character"
health: 110 health: 110
maxhealth: 110 maxhealth: 110
level: 11 level: 11
- -
id: "1a9f63f2-3006-4e12-b272-4fd6be518a93" id: 13
name: "Level 13 Character" name: "Level 13 Character"
displayName: "Level 13 Character" displayName: "Level 13 Character"
health: 130 health: 130
@@ -50,26 +50,26 @@ characters:
level: 13 level: 13
monsters: monsters:
- -
id: "de84c507-9673-44e7-b665-9e43416b9c2f" id: 1
name: "Evil Monster" name: "Evil Monster"
level: 5 level: 5
- -
id: "b636df29-f72d-4e2d-9850-982e783a9e94" id: 2
name: "High Dragon" name: "High Dragon"
level: 100 level: 100
- -
id: "c004bcb6-a7c1-4f9a-abc2-1711c64e23a0" id: 3
name: "Stone" name: "Stone"
level: 1 level: 1
- -
id: "f1d1f672-e308-420e-939f-cbb39285b222" id: 10
name: "Level 10 Monster" name: "Level 10 Monster"
level: 10 level: 10
- -
id: "7ca9c141-aaf8-44a5-9d04-b6f9923f3c66" id: 11
name: "Level 11 Monster" name: "Level 11 Monster"
level: 11 level: 11
- -
id: "09540b93-63c9-4d82-8501-f569f63dfc4c" id: 13
name: "Level 13 Monster" name: "Level 13 Monster"
level: 13 level: 13
+4 -4
View File
@@ -1,18 +1,18 @@
characters: characters:
- -
id: "10000000-0000-0000-0000-000000000001" id: 1
name: "Testcharacter 1" name: "Testcharacter 1"
displayName: "Testcharacter 1" displayName: "Testcharacter 1"
health: 0 health: 0
maxhealth: 100 maxhealth: 100
- -
id: "10000000-0000-0000-0000-000000000002" id: 2
name: "Testcharacter 2" name: "Testcharacter 2"
displayName: "Testcharacter 2" displayName: "Testcharacter 2"
health: 90 health: 90
maxhealth: 90 maxhealth: 90
- -
id: "10000000-0000-0000-0000-000000000003" id: 3
name: "Testcharacter 3" name: "Testcharacter 3"
displayName: "Testcharacter 3 (deleted)" displayName: "Testcharacter 3 (deleted)"
health: 90 health: 90
@@ -20,6 +20,6 @@ characters:
deletedAt: "2011-11-11 11:11:11" deletedAt: "2011-11-11 11:11:11"
character_properties: character_properties:
- -
owner_id: "10000000-0000-0000-0000-000000000001" owner_id: 1
propertyName: "test" propertyName: "test"
propertyValue: 's:5:"hallo";' propertyValue: 's:5:"hallo";'
+25 -25
View File
@@ -1,19 +1,19 @@
characters: characters:
- -
id: "10000000-0000-0000-0000-000000000001" id: 1
name: "Char without a Scene" name: "Char without a Scene"
displayName: "A" displayName: "A"
- -
id: "10000000-0000-0000-0000-000000000002" id: 2
name: "Char with a Scene" name: "Char with a Scene"
displayName: "B" displayName: "B"
- -
id: "10000000-0000-0000-0000-000000000003" id: 3
name: "Char without a Scene" name: "Char without a Scene"
displayName: "C" displayName: "C"
viewpoints: viewpoints:
- -
owner_id: "10000000-0000-0000-0000-000000000002" owner_id: 2
title: "The Village" title: "The Village"
description: "This is the village." description: "This is the village."
template: "lotgd/tests/village" template: "lotgd/tests/village"
@@ -22,74 +22,74 @@ viewpoints:
actionGroups: "a:0:{}" actionGroups: "a:0:{}"
scenes: scenes:
- -
id: "30000000-0000-0000-0000-000000000001" id: 1
title: "The Village" title: "The Village"
description: "This is the village." description: "This is the village."
template: "lotgd/tests/village" template: "lotgd/tests/village"
- -
id: "30000000-0000-0000-0000-000000000002" id: 2
title: "The Forest" title: "The Forest"
description: "This is a very dangerous and dark forest" description: "This is a very dangerous and dark forest"
template: "lotgd/tests/forest" template: "lotgd/tests/forest"
- -
id: "30000000-0000-0000-0000-000000000003" id: 3
title: "The Weaponry" title: "The Weaponry"
description: "This is the place where you can buy awesome weapons" description: "This is the place where you can buy awesome weapons"
template: "lotgd/tests/weaponry" template: "lotgd/tests/weaponry"
- -
id: "30000000-0000-0000-0000-000000000004" id: 4
title: "Parent Scene" title: "Parent Scene"
description: "This is a parent scene that connects to two children." description: "This is a parent scene that connects to two children."
template: "lotgd/tests/none" template: "lotgd/tests/none"
- -
id: "30000000-0000-0000-0000-000000000005" id: 5
title: "Child Scene 1" title: "Child Scene 1"
description: "This is a parent scene that connects to two children." description: "This is a parent scene that connects to two children."
template: "lotgd/tests/none" template: "lotgd/tests/none"
- -
id: "30000000-0000-0000-0000-000000000006" id: 6
title: "Child Scene 2" title: "Child Scene 2"
description: "This is a parent scene that connects to two children." description: "This is a parent scene that connects to two children."
template: "lotgd/tests/none" template: "lotgd/tests/none"
- -
id: "30000000-0000-0000-0000-000000000007" id: 7
title: "Parameter test" title: "Parameter test"
description: "This is a parameter test" description: "This is a parameter test"
template: "lotgd/tests/paramaters" template: "lotgd/tests/paramaters"
scene_connection_groups: scene_connection_groups:
- -
scene: "30000000-0000-0000-0000-000000000004" scene: 4
name: "lotgd/tests/none/child1" name: "lotgd/tests/none/child1"
title: "Child 1" title: "Child 1"
- -
scene: "30000000-0000-0000-0000-000000000004" scene: 4
name: "lotgd/tests/none/child2" name: "lotgd/tests/none/child2"
title: "Child 2" title: "Child 2"
scene_connections: scene_connections:
- -
outgoingScene: "30000000-0000-0000-0000-000000000001" outgoingScene: 1
incomingScene: "30000000-0000-0000-0000-000000000002" incomingScene: 2
directionality: 0 directionality: 0
- -
outgoingScene: "30000000-0000-0000-0000-000000000001" outgoingScene: 1
incomingScene: "30000000-0000-0000-0000-000000000003" incomingScene: 3
directionality: 0 directionality: 0
- -
outgoingScene: "30000000-0000-0000-0000-000000000001" outgoingScene: 1
incomingScene: "30000000-0000-0000-0000-000000000004" incomingScene: 4
directionality: 0 directionality: 0
- -
outgoingScene: "30000000-0000-0000-0000-000000000004" outgoingScene: 4
incomingScene: "30000000-0000-0000-0000-000000000005" incomingScene: 5
outgoingConnectionGroupName: "lotgd/tests/none/child1" outgoingConnectionGroupName: "lotgd/tests/none/child1"
directionality: 0 directionality: 0
- -
outgoingScene: "30000000-0000-0000-0000-000000000004" outgoingScene: 4
incomingScene: "30000000-0000-0000-0000-000000000006" incomingScene: 6
outgoingConnectionGroupName: "lotgd/tests/none/child2" outgoingConnectionGroupName: "lotgd/tests/none/child2"
directionality: 0 directionality: 0
- -
outgoingScene: "30000000-0000-0000-0000-000000000005" outgoingScene: 5
incomingScene: "30000000-0000-0000-0000-000000000006" incomingScene: 6
directionality: 1 directionality: 1
+7 -7
View File
@@ -1,19 +1,19 @@
characters: characters:
- -
id: "10000000-0000-0000-0000-000000000001" id: 1
name: "Testcharacter 1" name: "Testcharacter 1"
displayName: "Testcharacter 1" displayName: "Testcharacter 1"
- -
id: "10000000-0000-0000-0000-000000000002" id: 2
name: "Testcharacter 2" name: "Testcharacter 2"
displayName: "Testcharacter 2" displayName: "Testcharacter 2"
- -
id: "10000000-0000-0000-0000-000000000003" id: 3
name: "Testcharacter 1" name: "Testcharacter 1"
displayName: "Deleted Testcharacter" displayName: "Deleted Testcharacter"
deletedAt: "2011-11-11 11:11:11" deletedAt: "2011-11-11 11:11:11"
- -
id: "10000000-0000-0000-0000-000000000004" id: 4
name: "Testcharacter 3" name: "Testcharacter 3"
displayName: "Testcharacter 3" displayName: "Testcharacter 3"
message_threads: message_threads:
@@ -23,7 +23,7 @@ message_threads:
messages: messages:
- -
id: 1 id: 1
author_id: "10000000-0000-0000-0000-000000000001" author_id: 1
thread_id: 1 thread_id: 1
message: "Hi!" message: "Hi!"
createdAt: "2000-01-01 00:00:01" createdAt: "2000-01-01 00:00:01"
@@ -31,7 +31,7 @@ messages:
message_threads_x_characters: message_threads_x_characters:
- -
messagethread_id: 1 messagethread_id: 1
character_id: "10000000-0000-0000-0000-000000000001" character_id: 1
- -
messagethread_id: 1 messagethread_id: 1
character_id: "10000000-0000-0000-0000-000000000002" character_id: 2
+9 -9
View File
@@ -1,18 +1,18 @@
characters: characters:
- -
id: "10000000-0000-0000-0000-000000000001" id: 1
name: "Testcharacter 1" name: "Testcharacter 1"
displayName: "Testcharacter 1" displayName: "Testcharacter 1"
health: 0 health: 0
maxhealth: 100 maxhealth: 100
- -
id: "10000000-0000-0000-0000-000000000002" id: 2
name: "Testcharacter 2" name: "Testcharacter 2"
displayName: "Testcharacter 2" displayName: "Testcharacter 2"
health: 90 health: 90
maxhealth: 90 maxhealth: 90
- -
id: "10000000-0000-0000-0000-000000000003" id: 3
name: "Testcharacter 1" name: "Testcharacter 1"
displayName: "Deleted Testcharacter" displayName: "Deleted Testcharacter"
health: 200 health: 200
@@ -20,22 +20,22 @@ characters:
deletedAt: "2011-11-11 11:11:11" deletedAt: "2011-11-11 11:11:11"
motd: motd:
- -
id: "20000000-0000-0000-0000-000000000001" id: 1
author_id: "10000000-0000-0000-0000-000000000001" author_id: 1
title: "This is the title" title: "This is the title"
body: "This is the body of the message" body: "This is the body of the message"
creationTime: "2016-05-03 14:19:12" creationTime: "2016-05-03 14:19:12"
systemMessage: false systemMessage: false
- -
id: "20000000-0000-0000-0000-000000000002" id: 2
author_id: "10000000-0000-0000-0000-000000000001" author_id: 1
title: "This is a system message" title: "This is a system message"
body: "This is the body of the system message" body: "This is the body of the system message"
creationTime: "2016-05-04 14:19:12" creationTime: "2016-05-04 14:19:12"
systemMessage: true systemMessage: true
- -
id: "20000000-0000-0000-0000-000000000003" id: 3
author_id: "10000000-0000-0000-0000-000000000003" author_id: 3
title: "This is an old message." title: "This is an old message."
body: "This is an old message." body: "This is an old message."
creationTime: "2002-12-09 15:13:59" creationTime: "2002-12-09 15:13:59"
+15 -15
View File
@@ -1,53 +1,53 @@
scenes: scenes:
- -
id: "30000000-0000-0000-0000-000000000001" id: 1
title: "The Village" title: "The Village"
description: "This is the village." description: "This is the village."
template: "lotgd/tests/village" template: "lotgd/tests/village"
- -
id: "30000000-0000-0000-0000-000000000002" id: 2
title: "The Forest" title: "The Forest"
description: "This is a very dangerous and dark forest" description: "This is a very dangerous and dark forest"
template: "lotgd/tests/forest" template: "lotgd/tests/forest"
- -
id: "30000000-0000-0000-0000-000000000003" id: 3
title: "The Weaponry" title: "The Weaponry"
description: "This is the place where you can buy awesome weapons" description: "This is the place where you can buy awesome weapons"
template: "lotgd/tests/weaponry" template: "lotgd/tests/weaponry"
- -
id: "30000000-0000-0000-0000-000000000004" id: 4
title: "Another Village" title: "Another Village"
description: "This is another village" description: "This is another village"
template: "lotgd/tests/village" template: "lotgd/tests/village"
- -
id: "30000000-0000-0000-0000-000000000005" id: 5
title: "Orphan" title: "Orphan"
description: "This is an orphan scene" description: "This is an orphan scene"
template: "lotgd/tests/orphan" template: "lotgd/tests/orphan"
scene_connection_groups: scene_connection_groups:
- -
scene: "30000000-0000-0000-0000-000000000001" scene: 1
name: "lotgd/tests/village/outside" name: "lotgd/tests/village/outside"
title: "Outside" title: "Outside"
- -
scene: "30000000-0000-0000-0000-000000000001" scene: 1
name: "lotgd/tests/village/market" name: "lotgd/tests/village/market"
title: "Market" title: "Market"
- -
scene: "30000000-0000-0000-0000-000000000001" scene: 1
name: "lotgd/tests/village/empty" name: "lotgd/tests/village/empty"
title: "Empty" title: "Empty"
- -
scene: "30000000-0000-0000-0000-000000000002" scene: 2
name: "lotgd/tests/forest/category" name: "lotgd/tests/forest/category"
title: "Empty" title: "Empty"
scene_connections: scene_connections:
- -
outgoingScene: "30000000-0000-0000-0000-000000000001" outgoingScene: 1
incomingScene: "30000000-0000-0000-0000-000000000002" incomingScene: 2
- -
outgoingScene: "30000000-0000-0000-0000-000000000001" outgoingScene: 1
incomingScene: "30000000-0000-0000-0000-000000000003" incomingScene: 3
- -
outgoingScene: "30000000-0000-0000-0000-000000000001" outgoingScene: 1
incomingScene: "30000000-0000-0000-0000-000000000004" incomingScene: 4
+10 -10
View File
@@ -1,15 +1,15 @@
characters: characters:
- -
id: "10000000-0000-0000-0000-000000000001" id: 1
name: "Char without a Scene" name: "Char without a Scene"
displayName: "A" displayName: "A"
- -
id: "10000000-0000-0000-0000-000000000002" id: 2
name: "Char with a Scene" name: "Char with a Scene"
displayName: "B" displayName: "B"
viewpoints: viewpoints:
- -
owner_id: "10000000-0000-0000-0000-000000000002" owner_id: 2
title: "The Village" title: "The Village"
description: "This is the village." description: "This is the village."
template: "lotgd/tests/village" template: "lotgd/tests/village"
@@ -18,24 +18,24 @@ viewpoints:
actionGroups: "a:0:{}" actionGroups: "a:0:{}"
scenes: scenes:
- -
id: "30000000-0000-0000-0000-000000000001" id: 1
title: "The Village" title: "The Village"
description: "This is the village." description: "This is the village."
template: "lotgd/tests/village" template: "lotgd/tests/village"
- -
id: "30000000-0000-0000-0000-000000000002" id: 2
title: "The Forest" title: "The Forest"
description: "This is a very dangerous and dark forest" description: "This is a very dangerous and dark forest"
template: "lotgd/tests/forest" template: "lotgd/tests/forest"
- -
id: "30000000-0000-0000-0000-000000000003" id: 3
title: "The Weaponry" title: "The Weaponry"
description: "This is the place where you can buy awesome weapons" description: "This is the place where you can buy awesome weapons"
template: "lotgd/tests/weaponry" template: "lotgd/tests/weaponry"
scene_connections: scene_connections:
- -
outgoingScene: "30000000-0000-0000-0000-000000000001" outgoingScene: 1
incomingScene: "30000000-0000-0000-0000-000000000002" incomingScene: 2
- -
outgoingScene: "30000000-0000-0000-0000-000000000001" outgoingScene: 1
incomingScene: "30000000-0000-0000-0000-000000000003" incomingScene: 3