From 4a83759ca93e2b858246645e82a91248319a4bec Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 14 Jul 2012 01:36:12 +0200 Subject: [PATCH] Restoring dialog helper (required for migrations as of doctrine/DoctrineORMModule#78 ) with tests --- .travis/Version20120714005702.php | 44 +++++++++++++++++++++++++++ .travis/migrations-execute-config.xml | 11 +++++++ .travis/run-cli.sh | 3 +- src/DoctrineORMModule/Module.php | 23 +++++++------- 4 files changed, 69 insertions(+), 12 deletions(-) create mode 100644 .travis/Version20120714005702.php create mode 100644 .travis/migrations-execute-config.xml diff --git a/.travis/Version20120714005702.php b/.travis/Version20120714005702.php new file mode 100644 index 00000000..31f9413a --- /dev/null +++ b/.travis/Version20120714005702.php @@ -0,0 +1,44 @@ +. + */ + +namespace TravisDoctrineMigrations; + +use Doctrine\DBAL\Migrations\AbstractMigration, + Doctrine\DBAL\Schema\Schema; + +/** + * Empty test migration used for testing + */ +class Version20120714005702 extends AbstractMigration +{ + /** + * {@inheritDoc} + */ + public function up(Schema $schema) + { + $this->addSql("SELECT 'Migration succeeded!'"); + } + + /** + * {@inheritDoc} + */ + public function down(Schema $schema) + { + } +} diff --git a/.travis/migrations-execute-config.xml b/.travis/migrations-execute-config.xml new file mode 100644 index 00000000..8fb62d80 --- /dev/null +++ b/.travis/migrations-execute-config.xml @@ -0,0 +1,11 @@ + + + doctrine-migrations configuration for travis tests (running preset migrations) + TravisDoctrineMigrations + + vendor/doctrine/doctrine-orm-module/.travis + diff --git a/.travis/run-cli.sh b/.travis/run-cli.sh index 70478d49..eb0600cc 100755 --- a/.travis/run-cli.sh +++ b/.travis/run-cli.sh @@ -13,4 +13,5 @@ ./vendor/bin/doctrine-module orm:run-dql "SELECT COUNT(a) FROM DoctrineORMModuleTest\Assets\Entity\Test a" ./vendor/bin/doctrine-module orm:schema-tool:drop ./vendor/bin/doctrine-module migrations:generate --configuration=vendor/doctrine/doctrine-orm-module/.travis/migrations-config.xml -./vendor/bin/doctrine-module migrations:diff --configuration=vendor/doctrine/doctrine-orm-module/.travis/migrations-config.xml \ No newline at end of file +./vendor/bin/doctrine-module migrations:diff --configuration=vendor/doctrine/doctrine-orm-module/.travis/migrations-config.xml +./vendor/bin/doctrine-module migrations:execute 20120714005702 -n --configuration=vendor/doctrine/doctrine-orm-module/.travis/migrations-execute-config.xml \ No newline at end of file diff --git a/src/DoctrineORMModule/Module.php b/src/DoctrineORMModule/Module.php index 23b195c7..5e9993e8 100644 --- a/src/DoctrineORMModule/Module.php +++ b/src/DoctrineORMModule/Module.php @@ -13,14 +13,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see + * and is licensed under the MIT license. For more information, see * . */ namespace DoctrineORMModule; use Doctrine\Common\Annotations\AnnotationRegistry; -use Doctrine\ORM\Tools\Console\ConsoleRunner as ORMConsoleRunner; +use Doctrine\ORM\Tools\Console\ConsoleRunner; use DoctrineModule\Service as CommonService; use DoctrineORMModule\Service as ORMService; @@ -31,6 +31,9 @@ use Zend\ServiceManager\ServiceLocatorInterface; use Zend\EventManager\EventInterface; +use Symfony\Component\Console\Helper\DialogHelper; +use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper; +use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; use Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand; use Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand; use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand; @@ -43,10 +46,8 @@ /** * Base module for Doctrine ORM. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @license MIT * @link www.doctrine-project.org - * @since 1.0 - * @version $Revision$ * @author Kyle Spraggs * @author Marco Pivetta */ @@ -57,7 +58,7 @@ class Module implements ServiceProviderInterface, ConfigProviderInterface */ public function init(ModuleManagerInterface $moduleManager) { - AnnotationRegistry::registerLoader(function ($className) { + AnnotationRegistry::registerLoader(function($className) { return class_exists($className); }); } @@ -76,7 +77,7 @@ public function onBootstrap(EventInterface $e) /* @var $cli \Symfony\Component\Console\Application */ $cli = $e->getTarget(); - ORMConsoleRunner::addCommands($cli); + ConsoleRunner::addCommands($cli); $cli->addCommands(array( new DiffCommand(), new ExecuteCommand(), @@ -90,10 +91,10 @@ public function onBootstrap(EventInterface $e) $sm = $e->getParam('ServiceManager'); /* @var $em \Doctrine\ORM\EntityManager */ $em = $sm->get('doctrine.entitymanager.orm_default'); - $db = new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()); - $eh = new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em); - $cli->getHelperSet()->set($db, 'db'); - $cli->getHelperSet()->set($eh, 'em'); + $helperSet = $cli->getHelperSet(); + $helperSet->set(new DialogHelper(), 'dialog'); + $helperSet->set(new ConnectionHelper($em->getConnection()), 'db'); + $helperSet->set(new EntityManagerHelper($em), 'em'); }); }