Skip to content
Permalink
Browse files

Minor fixes and changes

The tests are now using sqlite inside of the memory. This ensures a
creation of the database every time the tests are run.
Added some additional tests for probing database persistance.
Removed outdated code.
  • Loading branch information...
Vassyli committed Apr 20, 2016
1 parent 7643277 commit 9986420b1091c7dc3809e018fd7bd62d34d8458c
BIN -11 KB dbtest.sqlite
Binary file not shown.
@@ -1,6 +1,6 @@
<phpunit bootstrap="bootstrap/bootstrap.php">
<php>
<var name="DB_DSN" value="sqlite:dbtest.sqlite" />
<var name="DB_DSN" value="sqlite::memory:" />
<var name="DB_USER" value="root" />
<var name="DB_PASSWORD" value="" />
<var name="DB_NAME" value="daenerys" />
@@ -2,7 +2,6 @@
namespace LotGD\Core\Models;
use LotGD\Core\Tools\Model\Creator;
use LotGD\Core\Tools\Model\Properties;
/**
@@ -3,10 +3,6 @@
namespace LotGD\Core\Tools\Model;
const PROPERTY_STRING = 0;
const PROPERTY_INT = 1;
const PROPERTY_FLOAT = 2;
/**
* Provides method and doctrine annotation for a property submodel
*/
@@ -33,7 +29,7 @@ public function getName(): string
*/
public function setName(string $name)
{
if($name === "") {
if ($name === "") {
throw new ArgumentEmptyException('The argument $name must not be empty.');
}
@@ -4,6 +4,7 @@
namespace LotGD\Core\Tests\Models;
use LotGD\Core\Models\Character;
use LotGD\Core\Models\CharacterProperty;
use LotGD\Core\Tests\ModelTestCase;
/**
@@ -107,6 +108,9 @@ public function testDeletion()
$rowsAfter = count($em->getRepository(Character::class)->findAll());
$this->assertEquals($rowsBefore - 1, $rowsAfter);
// test flushing
$em->flush();
}
/**
@@ -131,7 +135,24 @@ public function testProperties()
$this->assertNotSame(20, $firstCharacter->getProperty("dragonkills"));
$this->assertSame("20", $firstCharacter->getProperty("dragonkills"));
// save some other variables
$firstCharacter->setProperty("testvar1", 5);
$firstCharacter->setProperty("testvar2", [5 => 18]);
$firstCharacter->setProperty("testvar3 9 8", "spam and eggs");
$firstCharacter->setProperty("testvar4", true);
// test precreated property
$this->assertSame("hallo", $firstCharacter->getProperty("test"));
// test flushing
$em->flush();
// revisit database and retrieve properties, check if the correct number is saved
$total = intval($em->createQueryBuilder()
->from(CharacterProperty::class, "u")
->select("COUNT(u.propertyName)")
->getQuery()->getSingleScalarResult());
$this->assertSame(6, $total);
}
}

0 comments on commit 9986420

Please sign in to comment.
You can’t perform that action at this time.