From 9db64bbe780b205d3be84bdf46342bba3cd3f52e Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 9 Jul 2013 10:52:37 +0200 Subject: [PATCH] complete install command and fix travis file --- .travis.yml | 5 ++++ core/lib/Thelia/Command/Install.php | 40 ++++++++++++++++++++++++++--- local/config/database.yml.sample | 0 3 files changed, 42 insertions(+), 3 deletions(-) mode change 100755 => 100644 local/config/database.yml.sample diff --git a/.travis.yml b/.travis.yml index 54448cbcd..cd1b18d6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,5 +4,10 @@ php: - "5.4" - "5.5" +env: + - DB_USER=root + before_script: - composer install + - sh -c "mysql -u$DB_USER -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS thelia;SET FOREIGN_KEY_CHECKS = 1;'; fi" + - php Thelia thelia:install --db_host=localhost --db_username=$DB_USER --db_name=thelia diff --git a/core/lib/Thelia/Command/Install.php b/core/lib/Thelia/Command/Install.php index 81f493701..9d4d4d1fd 100755 --- a/core/lib/Thelia/Command/Install.php +++ b/core/lib/Thelia/Command/Install.php @@ -41,6 +41,30 @@ class Install extends ContainerAwareCommand ->setName("thelia:install") ->setDescription("Install thelia using cli tools. For now Thelia only use mysql database") ->setHelp("The thelia:install command install Thelia database and create config file needed.") + ->addOption( + "db_host", + null, + InputOption::VALUE_OPTIONAL, + "host for your database" + ) + ->addOption( + "db_username", + null, + InputOption::VALUE_OPTIONAL, + "username for your database" + ) + ->addOption( + "db_password", + null, + InputOption::VALUE_OPTIONAL, + "password for your database" + ) + ->addOption( + "db_name", + null, + InputOption::VALUE_OPTIONAL, + "database name" + ) ; } @@ -56,9 +80,19 @@ class Install extends ContainerAwareCommand $this->checkPermission($output); - do { - $connectionInfo = $this->getConnectionInfo($input, $output); - } while(false === $connection = $this->tryConnection($connectionInfo, $output)); + + $connectionInfo = array( + "host" => $input->getOption("db_host"), + "dbName" => $input->getOption("db_name"), + "username" => $input->getOption("db_username"), + "password" => $input->getOption("db_password") + ); + + + + while(false === $connection = $this->tryConnection($connectionInfo, $output)) { + $connectionInfo = $this->getConnectionInfo($input, $output); + } $this->createDatabase($connection, $connectionInfo["dbName"]); diff --git a/local/config/database.yml.sample b/local/config/database.yml.sample old mode 100755 new mode 100644