Fixed Test
This commit is contained in:
@@ -9,6 +9,7 @@ use Doctrine\ORM\{
|
||||
Tools\SchemaTool
|
||||
};
|
||||
use Doctrine\ORM\Mapping\{
|
||||
AnsiQuoteStrategy,
|
||||
ClassMetadata,
|
||||
Driver\DriverChain,
|
||||
Driver\AnnotationDriver
|
||||
@@ -28,20 +29,15 @@ abstract class ModelTestCase extends \PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
protected function setUp() {
|
||||
$configuration = Setup::createAnnotationMetadataConfiguration(["src/Models"], true);
|
||||
$configuration->setQuoteStrategy(new AnsiQuoteStrategy());
|
||||
|
||||
$this->_em = EntityManager::create(["url" => "sqlite:///:memory:"], $configuration);
|
||||
|
||||
$metaData = $this->_em->getMetadataFactory()->getAllMetadata();
|
||||
|
||||
// Create Schema
|
||||
$schemaTool = new SchemaTool($this->_em);
|
||||
|
||||
$metaClasses = [];
|
||||
foreach($this->entities as $entity) {
|
||||
$metaClasses[] = new ClassMetadata($entity);
|
||||
}
|
||||
|
||||
var_dump($metaClasses[0]);
|
||||
|
||||
$schemaTool->createSchema($metaClasses);
|
||||
$schemaTool->createSchema($metaData);
|
||||
}
|
||||
|
||||
protected function getEntityManager() {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<phpunit bootstrap="bootstrap/bootstrap.php">
|
||||
<testsuites>
|
||||
<testsuite name="Models">
|
||||
<directory>tests/Models</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
@@ -8,14 +8,42 @@ use Doctrine\ORM\Mapping\Entity;
|
||||
* Description of Character
|
||||
*
|
||||
* @Entity
|
||||
* @Table(name="Characters")
|
||||
* @Table(name="characters")
|
||||
*/
|
||||
class Character {
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
private $id;
|
||||
/** @Column(type="string", length=255, unique=true); */
|
||||
/** @Column(type="string", length=50, unique=true); */
|
||||
private $name;
|
||||
/** @Column(type="text", unique=true); */
|
||||
private $displayName;
|
||||
/** @Column(type="integer", options={"default" = 10}) */
|
||||
private $health = 10;
|
||||
/** @Column(type="integer", options={"default" = 10}) */
|
||||
private $maxhealth = 10;
|
||||
private $properties;
|
||||
|
||||
/**
|
||||
* Sets the character's name and generates the display name
|
||||
* @param string $name The name to set
|
||||
*/
|
||||
public function setName(string $name) {
|
||||
$this->name = $name;
|
||||
$this->generateDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the character's name
|
||||
* @return string The name
|
||||
*/
|
||||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the display name which is a composition of title and name.
|
||||
*/
|
||||
protected function generateDisplayName() {
|
||||
$this->displayName = $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user