|
1 | 1 | <?php |
2 | 2 | namespace TapestryCloud\Asset\Tests; |
| 3 | +use Doctrine\ORM\EntityManager; |
| 4 | +use Doctrine\ORM\Tools\SchemaTool; |
| 5 | +use Doctrine\ORM\Tools\Setup; |
3 | 6 | use Symfony\Component\Console\Input\ArrayInput; |
4 | 7 | use Symfony\Component\Console\Output\NullOutput; |
5 | 8 | use Tapestry\Console\DefaultInputDefinition; |
| 9 | +use Tapestry\Entities\Configuration; |
6 | 10 | use Tapestry\Entities\Project; |
7 | 11 | use Tapestry\Generator; |
8 | 12 | use Tapestry\Tapestry; |
| 13 | + |
9 | 14 | class PluginTest extends \PHPUnit_Framework_TestCase |
10 | 15 | { |
| 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 | + |
11 | 54 | public function testPlugin(){ |
12 | 55 | $definitions = new DefaultInputDefinition(); |
13 | 56 | $tapestry = new Tapestry(new ArrayInput([ |
|
0 commit comments