This repository has been archived by the owner on Jul 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
BaseTestGeneratedRestController.php
63 lines (58 loc) · 2.84 KB
/
BaseTestGeneratedRestController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Tpg\ExtjsBundle\Tests\Command;
include_once(__DIR__ . '/../app/AppKernel.php');
use Doctrine\Bundle\MongoDBBundle\Command\CreateSchemaDoctrineODMCommand;
use Doctrine\Bundle\MongoDBBundle\Command\DropSchemaDoctrineODMCommand;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand;
use Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand;
use Doctrine\Bundle\DoctrineBundle\Command\Proxy\CreateSchemaDoctrineCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Routing\Router;
use Tpg\ExtjsBundle\Command\GenerateRestControllerCommand;
class BaseTestGeneratedRestController extends WebTestCase {
public static function setUpBeforeClass() {
@unlink(__DIR__.'/../Fixtures/Test/TestBundle/Resources/config/routing.rest.yml');
@unlink(__DIR__.'/../Fixtures/Test/TestBundle/Controller/CarController.php');
@unlink(__DIR__.'/../Fixtures/Test/TestBundle/Controller/OrderController.php');
$kernel = new \AppKernel('test', true);
$app = new Application($kernel);
$app->addCommands(array(
new GenerateRestControllerCommand(),
));
$kernel->boot();
$command = $app->find('generate:rest:controller');
$commandTester = new CommandTester($command);
$commandTester->execute(array(
'command' => $command->getName(),
'--controller' => 'TestTestBundle:Order',
'--entity' => 'TestTestBundle:Order',
'--mongo' => true,
), array('interactive'=>false));
$kernel->shutdown();
$kernel = new \AppKernel('test', true);
$app = new Application($kernel);
$app->addCommands(array(
new GenerateRestControllerCommand(),
));
$kernel->boot();
$command = $app->find('generate:rest:controller');
$commandTester = new CommandTester($command);
$commandTester->execute(array(
'command' => $command->getName(),
'--controller' => 'TestTestBundle:Car',
'--entity' => 'TestTestBundle:Car'
), array('interactive'=>false));
$kernel->shutdown();
@unlink(__DIR__.'/../app/cache/test/appTestUrlGenerator.php.meta');
@unlink(__DIR__.'/../app/cache/test/appTestUrlGenerator.php');
@unlink(__DIR__.'/../app/cache/test/appTestUrlMatcher.php.meta');
@unlink(__DIR__.'/../app/cache/test/appTestUrlMatcher.php');
}
public static function tearDownAfterClass() {
@unlink(__DIR__.'/../Fixtures/Test/TestBundle/Resources/config/routing.rest.yml');
@unlink(__DIR__.'/../Fixtures/Test/TestBundle/Controller/CarController.php');
@unlink(__DIR__.'/../Fixtures/Test/TestBundle/Controller/OrderController.php');
}
}