Author: Tobias Schlitt
Date: 2006-08-09 17:11:39 +0200 (Wed, 09 Aug 2006)
New Revision: 3255

Log:
- Fixed bug #8738: Unexpected behaviour with options->colPadding.

Modified:
   trunk/ConsoleTools/ChangeLog
   trunk/ConsoleTools/src/table.php
   trunk/ConsoleTools/tests/table_test.php

Modified: trunk/ConsoleTools/ChangeLog
===================================================================
--- trunk/ConsoleTools/ChangeLog        2006-08-09 13:56:04 UTC (rev 3254)
+++ trunk/ConsoleTools/ChangeLog        2006-08-09 15:11:39 UTC (rev 3255)
@@ -1,3 +1,9 @@
+1.1.2 - [RELEASEDATE]
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Fixed bug #8738: Unexpected behaviour with options->colPadding.
+
+
 1.1.1 - Monday 07 August 2006
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

Modified: trunk/ConsoleTools/src/table.php
===================================================================
--- trunk/ConsoleTools/src/table.php    2006-08-09 13:56:04 UTC (rev 3254)
+++ trunk/ConsoleTools/src/table.php    2006-08-09 15:11:39 UTC (rev 3255)
@@ -577,12 +577,12 @@
                             $this->options->lineHorizontal, 
                             $borderFormat
                         );
-            $rowData .= ' ';
+            $rowData .= $this->options->colPadding;
             $rowData .= $this->outputHandler->formatText(
                             str_pad( $data, $colWidth[$cell], ' ', $align ),
                             $format
                         );
-            $rowData .= ' ';
+            $rowData .= $this->options->colPadding;
         }
         $rowData .= $this->outputHandler->formatText( 
$this->options->lineHorizontal, $row->borderFormat );
         return $rowData;
@@ -716,8 +716,14 @@
         {
             $colCount = max( sizeof( $row ), $colCount );
         }
+        $borderWidth = strlen( $this->options->lineHorizontal );
         // Subtract border and padding chars from global width
-        $globalWidth = $this->width - ( $colCount * ( 2 * strlen( 
$this->options->colPadding ) + 1 ) ) - 1;
+        $globalWidth = $this->width
+            - ( 
+                // Per column: 2 * border padding + 1 border
+                $colCount * ( 2 * strlen( $this->options->colPadding ) + 
$borderWidth ) 
+              // 1 Additional border
+              ) - $borderWidth;
         // Width of a column if each is made equal
         $colNormWidth = round( $globalWidth / $colCount );
         $colMaxWidth = array();

Modified: trunk/ConsoleTools/tests/table_test.php
===================================================================
--- trunk/ConsoleTools/tests/table_test.php     2006-08-09 13:56:04 UTC (rev 
3254)
+++ trunk/ConsoleTools/tests/table_test.php     2006-08-09 15:11:39 UTC (rev 
3255)
@@ -132,7 +132,29 @@
             array( 'lineFormatHead' => 'magenta', 'defaultAlign' => 
ezcConsoleTable::ALIGN_RIGHT )
         );
     }
+   
+    // Bug #8738: Unexpected behaviour with options->colPadding
+    public function testTableColPadding1()
+    {
+        $this->commonTableTest(
+            __FUNCTION__,
+            $this->tableData2,
+            array( 'width' =>  100 ),
+            array( 'defaultAlign' => ezcConsoleTable::ALIGN_CENTER, 
'colPadding' => '~~~', 'widthType' => ezcConsoleTable::WIDTH_FIXED )
+        );
+    }
     
+    // Bug #8738: Unexpected behaviour with options->colPadding
+    public function testTableColPadding2()
+    {
+        $this->commonTableTest(
+            __FUNCTION__,
+            $this->tableData2,
+            array( 'width' =>  100 ),
+            array( 'defaultAlign' => ezcConsoleTable::ALIGN_CENTER, 
'colPadding' => '~~~' )
+        );
+    }
+    
     public function testTable3a()
     {
         $this->commonTableTest(
@@ -511,6 +533,9 @@
 //        echo implode( "\n", $table->getTable() );
 //        echo "\n\n";
         
+        // To prepare test files, uncomment this block
+        // file_put_contents( dirname( __FILE__ ) . '/data/' . $refFile . 
'.dat', implode( "\n", $table->getTable() ) );
+        
         // For test assertion, uncomment this block
         $this->assertEquals(
             file_get_contents( dirname( __FILE__ ) . '/data/' . $refFile . 
'.dat' ),
@@ -518,8 +543,6 @@
             'Table not correctly generated for ' . $refFile . '.'
         );
 
-        // To prepare test files, uncomment this block
-        // file_put_contents( dirname( __FILE__ ) . '/data/' . $refFile . 
'.dat', implode( "\n", $table->getTable() ) );
     }
 }
 ?>

-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to