From 592b1db21e63801c0cb26533a115c2a287d60367 Mon Sep 17 00:00:00 2001 From: Baldur Rensch Date: Sun, 22 Dec 2013 19:06:09 -0800 Subject: [PATCH] Functional Test Base added --- Resources/config/services.xml | 2 +- Tests/Functional/AppKernel.php | 29 ++++++++++++ .../Command/DoctrineFixtureTest.php | 27 ++++++++++++ Tests/Functional/ControllerTest.php | 14 ++++++ .../TestBundle/Controller/RootController.php | 15 +++++++ .../TestBundle/Resources/config/services.yml | 1 + Tests/Functional/TestBundle/TestBundle.php | 9 ++++ Tests/Functional/TestCase.php | 44 +++++++++++++++++++ Tests/Functional/config/config.yml | 10 +++++ Tests/Functional/config/config_test.yml | 5 +++ Tests/Functional/config/routing.yml | 4 ++ composer.json | 5 ++- 12 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 Tests/Functional/AppKernel.php create mode 100644 Tests/Functional/Command/DoctrineFixtureTest.php create mode 100644 Tests/Functional/ControllerTest.php create mode 100644 Tests/Functional/TestBundle/Controller/RootController.php create mode 100644 Tests/Functional/TestBundle/Resources/config/services.yml create mode 100644 Tests/Functional/TestBundle/TestBundle.php create mode 100644 Tests/Functional/TestCase.php create mode 100644 Tests/Functional/config/config.yml create mode 100644 Tests/Functional/config/config_test.yml create mode 100644 Tests/Functional/config/routing.yml diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 270d7f2a..7a65f06e 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -21,7 +21,7 @@ - + diff --git a/Tests/Functional/AppKernel.php b/Tests/Functional/AppKernel.php new file mode 100644 index 00000000..de408a33 --- /dev/null +++ b/Tests/Functional/AppKernel.php @@ -0,0 +1,29 @@ +load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); + } +} diff --git a/Tests/Functional/Command/DoctrineFixtureTest.php b/Tests/Functional/Command/DoctrineFixtureTest.php new file mode 100644 index 00000000..f445724c --- /dev/null +++ b/Tests/Functional/Command/DoctrineFixtureTest.php @@ -0,0 +1,27 @@ +add(new LoadDataFixturesDoctrineCommand()); + $command = $application->find('doctrine:fixtures:load'); +// $command = new \Symfony\Component\Console\Command\Command(); + + $commandTester = new CommandTester($command); + $commandTester->execute(array()); + + $display = $commandTester->getDisplay(); + + var_dump($display); + } +} diff --git a/Tests/Functional/ControllerTest.php b/Tests/Functional/ControllerTest.php new file mode 100644 index 00000000..faaa9980 --- /dev/null +++ b/Tests/Functional/ControllerTest.php @@ -0,0 +1,14 @@ +createClient(); + } +} diff --git a/Tests/Functional/TestBundle/Controller/RootController.php b/Tests/Functional/TestBundle/Controller/RootController.php new file mode 100644 index 00000000..1af1daeb --- /dev/null +++ b/Tests/Functional/TestBundle/Controller/RootController.php @@ -0,0 +1,15 @@ +boot(); + } + + protected static function getKernel() + { + static::initializeKernel(); + + return static::$kernel; + } + + protected function setUp() + { + $fs = new Filesystem(); + $fs->remove(sys_get_temp_dir().'/AliceBundle/'); + } + + protected function tearDown() + { + static::$kernel = null; + } +} diff --git a/Tests/Functional/config/config.yml b/Tests/Functional/config/config.yml new file mode 100644 index 00000000..2b36795d --- /dev/null +++ b/Tests/Functional/config/config.yml @@ -0,0 +1,10 @@ +imports: + - { resource: "@TestBundle/Resources/config/services.yml" } + +framework: + secret: test + router: + resource: "%kernel.root_dir%/config/routing.yml" + form: ~ + validation: ~ + session: ~ diff --git a/Tests/Functional/config/config_test.yml b/Tests/Functional/config/config_test.yml new file mode 100644 index 00000000..8cdccf7c --- /dev/null +++ b/Tests/Functional/config/config_test.yml @@ -0,0 +1,5 @@ +imports: + - { resource: config.yml } + +framework: + test: ~ diff --git a/Tests/Functional/config/routing.yml b/Tests/Functional/config/routing.yml new file mode 100644 index 00000000..ddc647de --- /dev/null +++ b/Tests/Functional/config/routing.yml @@ -0,0 +1,4 @@ +api_root: + pattern: /test + defaults: + _controller: TestBundle:Root:test diff --git a/composer.json b/composer.json index 63febb29..bdf184aa 100644 --- a/composer.json +++ b/composer.json @@ -12,12 +12,13 @@ ], "require": { "php": ">=5.3.0", - "nelmio/alice": "~1.5", + "nelmio/alice": "~1.6", "doctrine/doctrine-fixtures-bundle": "~2.2", - "doctrine/data-fixtures": "~1.0" + "doctrine/doctrine-bundle": "~1.2" }, "require-dev": { "symfony/framework-bundle": "~2.1", + "symfony/console": "~2.1", "symfony/yaml": "~2.1" }, "autoload": {