class WildcardUnitCase

  1. 8.0.x tests/expandWildcardTablesUnitTest.php WildcardUnitCase
  2. 6.x tests/expandWildcardTablesUnitTest.php WildcardUnitCase
  3. 7.x tests/expandWildcardTablesUnitTest.php WildcardUnitCase
  4. master tests/expandWildcardTablesUnitTest.php WildcardUnitCase

Unit tests for drush_sql_expand_wildcard_tables and drush_sql_filter_tables.

@group base @group sql

Namespace

Unish

Hierarchy

Expanded class hierarchy of WildcardUnitCase

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
UnishTestCase::$sites private static property A list of Drupal sites that have been recently installed.
UnishTestCase::bit_bucket function Borrowed from Drush. Checks operating system and returns supported bit bucket folder.
UnishTestCase::convert_path function Converts a Windows path (dir1\dir2\dir3) into a Unix path (dir1/dir2/dir3). Also converts a cygwin "drive emulation" path (/cygdrive/c/dir1) into a proper drive path, still with Unix slashes (c:/dir1).
UnishTestCase::db_driver function
UnishTestCase::db_url function
UnishTestCase::directory_cache function
UnishTestCase::drupalSitewideDirectory function
UnishTestCase::escapeshellarg public static function
UnishTestCase::fetchInstallDrupal function
UnishTestCase::getSites function
UnishTestCase::get_tar_executable public static function
UnishTestCase::is_windows public static function
UnishTestCase::log function Print a log message to the console.
UnishTestCase::log_level function
UnishTestCase::randomString public function Helper function to generate a random string of arbitrary length.
UnishTestCase::setUpDrupal function
UnishTestCase::setUpFreshSandBox public static function Remove any pre-existing sandbox, then create a new one.
UnishTestCase::tick function Print out a tick mark.
UnishTestCase::unish_file_aliases function Prepare the contents of an aliases file.
UnishTestCase::webroot function
UnishTestCase::writeSiteAlias function
UnishTestCase::_escapeshellarg_windows public static function
UnishTestCase::__construct function
UnitUnishTestCase::drush_major_version function
UnitUnishTestCase::tearDownAfterClass public static function Runs after all tests in a class are run. Remove sandbox directory. Overrides UnishTestCase::tearDownAfterClass
WildcardUnitCase::setUpBeforeClass public static function Minimally bootstrap drush Overrides UnitUnishTestCase::setUpBeforeClass
WildcardUnitCase::testExpandWildcardTables public function Tests drush_sql_expand_wildcard_tables().
WildcardUnitCase::testFilterTables public function Tests drush_sql_filter_tables().

File

tests/expandWildcardTablesUnitTest.php, line 12

View source
class WildcardUnitCase extends UnitUnishTestCase {

  public static function setUpBeforeClass() {
    parent::setUpBeforeClass();
    require_once (dirname(__FILE__) . '/../commands/sql/sql.drush.inc');
  }

  /**
   * Tests drush_sql_expand_wildcard_tables().
   *
   * @see drush_sql_expand_wildcard_tables().
   */
  public function testExpandWildcardTables() {
    // Array of tables to search for.
    $wildcard_input = array(
      'cache*',
    );
    // Mock array of tables to test with. This is
    // also the expected result.
    $db_tables = array(
      'cache',
      'cache_bootstrap',
      'cache_field',
      'cache_filter',
      'cache_form',
      'cache_menu',
      'cache_page',
      'cache_path',
      'cache_update',
      'example',
    );

    $expanded_db_tables = drush_sql_expand_wildcard_tables($wildcard_input, $db_tables);
    // We expect all but the last table to match.
    array_pop($db_tables);
    $this->assertEquals($db_tables, $expanded_db_tables);
  }

  /**
   * Tests drush_sql_filter_tables().
   *
   * @see drush_sql_filter_tables().
   */
  public function testFilterTables() {
    // Array of tables to search for.
    $wildcard_input = array(
      'cache',
      'cache_*',
    );
    // Mock array of tables to test with.
    $db_tables = array(
      'cache',
      'cache_bootstrap',
      'cache_field',
      'cache_filter',
      'cache_form',
      'cache_menu',
      'cache_page',
      'cache_path',
      'cache_update',
    );
    $expected_result = array(
      'cache',
    );

    $actual_result = drush_sql_filter_tables($wildcard_input, $db_tables);
    $this->assertEquals($expected_result, $actual_result);
  }
}