Added strict_types=1 and added test

This commit is contained in:
Basilius Sauter
2016-04-15 18:56:08 +02:00
parent 5a405fc2db
commit 7afa27246b
4 changed files with 58 additions and 16 deletions
+44 -7
View File
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Tests\Models;
@@ -15,15 +16,51 @@ use Doctrine\ORM\Mapping as ORM;
class CharacterModelTest extends ModelTestCase {
/** @var array */
protected $entities = [Character::class];
/**
* Tests character creation
*/
public function testCreation() {
$characters = [
1 => [
"name" => "Testcharacter",
"maxhealth" => 250
],
2 => [
"name" => "Spamegg",
"maxhealth" => 42
],
];
foreach($characters as $characterId => $characterData) {
$characterEntity = Character::create($characterData);
$characterEntity->save($this->getEntityManager());
public function testCreationQuery() {
$character = Character::create([
"name" => "Testcharacter",
"maxhealth" => 250,
]);
$this->assertEquals($characterEntity->getId(), $characterId);
}
$character->save($this->getEntityManager());
$entities = $this->getEntityManager()->getRepository(Character::class)
->findAll();
$this->assertEquals(count($entities), count($characters));
}
/**
* @expectedException TypeError
*/
public function testCreationTypes() {
$faultyCharacters = [
1 => [
"name" => 16,
"maxhealth" => 16,
],
2 => [
"name" => "Faulter",
"maxhealth" => 17.8,
]
];
$this->assertEquals($character->getId(), 1);
foreach($faultyCharacters as $faultyCharacterData) {
$char = Character::create($faultyCharacterData);
}
}
}