Skip to content

Commit 2b92ad5

Browse files
committed
✅ unit test now setups and drops database
1 parent 1271afb commit 2b92ad5

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tests/PluginTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,56 @@
11
<?php
22
namespace TapestryCloud\Asset\Tests;
3+
use Doctrine\ORM\EntityManager;
4+
use Doctrine\ORM\Tools\SchemaTool;
5+
use Doctrine\ORM\Tools\Setup;
36
use Symfony\Component\Console\Input\ArrayInput;
47
use Symfony\Component\Console\Output\NullOutput;
58
use Tapestry\Console\DefaultInputDefinition;
9+
use Tapestry\Entities\Configuration;
610
use Tapestry\Entities\Project;
711
use Tapestry\Generator;
812
use Tapestry\Tapestry;
13+
914
class PluginTest extends \PHPUnit_Framework_TestCase
1015
{
16+
17+
protected static $em;
18+
19+
/**
20+
* This method is called before the first test of this test class is run.
21+
*
22+
* @inheritdoc
23+
*/
24+
public static function setUpBeforeClass()
25+
{
26+
$configuration = new Configuration(include __DIR__ . '/mock_project/config.php');
27+
28+
$em = EntityManager::create(
29+
$configuration->get('plugins.database', []),
30+
Setup::createAnnotationMetadataConfiguration(
31+
[
32+
realpath(__DIR__ . '/../src/Entities')
33+
],
34+
true
35+
)
36+
);
37+
$tool = new SchemaTool($em);
38+
$tool->createSchema($em->getMetadataFactory()->getAllMetadata());
39+
40+
self::$em = $em;
41+
}
42+
43+
/**
44+
* This method is called after the last test of this test class is run.
45+
*
46+
* @inheritdoc
47+
*/
48+
public static function tearDownAfterClass()
49+
{
50+
$tool = new SchemaTool(self::$em);
51+
$tool->dropDatabase();
52+
}
53+
1154
public function testPlugin(){
1255
$definitions = new DefaultInputDefinition();
1356
$tapestry = new Tapestry(new ArrayInput([

0 commit comments

Comments
 (0)