assertEquals( 2, count( $row ), "ezcConsoleTableRow not correctly created." ); } public function testCtorSuccess_2() { $row = new ezcConsoleTableRow(); $this->assertEquals( 0, count( $row ), "ezcConsoleTableRow not correctly created." ); } public function testCtorFailure() { /* * // Unneccessary, typehint! * $row = new ezcConsoleTableRow( 'foo' ); $this->assertEquals( 0, count( $row ), "ezcConsoleTableRow not correctly created." ); */ } public function testAppend() { $row = new ezcConsoleTableRow(); $row[]->content = 'foo'; $this->assertTrue( $row[0] instanceof ezcConsoleTableCell, "ezcConsoleTableCell not correctly created on write access." ); } public function testOntheflyCreationRead_1() { $row = new ezcConsoleTableRow(); $this->assertTrue( $row[0] instanceof ezcConsoleTableCell, "ezcConsoleTableCell not correctly created on write access." ); } public function testOntheflyCreationRead_2() { $row = new ezcConsoleTableRow(); $row[0]; $row[1]; $row[2]; $this->assertTrue( count( $row ) == 3, "ezcConsoleTableCell not correctly created on write access." ); } public function testOntheflyCreationRead_3() { $row = new ezcConsoleTableRow(); $row[0]->content = 'test'; $row[1]->format = 'test'; $row[2]->align = ezcConsoleTable::ALIGN_CENTER; $this->assertTrue( count($row) == 3, "ezcConsoleTableCell not correctly created on write access." ); } public function testOntheflyCreationWrite_1() { $row = new ezcConsoleTableRow(); $row[0] = new ezcConsoleTableCell(); $row[0]->content = 'test'; $this->assertTrue( count($row) == 1 && $row[0] instanceof ezcConsoleTableCell && $row[0]->content === 'test', "ezcConsoleTableCell not correctly created on write access." ); } public function testNoOntheflyCreationIsset() { $row = new ezcConsoleTableRow(); $this->assertEquals( isset( $row[0] ), false, "ezcConsoleTableCell created on isset access." ); $this->assertEquals( count($row), 0, "ezcConsoleTableCell created on isset access." ); } public function testForeach_1() { $row = new ezcConsoleTableRow(); for ( $i = 0; $i < 10; $i++ ) { $row[$i]->content = 'Is '.$i; } $this->assertEquals( count( $row ), 10, "ezcConsoleTableCells not correctly created on write access." ); foreach ( $row as $id => $cell ) { $this->assertEquals( 'Is ' . $id, $cell->content, "Cell with wrong content found on iteration." ); } } public function testForeach_2() { $row = new ezcConsoleTableRow(); for ( $i = 0; $i < 20; $i += 2 ) { $row[$i]->content = 'Is '.$i; } $this->assertEquals( count( $row ), 19, "ezcConsoleTableCells." ); foreach ( $row as $id => $cell ); { $this->assertEquals( 'Is ' . $id, $cell->content, "Cell with wrong content found on iteration." ); } } public function testCount_1() { $row = new ezcConsoleTableRow(); $row[0]->content = 0; $this->assertEquals( 1, count( $row ), "Did not count number of cells correctly" ); } public function testCount_2() { $row = new ezcConsoleTableRow(); $row[1]->content = 0; $this->assertEquals( 2, count( $row ), "Did not count number of cells correctly" ); } public function testCount_3() { $row = new ezcConsoleTableRow(); $row[10]->content = 0; $this->assertEquals( 11, count( $row ), "Did not count number of cells correctly" ); } public function testSetAllCellsProperties_1() { $row = new ezcConsoleTableRow(); for ( $i = 0; $i < 10; $i++ ) { $row[$i]->content = $i; } $row->align = ezcConsoleTable::ALIGN_CENTER; foreach ( $this as $cell ) { $this->assertEquals( ezcConsoleTable::ALIGN_CENTER, $cell->align, "Did not set alignment correctly for all contained cells." ); } } public function testSetAllCellsProperties_2() { $row = new ezcConsoleTableRow(); for ( $i = 0; $i < 10; $i++ ) { $row[$i]->content = $i; } $row->format = 'headline'; foreach ( $this as $cell ) { $this->assertEquals( 'headline', $cell->format, "Did not set alignment correctly for all contained cells." ); } } } ?>