public function tablesUnitTest::testFormatAutoWidths

8.0.x tablesUnitTest.php public tablesUnitTest::testFormatAutoWidths()
6.x tablesUnitTest.php public tablesUnitTest::testFormatAutoWidths()
7.x tablesUnitTest.php public tablesUnitTest::testFormatAutoWidths()
master tablesUnitTest.php public tablesUnitTest::testFormatAutoWidths()

Tests drush_format_table() at various table widths with automatic column sizing.

See also

drush_format_table().

File

tests/tablesUnitTest.php, line 38

Namespace

Unish

Class

tablesUnitTest
Unit tests for table formatting.

Code

public function testFormatAutoWidths() {
  // print "\n'" . str_replace("\n", "' . PHP_EOL . '", $output) . "'\n";
  drush_set_context('DRUSH_COLUMNS', 16);
  $output = drush_format_table($this->numbers);
  $expected = ' 1    12   123  ' . PHP_EOL . ' 123  123  1234 ' . PHP_EOL . ' 4    45   56   ' . PHP_EOL . ' 123  123  1234 ' . PHP_EOL . ' 456  456  5678 ' . PHP_EOL . ' 7    78   9    ' . PHP_EOL;
  $this->assertEquals($expected, $output);

  drush_set_context('DRUSH_COLUMNS', 22);
  $output = drush_format_table($this->numbers);
  $expected = ' 1      12     123    ' . PHP_EOL . ' 1234   12345  123456 ' . PHP_EOL . ' 12345  12345  123456 ' . PHP_EOL . ' 67     678    789    ' . PHP_EOL;
  $this->assertEquals($expected, $output);

  drush_set_context('DRUSH_COLUMNS', 24);
  $output = drush_format_table($this->numbers);
  $expected = ' 1       12      123    ' . PHP_EOL . ' 1234    12345   123456 ' . PHP_EOL . ' 123456  123456  123456 ' . PHP_EOL . ' 7       78      789    ' . PHP_EOL;
  $this->assertEquals($expected, $output);

  drush_set_context('DRUSH_COLUMNS', 80);
  $output = drush_format_table($this->numbers);
  $expected = ' 1        12        123       ' . PHP_EOL . ' 1234     12345     123456    ' . PHP_EOL . ' 1234567  12345678  123456789 ' . PHP_EOL;
  $this->assertEquals($expected, $output);
}