Basic commit

Added meta data files (gitattribute to normalize line ending,
gitignore), as well as a simple Model and non-working tests.
This commit is contained in:
Basilius Sauter
2016-04-14 23:57:17 +02:00
parent be01f8c1b6
commit 5e06171bec
9 changed files with 2353 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
*.php text eol=lf
+226
View File
@@ -0,0 +1,226 @@
vendor/
pdo.sqlite
#################
## NetBeans
#################
nbproject/
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
*.publishproj
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[cod]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg
dbconfig.php
+50
View File
@@ -0,0 +1,50 @@
<?php
namespace LotGD\Core\Tests;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\ORM\{
EntityManager,
Tools\Setup,
Tools\SchemaTool
};
use Doctrine\ORM\Mapping\{
ClassMetadata,
Driver\DriverChain,
Driver\AnnotationDriver
};
/**
* Description of ModelTestCase
*/
abstract class ModelTestCase extends \PHPUnit_Framework_TestCase {
/** @var array */
protected $entities = [];
/** @var Doctrine\ORM\EntityManager */
protected $_em;
/**
* Sets up the database and database structure
*/
protected function setUp() {
$configuration = Setup::createAnnotationMetadataConfiguration(["src/Models"], true);
$this->_em = EntityManager::create(["url" => "sqlite:///:memory:"], $configuration);
// Create Schema
$schemaTool = new SchemaTool($this->_em);
$metaClasses = [];
foreach($this->entities as $entity) {
$metaClasses[] = new ClassMetadata($entity);
}
var_dump($metaClasses[0]);
$schemaTool->createSchema($metaClasses);
}
protected function getEntityManager() {
return $this->_em;
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace LotGD\Core\Tests\Models;
use LotGD\Core\Models\Character;
use LotGD\Core\Tests\ModelTestCase;
use Doctrine\ORM\Mapping as ORM;
/**
* Description of CharacterModelTest
*
* @author Basilius Sauter
*/
class CharacterModelTest extends ModelTestCase {
/** @var array */
protected $entities = [Character::class];
public function testCreationQuery() {
$queryBuilder = $this->_em->getRepository(Character::class)->find(1);
$character = new Character();
$character->setName("Test");
}
}
+3
View File
@@ -0,0 +1,3 @@
<?php
$autoloader = require __DIR__ . "/../vendor/autoload.php";
+16
View File
@@ -0,0 +1,16 @@
<?php
require __DIR__ . "/bootstrap/bootstrap.php";
use Doctrine\ORM\{
EntityManager,
Mapping\AnsiQuoteStrategy,
Tools\Setup
};
$configuration = Setup::createAnnotationMetadataConfiguration(["src/Models"], true);
$configuration->setQuoteStrategy(new \Doctrine\ORM\Mapping\AnsiQuoteStrategy());
$entityManager = EntityManager::create(["url" => "sqlite://:memory:"], $configuration);
return Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($entityManager);
+18
View File
@@ -0,0 +1,18 @@
{
"autoload": {
"psr-4": {
"LotGD\\Core\\": "src/",
"LotGD\\Core\\Tests\\": "tests/"
}
},
"require": {
"monolog/monolog": "1.16.0",
"doctrine/orm": "2.5.*"
},
"require-dev": {
"phpunit/phpunit": "*",
"phpunit/dbunit": "*"
}
}
Generated
+1993
View File
File diff suppressed because it is too large Load Diff
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace LotGD\Core\Models;
use Doctrine\ORM\Mapping\Entity;
/**
* Description of Character
*
* @Entity
* @Table(name="Characters")
*/
class Character {
/** @Id @Column(type="integer") @GeneratedValue */
private $id;
/** @Column(type="string", length=255, unique=true); */
private $name;
private $health = 10;
private $maxhealth = 10;
private $properties;
}