sqlConnectTest.php

  1. 6.x tests/sqlConnectTest.php
  2. 5.x tests/sqlConnectTest.php

Classes

Namesort descending Description
SqlConnectCase

File

tests/sqlConnectTest.php
View source
  1. <?php
  2. /*
  3. * @file
  4. * Tests sql-connect command
  5. *
  6. * Installs Drupal and checks that the given URL by sql-connect is correct.
  7. * @TODO: test Postgre-SQL and Sqlite.
  8. *
  9. * @group commands
  10. */
  11. class SqlConnectCase extends Drush_CommandTestCase {
  12. function testSqlConnect() {
  13. $sites = $this->setUpDrupal(1, TRUE);
  14. $options = array(
  15. 'yes' => NULL,
  16. 'root' => $this->webroot(),
  17. 'uri' => key($sites),
  18. );
  19. // @todo: extend to other DB platforms.
  20. if (strpos(UNISH_DB_URL, 'mysql') === FALSE) {
  21. $this->markTestSkipped('sql-connect tests need updating for non-mysql UNISH_DB_URL.');
  22. }
  23. // Get the connection details with sql-connect and check its structure.
  24. $this->drush('sql-connect', array(), $options);
  25. $output = $this->getOutput();
  26. $this->assertRegExp('/^mysql --database=[^\s]+ --host=[^\s]+ --user=[^\s]+ --password=.*$/', $output);
  27. // Issue a query and check the result to verify the connection.
  28. $this->execute($output . ' -e "select name from users where uid = 1;"');
  29. $output = $this->getOutput();
  30. $this->assertContains('admin', $output);
  31. }
  32. }