public function outputFormatCase::testOutputFormatWithDrupal

8.0.x outputFormatTest.php public outputFormatCase::testOutputFormatWithDrupal()
6.x outputFormatTest.php public outputFormatCase::testOutputFormatWithDrupal()
7.x outputFormatTest.php public outputFormatCase::testOutputFormatWithDrupal()

Test output formats using various Drush commands on a Drupal site.

Cannot use dataProvider since we want to share one setUpDrupal(),

File

tests/outputFormatTest.php, line 22

Namespace

Unish

Class

outputFormatCase
@todo, Consider removing these tests now that we have outputFormatUnitCase.

Code

public function testOutputFormatWithDrupal() {
  $data = $this->getDataForDrupal();
  $sites = $this->setUpDrupal(1, TRUE);
  $site_options = array(
    'root' => $this->webroot(),
    'uri' => key($sites),
  );
  $this->drush('pm-download', array('devel'), $site_options + array('cache' => NULL, 'skip' => TRUE));

  foreach ($data as $row) {
    extract($row);
    $name = $name . ": ";
    // We need to specify a fixed column width so that word wrapping does
    // not change our output contrary to our expectations when run in
    // a narrow terminal window.
    $env = array(
      'COLUMNS' => '800',
    );
    $this->drush($command, $args, $site_options + $options + array('format' => $format), NULL, NULL, self::EXIT_SUCCESS, NULL, $env);
    $output = implode("\n", $this->getOutputAsList()); // note: we consider trailing eols insignificant
    // If the Drupal command we are running might produce variable output,
    // we can use one or more output filters to simplify the output down
    // to an invariant form.
    foreach ($output_filter as $regex => $replacement) {
      $output = preg_replace($regex, $replacement, $output);
    }
    $this->assertEquals($name . $expected, $name . $output);
  }
}