Skip to content

Commit

Permalink
[Console] Added server parameter to test:prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Nov 29, 2011
1 parent 2a27158 commit 5de7929
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 20 deletions.
29 changes: 26 additions & 3 deletions src/Propel/Generator/Command/PrepareTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@
*/
class PrepareTests extends Command
{
/**
* @var string
*/
const DEFAULT_VENDOR = 'mysql';

/**
* @var string
*/
const DEFAULT_DB_SERVER = '127.0.0.1';

/**
* @var string
*/
const DEFAULT_DB_USER = 'root';

/**
* @var string
*/
const DEFAULT_DB_PASSWD = '';

/**
* @var array
*/
Expand Down Expand Up @@ -49,9 +69,10 @@ protected function configure()
{
$this
->setDefinition(array(
new InputOption('vendor', null, InputOption::VALUE_REQUIRED, 'The database vendor', 'mysql'),
new InputOption('user', 'u', InputOption::VALUE_REQUIRED, 'The database user', 'root'),
new InputOption('password', 'p', InputOption::VALUE_REQUIRED, 'The database password', ''),
new InputOption('vendor', null, InputOption::VALUE_REQUIRED, 'The database vendor', self::DEFAULT_VENDOR),
new InputOption('server', 's', InputOption::VALUE_REQUIRED, 'The database server', self::DEFAULT_DB_SERVER),
new InputOption('user', 'u', InputOption::VALUE_REQUIRED, 'The database user', self::DEFAULT_DB_USER),
new InputOption('password', 'p', InputOption::VALUE_REQUIRED, 'The database password', selft::DEFAULT_DB_PASSWD),
new InputOption('fixtures-dir', null, InputOption::VALUE_REQUIRED, 'A fixture directory to build', null),
))
->setName('test:prepare')
Expand Down Expand Up @@ -91,6 +112,7 @@ protected function buildFixtures($fixturesDir, InputInterface $input, OutputInte
$content = file_get_contents('build.properties.dist');

$content = str_replace('##DATABASE_VENDOR##', $input->getOption('vendor'), $content);
$content = str_replace('##DATABASE_SERVER##', $input->getOption('server'), $content);
$content = str_replace('##DATABASE_USER##', $input->getOption('user'), $content);
$content = str_replace('##DATABASE_PASSWORD##', $input->getOption('password'), $content);

Expand All @@ -104,6 +126,7 @@ protected function buildFixtures($fixturesDir, InputInterface $input, OutputInte
$content = file_get_contents('runtime-conf.xml.dist');

$content = str_replace('##DATABASE_VENDOR##', $input->getOption('vendor'), $content);
$content = str_replace('##DATABASE_SERVER##', $input->getOption('server'), $content);
$content = str_replace('##DATABASE_USER##', $input->getOption('user'), $content);
$content = str_replace('##DATABASE_PASSWORD##', $input->getOption('password'), $content);

Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/bookstore/build.properties.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

propel.project = bookstore
propel.database = ##DATABASE_VENDOR##
propel.database.url = ##DATABASE_VENDOR##:dbname=test
propel.database.url = ##DATABASE_VENDOR##:##DATABASE_SERVER##;dbname=test
propel.mysql.tableType = InnoDB
propel.disableIdentifierQuoting = true
propel.schema.autoPrefix = false
Expand Down
6 changes: 3 additions & 3 deletions tests/Fixtures/bookstore/runtime-conf.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- Connection parameters. See PDO documentation for DSN format and available option constants. -->
<connection>
<classname>\Propel\Runtime\Connection\DebugPDO</classname>
<dsn>##DATABASE_VENDOR##:dbname=test</dsn>
<dsn>##DATABASE_VENDOR##:##DATABASE_SERVER##;dbname=test</dsn>
<user>##DATABASE_USER##</user>
<password>##DATABASE_PASSWORD##</password>
<options>
Expand Down Expand Up @@ -48,7 +48,7 @@
<adapter>##DATABASE_VENDOR##</adapter>
<connection>
<classname>\Propel\Runtime\Connection\DebugPDO</classname>
<dsn>##DATABASE_VENDOR##:dbname=test</dsn>
<dsn>##DATABASE_VENDOR##:##DATABASE_SERVER##;dbname=test</dsn>
<user>##DATABASE_USER##</user>
<password>##DATABASE_PASSWORD##</password>
<options>
Expand All @@ -67,7 +67,7 @@
<adapter>##DATABASE_VENDOR##</adapter>
<connection>
<classname>\Propel\Runtime\Connection\DebugPDO</classname>
<dsn>##DATABASE_VENDOR##:dbname=test</dsn>
<dsn>##DATABASE_VENDOR##:##DATABASE_SERVER##;dbname=test</dsn>
<user>##DATABASE_USER##</user>
<password>##DATABASE_PASSWORD##</password>
<options>
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/namespaced/build.properties.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

propel.project = bookstore_namespaced
propel.database = ##DATABASE_VENDOR##
propel.database.url = ##DATABASE_VENDOR##:dbname=test
propel.database.url = ##DATABASE_VENDOR##:##DATABASE_SERVER##;dbname=test
propel.mysql.tableType = InnoDB
propel.disableIdentifierQuoting = true

Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/namespaced/runtime-conf.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- Connection parameters. See PDO documentation for DSN format and available option constants. -->
<connection>
<classname>\Propel\Runtime\Connection\DebugPDO</classname>
<dsn>##DATABASE_VENDOR##:dbname=test</dsn>
<dsn>##DATABASE_VENDOR##:##DATABASE_SERVER##;dbname=test</dsn>
<user>##DATABASE_USER##</user>
<password>##DATABASE_PASSWORD##</password>
<options>
Expand Down
6 changes: 3 additions & 3 deletions tests/Fixtures/reverse/mysql/build.properties.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
propel.project = reverse_bookstore

propel.database = mysql
propel.database.url = mysql:dbname=reverse_bookstore
propel.database.url = mysql:##DATABASE_SERVER##;dbname=reverse_bookstore

# For MySQL or Oracle, you also need to specify username & password
#propel.database.user = [db username]
#propel.database.password = [db password]
propel.database.user = ##DATABASE_USER##
propel.database.password = ##DATABASE_PASSWORD##

propel.mysql.tableType = InnoDB

Expand Down
9 changes: 3 additions & 6 deletions tests/Fixtures/reverse/mysql/runtime-conf.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@
<adapter>mysql</adapter>
<connection>
<classname>\Propel\Runtime\Connection\DebugPDO</classname>
<dsn>mysql:dbname=reverse_bookstore</dsn>
<!--
For MySQL and Oracle you must specify username + password separate from DSN:
<user>bookstore</user>
<password></password>
-->
<dsn>mysql:##DATABASE_SERVER##;dbname=reverse_bookstore</dsn>
<user>##DATABASE_USER##</user>
<password>##DATABASE_PASSWORD##</password>
<options>
<option id="ATTR_PERSISTENT">false</option>
</options>
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/schemas/build.properties.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

propel.project = bookstore
propel.database = ##DATABASE_VENDOR##
propel.database.url = ##DATABASE_VENDOR##:dbname=test
propel.database.url = ##DATABASE_VENDOR##:##DATABASE_SERVER##;dbname=test
propel.database.user = ##DATABASE_USER##
propel.database.password = ##DATABASE_PASSWORD##
propel.mysql.tableType = InnoDB
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/schemas/runtime-conf.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<adapter>##DATABASE_VENDOR##</adapter>
<connection>
<classname>\Propel\Runtime\Connection\DebugPDO</classname>
<dsn>##DATABASE_VENDOR##:dbname=test</dsn>
<dsn>##DATABASE_VENDOR##:##DATABASE_SERVER##;dbname=test</dsn>
<user>##DATABASE_USER##</user>
<password>##DATABASE_PASSWORD##</password>
<options>
Expand Down

0 comments on commit 5de7929

Please sign in to comment.