Skip to content

Commit 56ebca2

Browse files
Test coverage for table constraining
1 parent bc28bac commit 56ebca2

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/test-table.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/**
4+
* Tests for cli\Table
5+
*/
6+
class Test_Table extends PHPUnit_Framework_TestCase {
7+
8+
public function test_column_value_too_long() {
9+
10+
$constaint_width = 80;
11+
12+
$table = new cli\Table;
13+
$renderer = new cli\Table\Ascii;
14+
$renderer->setConstraintWidth( $constaint_width );
15+
$table->setRenderer( $renderer );
16+
$table->setHeaders( array( 'Field', 'Value' ) );
17+
$table->addRow( array( 'description', 'The 2012 theme for WordPress is a fully responsive theme that looks great on any device. Features include a front page template with its own widgets, an optional display font, styling for post formats on both index and single views, and an optional no-sidebar page template. Make it yours with a custom menu, header image, and background.' ) );
18+
$table->addRow( array( 'author', '<a href="http://wordpress.org/" title="Visit author homepage">the WordPress team</a>' ) );
19+
20+
$out = $table->getDisplayLines();
21+
// "+ 1" accommodates "\n"
22+
$this->assertEquals( $constaint_width, strlen( $out[0] ) + 1 );
23+
$this->assertEquals( $constaint_width, strlen( $out[1] ) + 1 );
24+
$this->assertEquals( $constaint_width, strlen( $out[2] ) + 1 );
25+
$this->assertEquals( $constaint_width, strlen( $out[3] ) + 1 );
26+
$this->assertEquals( $constaint_width, strlen( $out[4] ) + 1 );
27+
$this->assertEquals( $constaint_width, strlen( $out[5] ) + 1 );
28+
$this->assertEquals( $constaint_width, strlen( $out[6] ) + 1 );
29+
$this->assertEquals( $constaint_width, strlen( $out[7] ) + 1 );
30+
$this->assertEquals( $constaint_width, strlen( $out[8] ) + 1 );
31+
$this->assertEquals( $constaint_width, strlen( $out[9] ) + 1 );
32+
$this->assertEquals( $constaint_width, strlen( $out[10] ) + 1 );
33+
$this->assertEquals( $constaint_width, strlen( $out[11] ) + 1 );
34+
35+
}
36+
37+
}

0 commit comments

Comments
 (0)