[Piwik-svn] r177 - in trunk: config modules/API modules/ArchiveProcessing modules/DataTable/Renderer tests tests/modules tests/modules/DataTable

svnmaster at piwik.org svnmaster at piwik.org
Thu Jan 17 01:23:52 CET 2008


Author: matt
Date: 2008-01-17 01:23:52 +0100 (Thu, 17 Jan 2008)
New Revision: 177

Added:
   trunk/tests/modules/DataTable/
   trunk/tests/modules/DataTable/Renderer.test.php
Modified:
   trunk/config/global.ini.php
   trunk/modules/API/Request.php
   trunk/modules/ArchiveProcessing/Day.php
   trunk/modules/ArchiveProcessing/Period.php
   trunk/modules/DataTable/Renderer/Csv.php
   trunk/modules/DataTable/Renderer/Xml.php
   trunk/tests/all_tests.php
   trunk/tests/modules/DataTable.test.php
Log:
Added tests/factored/ before big modification

Modified: trunk/config/global.ini.php
===================================================================
--- trunk/config/global.ini.php	2008-01-15 04:59:50 UTC (rev 176)
+++ trunk/config/global.ini.php	2008-01-17 00:23:52 UTC (rev 177)
@@ -17,7 +17,7 @@
 host 			= localhost
 username 		= root
 password 		= 
-dbname			= piwik_tests4
+dbname			= piwik_tests5
 tables_prefix	= piwiktests_
 adapter 		= PDO_MYSQL
 

Modified: trunk/modules/API/Request.php
===================================================================
--- trunk/modules/API/Request.php	2008-01-15 04:59:50 UTC (rev 176)
+++ trunk/modules/API/Request.php	2008-01-17 00:23:52 UTC (rev 177)
@@ -379,7 +379,7 @@
 	 * Apply the specified renderer to the DataTable
 	 * 
 	 * @param Piwik_DataTable
-	 * @return Piwik_DataTable
+	 * @return string
 	 */
 	protected function getRenderedDataTable($dataTable)
 	{

Modified: trunk/modules/ArchiveProcessing/Day.php
===================================================================
--- trunk/modules/ArchiveProcessing/Day.php	2008-01-15 04:59:50 UTC (rev 176)
+++ trunk/modules/ArchiveProcessing/Day.php	2008-01-17 00:23:52 UTC (rev 177)
@@ -33,7 +33,7 @@
 	/**
 	 * Main method to process logs for a day. The only logic done here is computing the number of visits, actions, etc.
 	 * All the otherreports are computed inside plugins listening to the event 'ArchiveProcessing_Day.compute'.
-	 * See some of the plugins for example.
+	 * See some of the plugins for an example.
 	 * 
 	 * @return void
 	 */

Modified: trunk/modules/ArchiveProcessing/Period.php
===================================================================
--- trunk/modules/ArchiveProcessing/Period.php	2008-01-15 04:59:50 UTC (rev 176)
+++ trunk/modules/ArchiveProcessing/Period.php	2008-01-17 00:23:52 UTC (rev 177)
@@ -10,6 +10,13 @@
  */
 
 /**
+ * Handles the archiving process for a period
+ * 
+ * This class provides generic methods to archive data for a period (week / month / year).
+ * 
+ * These methods are called by the plugins that do the logic of archiving their own data. \
+ * They hook on the event 'ArchiveProcessing_Period.compute'
+ * 
  * @package Piwik_ArchiveProcessing
  */
 class Piwik_ArchiveProcessing_Period extends Piwik_ArchiveProcessing
@@ -18,7 +25,44 @@
 	{
 		parent::__construct();
 	}
+
+	/**
+	 * Sums all values for the given field names $aNames over the period
+	 * See @archiveNumericValuesGeneral for more information
+	 * 
+	 * @param string|array 
+	 * @return Piwik_ArchiveProcessing_Record_Numeric
+	 * 
+	 */
+	public function archiveNumericValuesSum( $aNames )
+	{
+		return $this->archiveNumericValuesGeneral($aNames, 'sum');
+	}
 	
+	/**
+	 * Get the maximum value for all values for the given field names $aNames over the period
+	 * See @archiveNumericValuesGeneral for more information
+	 * 
+	 * @param string|array 
+	 * @return Piwik_ArchiveProcessing_Record_Numeric
+	 * 
+	 */
+	public function archiveNumericValuesMax( $aNames )
+	{
+		return $this->archiveNumericValuesGeneral($aNames, 'max');
+	}
+	
+	/**
+	 * Given a list of fields names, the method will fetch all their values over the period, and archive them using the given operation.
+	 * 
+	 * For example if $operationToApply = 'sum' and $aNames = array('nb_visits', 'sum_time_visit')
+	 *  it will sum all values of nb_visits for the period (for example give the number of visits for the month by summing the visits of every day)
+	 * 
+	 * @param array|string $aNames Array of strings or string containg the field names to select
+	 * @param string $operationToApply Available operations = sum, max, min 
+	 * @return Piwik_ArchiveProcessing_Record_Numeric Returns the record if $aNames is a string, 
+	 *  an array of Piwik_ArchiveProcessing_Record_Numeric indexed by their field names if aNames is an array of strings
+	 */
 	private function archiveNumericValuesGeneral($aNames, $operationToApply)
 	{
 		if(!is_array($aNames))
@@ -78,22 +122,28 @@
 		return $records;
 	}
 	
-	public function archiveNumericValuesSum( $aNames )
-	{
-		return $this->archiveNumericValuesGeneral($aNames, 'sum');
-	}
 	
-	public function archiveNumericValuesMax( $aNames )
-	{
-		return $this->archiveNumericValuesGeneral($aNames, 'max');
-	}
-	
 	/**
-	 * Returns an array (
-	 * 	nameTable1 => number of rows, 
-	 *  nameTable2 => number of rows, 
+	 * This powerful method will compute the sum of DataTables over the period for the given fields $aRecordName.
+	 * It will usually be called in a plugin that listens to the hook 'ArchiveProcessing_Period.compute'
 	 * 
-	 * )
+	 * 
+	 * For example if $aRecordName = 'UserCountry_country' the method will select all UserCountry_country DataTable for the period
+	 * (eg. the 31 dataTable of the last month), sum them, and create the Piwik_ArchiveProcessing_Record_Blob_Array so that
+	 * the resulting dataTable is AUTOMATICALLY recorded in the database.
+	 * 
+	 * 
+	 * This method works on recursive dataTable. For example for the 'Actions' it will select all subtables of all dataTable of all the sub periods
+	 *  and get the sum.
+	 * 
+	 * It returns an array that gives information about the "final" DataTable. The array gives for every field name, the number of rows in the 
+	 *  final DataTable (ie. the number of distinct LABEL over the period) (eg. the number of distinct keywords over the last month)
+	 * 
+	 * @param string|array Field name(s) of DataTable to select so we can get the sum 
+	 * @return array  array (
+	 * 					nameTable1 => number of rows, 
+	 *  				nameTable2 => number of rows,
+	 * 				)
 	 */
 	public function archiveDataTable( $aRecordName )
 	{
@@ -115,7 +165,14 @@
 		return $nameToCount;
 	}
 	
-
+	/**
+	 * This method selects all DataTables that have the name $name over the period.
+	 * It calls the appropriate methods that sum all these tables together.
+	 * The resulting DataTable is returned.
+	 *
+	 * @param string $name
+	 * @return Piwik_DataTable
+	 */
 	protected function getRecordDataTableSum( $name )
 	{
 		$table = new Piwik_DataTable;
@@ -134,7 +191,14 @@
 		return $table;
 	}
 	
-	
+	/**
+	 * Main method to process logs for a period. The only logic done here is computing the number of visits, actions, etc.
+	 * 
+	 * All the other reports are computed inside plugins listening to the event 'ArchiveProcessing_Period.compute'.
+	 * See some of the plugins for an example.
+	 * 
+	 * @return void
+	 */
 	protected function compute()
 	{		
 		$this->archives = $this->archivesSubperiods;
@@ -150,9 +214,5 @@
 		$this->archiveNumericValuesSum($toSum);
 		
 		Piwik_PostEvent('ArchiveProcessing_Period.compute', $this);		
-		
-		//delete all DataTable instanciated
-//		Piwik_DataTable_Manager::getInstance()->deleteAll();
-		
 	}
 }

Modified: trunk/modules/DataTable/Renderer/Csv.php
===================================================================
--- trunk/modules/DataTable/Renderer/Csv.php	2008-01-15 04:59:50 UTC (rev 176)
+++ trunk/modules/DataTable/Renderer/Csv.php	2008-01-17 00:23:52 UTC (rev 177)
@@ -17,9 +17,6 @@
  * The first record contains headers for all the columns in the report.
  * All rows have the same number of columns.
  * The default field delimiter string is a comma (,).
- * The record delimiter string is the carriage return and line feed (<cr><lf>).
- * The text qualifier string is a quotation mark (").
- * If the text contains an embedded delimiter string or qualifier string, the text qualifier is placed around the text, and the embedded qualifier strings are doubled.
  * Formatting and layout are ignored.
  * 
  * @package Piwik_DataTable
@@ -115,7 +112,12 @@
 		}
 		else
 		{
-			$str .= implode($this->separator, array_keys($allColumns));
+			$keys = array_keys($allColumns);
+//			foreach($keys as &$key)
+//			{
+//				$key = '"' . $key . '"';
+//			}
+			$str .= implode($this->separator, $keys);
 		}
 		
 		// we render the CSV
@@ -131,8 +133,10 @@
 			
 			$str .= $rowStr;
 		}
-		header("Content-type: application/vnd.ms-excel");
-		header("Content-Disposition: attachment; filename=piwik-report-export.csv");			
+		
+		// silent fail otherwise unit tests fail
+		@header("Content-type: application/vnd.ms-excel");
+		@header("Content-Disposition: attachment; filename=piwik-report-export.csv");			
 		return $str;
 	}
 }
\ No newline at end of file

Modified: trunk/modules/DataTable/Renderer/Xml.php
===================================================================
--- trunk/modules/DataTable/Renderer/Xml.php	2008-01-15 04:59:50 UTC (rev 176)
+++ trunk/modules/DataTable/Renderer/Xml.php	2008-01-17 00:23:52 UTC (rev 177)
@@ -10,6 +10,7 @@
  */
 
 require_once "DataTable/Renderer/Php.php";
+require_once "XML/Serializer.php";
 /**
  * XML export. Using the excellent Pear::XML_Serializer.
  * We had to fix the PEAR library so that it works under PHP5 STRICT mode.
@@ -37,7 +38,6 @@
 		
 //		var_dump($array); exit;
 
-		require_once 'XML/Serializer.php';
 		
 		$options = array(
             XML_SERIALIZER_OPTION_INDENT       => '	',
@@ -63,7 +63,9 @@
 			$xmlStr = str_replace(">\n", ">\n\t",$xmlStr);
 			$xmlStr = str_replace("\t</result>", "</result>",$xmlStr);
 		}
-		header('Content-type: text/xml');		
+		
+		// silent fail because otherwise it throws an exception in the unit tests
+		@header('Content-type: text/xml');		
 		return $xmlStr;
 	}
 }
\ No newline at end of file

Modified: trunk/tests/all_tests.php
===================================================================
--- trunk/tests/all_tests.php	2008-01-15 04:59:50 UTC (rev 176)
+++ trunk/tests/all_tests.php	2008-01-17 00:23:52 UTC (rev 177)
@@ -10,7 +10,7 @@
 <p>Some of the tests require a database access. The database used for tests is different from your normal Piwik database. 
 You may need to create this database ; you can edit the settings for the unit tests database access in your config file 
 /config/global.ini.php</p>
-<p><b>The database used in your test is called "<?php echo $databaseTestName; ?>". Create it if necessary.</b></p>
+<p><b>The database used in your tests is called "<?php echo $databaseTestName; ?>". Create it if necessary.</b></p>
 <p><a href='modules'>Run the tests by module</a></p>
 <hr>
 

Added: trunk/tests/modules/DataTable/Renderer.test.php
===================================================================
--- trunk/tests/modules/DataTable/Renderer.test.php	                        (rev 0)
+++ trunk/tests/modules/DataTable/Renderer.test.php	2008-01-17 00:23:52 UTC (rev 177)
@@ -0,0 +1,239 @@
+<?php
+if(!defined("PATH_TEST_TO_ROOT")) {
+	define('PATH_TEST_TO_ROOT', '../../..');
+}
+if(!defined('CONFIG_TEST_INCLUDED'))
+{
+	require_once "../../../tests/config_test.php";
+}
+
+require_once 'DataTable.php';
+require_once 'DataTable/Simple.php';
+require_once 'DataTable/Renderer/Xml.php';
+require_once 'DataTable/Renderer/Csv.php';
+require_once 'DataTable/Renderer/Json.php';
+require_once 'DataTable/Renderer/Php.php';
+
+class Test_Piwik_DataTable_Renderer extends UnitTestCase
+{
+	function __construct( $title = '')
+	{
+		parent::__construct( $title );
+	}
+	
+	public function setUp()
+	{
+	}
+	
+	public function tearDown()
+	{
+	}
+	
+	
+	/**
+	 * for each renderer we test the case
+	 * - datatableSimple
+	 * - normal datatable  with 2 row (including columns and details)	 *
+	 */
+	protected function getTableTest1()
+	{
+		$array = array ( 
+			array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Google', 'nb_unique_visitors' => 11, 'nb_visits' => 11, 'nb_actions' => 17, 'max_actions' => '5', 'sum_visit_length' => 517, 'bounce_count' => 9), 
+						Piwik_DataTable_Row::DETAILS => array('url' => 'http://www.google.com', 'logo' => './plugins/Referers/images/searchEngines/www.google.com.png'), 
+					 ), 
+			array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Yahoo!', 'nb_unique_visitors' => 15, 'nb_visits' => 151, 'nb_actions' => 147, 'max_actions' => '50', 'sum_visit_length' => 517, 'bounce_count' => 90), 
+						Piwik_DataTable_Row::DETAILS => array('url' => 'http://www.yahoo.com', 'logo' => './plugins/Referers/images/searchEngines/www.yahoo.com.png'), 
+					 )
+			);
+		$dataTable = new Piwik_DataTable();
+		$dataTable->loadFromArray($array);
+		return $dataTable;
+	}
+	protected function getTableTest2()
+	{
+		$array = array ( 'max_actions' => 14.0, 'nb_uniq_visitors' => 57.0, 'nb_visits' => 66.0, 'nb_actions' => 151.0, 'sum_visit_length' => 5118.0, 'bounce_count' => 44.0, );
+		
+		$table = new Piwik_DataTable_Simple;
+		$table->loadFromArray($array);
+		return $table;
+	}
+
+	function test_XML_test1()
+	{
+		$dataTable = $this->getTableTest1();
+	  	$render = new Piwik_DataTable_Renderer_Xml($dataTable);
+		$expected = '<result>
+	<row>
+		<label>Google</label>
+		<nb_unique_visitors>11</nb_unique_visitors>
+		<nb_visits>11</nb_visits>
+		<nb_actions>17</nb_actions>
+		<max_actions>5</max_actions>
+		<sum_visit_length>517</sum_visit_length>
+		<bounce_count>9</bounce_count>
+		<url>http://www.google.com</url>
+		<logo>./plugins/Referers/images/searchEngines/www.google.com.png</logo>
+	</row>
+	<row>
+		<label>Yahoo!</label>
+		<nb_unique_visitors>15</nb_unique_visitors>
+		<nb_visits>151</nb_visits>
+		<nb_actions>147</nb_actions>
+		<max_actions>50</max_actions>
+		<sum_visit_length>517</sum_visit_length>
+		<bounce_count>90</bounce_count>
+		<url>http://www.yahoo.com</url>
+		<logo>./plugins/Referers/images/searchEngines/www.yahoo.com.png</logo>
+	</row>
+</result>';
+		$this->assertEqual( $expected,$render->render());
+	}
+
+	function test_XML_test2()
+	{
+		$dataTable = $this->getTableTest2();
+	  	$render = new Piwik_DataTable_Renderer_Xml($dataTable);
+		$expected = '<result>
+	<max_actions>14</max_actions>
+	<nb_uniq_visitors>57</nb_uniq_visitors>
+	<nb_visits>66</nb_visits>
+	<nb_actions>151</nb_actions>
+	<sum_visit_length>5118</sum_visit_length>
+	<bounce_count>44</bounce_count>
+</result>';
+		$this->assertEqual( $expected,$render->render());
+	}
+	function test_CSV_test1()
+	{
+		$dataTable = $this->getTableTest1();
+	  	$render = new Piwik_DataTable_Renderer_Csv($dataTable);
+		$expected = 'label,nb_unique_visitors,nb_visits,nb_actions,max_actions,sum_visit_length,bounce_count,detail_url,detail_logo
+Google,11,11,17,5,517,9,http://www.google.com,./plugins/Referers/images/searchEngines/www.google.com.png
+Yahoo!,15,151,147,50,517,90,http://www.yahoo.com,./plugins/Referers/images/searchEngines/www.yahoo.com.png';
+
+		$this->assertEqual( $expected,$render->render());
+	}
+	function test_CSV_test2()
+	{
+		$dataTable = $this->getTableTest2();
+	  	$render = new Piwik_DataTable_Renderer_Csv($dataTable);
+		$expected = 'label,value
+max_actions,14
+nb_uniq_visitors,57
+nb_visits,66
+nb_actions,151
+sum_visit_length,5118
+bounce_count,44';
+
+		$this->assertEqual( $expected,$render->render());
+	}
+
+	function test_JSON_test1()
+	{
+		$dataTable = $this->getTableTest1();
+	  	$render = new Piwik_DataTable_Renderer_Json($dataTable);
+		$expected = '[{"label":"Google","nb_unique_visitors":11,"nb_visits":11,"nb_actions":17,"max_actions":"5","sum_visit_length":517,"bounce_count":9,"url":"http:\/\/www.google.com","logo":".\/plugins\/Referers\/images\/searchEngines\/www.google.com.png"},{"label":"Yahoo!","nb_unique_visitors":15,"nb_visits":151,"nb_actions":147,"max_actions":"50","sum_visit_length":517,"bounce_count":90,"url":"http:\/\/www.yahoo.com","logo":".\/plugins\/Referers\/images\/searchEngines\/www.yahoo.com.png"}]';
+
+		$this->assertEqual( $expected,$render->render());
+	}
+	function test_JSON_test2()
+	{
+		$dataTable = $this->getTableTest2();
+	  	$render = new Piwik_DataTable_Renderer_Json($dataTable);
+		$expected = '{"max_actions":14,"nb_uniq_visitors":57,"nb_visits":66,"nb_actions":151,"sum_visit_length":5118,"bounce_count":44}';
+
+		$this->assertEqual( $expected,$render->render());
+	}
+
+	function test_PHP_test1()
+	{
+		$dataTable = $this->getTableTest1();
+	  	$render = new Piwik_DataTable_Renderer_Php($dataTable);
+		$expected = 'a:2:{i:0;a:9:{s:5:"label";s:6:"Google";s:18:"nb_unique_visitors";i:11;s:9:"nb_visits";i:11;s:10:"nb_actions";i:17;s:11:"max_actions";s:1:"5";s:16:"sum_visit_length";i:517;s:12:"bounce_count";i:9;s:3:"url";s:21:"http://www.google.com";s:4:"logo";s:58:"./plugins/Referers/images/searchEngines/www.google.com.png";}i:1;a:9:{s:5:"label";s:6:"Yahoo!";s:18:"nb_unique_visitors";i:15;s:9:"nb_visits";i:151;s:10:"nb_actions";i:147;s:11:"max_actions";s:2:"50";s:16:"sum_visit_length";i:517;s:12:"bounce_count";i:90;s:3:"url";s:20:"http://www.yahoo.com";s:4:"logo";s:57:"./plugins/Referers/images/searchEngines/www.yahoo.com.png";}}';
+		$this->assertEqual( $expected,$render->render());
+	}
+	function test_PHP_test2()
+	{
+		$dataTable = $this->getTableTest2();
+	  	$render = new Piwik_DataTable_Renderer_Php($dataTable);
+		$expected = 'a:6:{s:11:"max_actions";d:14;s:16:"nb_uniq_visitors";d:57;s:9:"nb_visits";d:66;s:10:"nb_actions";d:151;s:16:"sum_visit_length";d:5118;s:12:"bounce_count";d:44;}';
+		$this->assertEqual( $expected,$render->render());
+	}
+	
+	/**
+	 *  test with a row without child
+	 * 			  a row with a child that has a child
+	 * 			  a row with w child
+	 */
+	function test_Console_2SubLevelAnd2Different()
+	{
+		
+	  	$table = new Piwik_DataTable;
+	  	$idtable = $table->getId();
+	  	$table->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>245,'visitors'=>245),
+	  						Piwik_DataTable_Row::DETAILS => array('logo' => 'test.png'),)
+	  	
+	  	);  
+	  	
+	  		
+	  	$subsubtable = new Piwik_DataTable;
+	  	$idsubsubtable = $subsubtable->getId();
+	  	$subsubtable->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>2)));
+	  		
+	  	$subtable = new Piwik_DataTable;
+	  	$idsubtable1 = $subtable->getId();
+	  	$subtable->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>1),
+	  						Piwik_DataTable_Row::DATATABLE_ASSOCIATED => $subsubtable));
+	  	
+	  	$table->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>3),
+	  						Piwik_DataTable_Row::DATATABLE_ASSOCIATED => $subtable)
+	  						);  
+	  	
+	  	$subtable2 = new Piwik_DataTable;
+	  	$idsubtable2 = $subtable2->getId();
+	  	$subtable2->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>5),));
+	  	
+	  	$table->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>9),
+	  						Piwik_DataTable_Row::DATATABLE_ASSOCIATED => $subtable2)
+	  						);  
+	  	
+	  	
+	  	$expected=
+"- 1 ['visits' => 245, 'visitors' => 245] ['logo' => 'test.png'] [idsubtable = ]<br>\n- 2 ['visits' => 3] [] [idsubtable = $idsubtable1]<br>\n*- 1 ['visits' => 1] [] [idsubtable = $idsubsubtable]<br>\n**- 1 ['visits' => 2] [] [idsubtable = ]<br>\n- 3 ['visits' => 9] [] [idsubtable = $idsubtable2]<br>\n*- 1 ['visits' => 5] [] [idsubtable = ]<br>\n";
+	  	/*
+	  	 * RENDER
+	  	 */
+	  	$render = new Piwik_DataTable_Renderer_Console ($table);
+	  	$render->setPrefixRow('*');
+		$rendered = $render->render();
+	  	
+//		var_dump($expected);
+//		var_dump($rendered);
+	  	$this->assertEqual($expected,$rendered);
+	}
+	
+
+	/**
+	 *  test with a row without child
+	 */
+	function test_Console_Simple()
+	{
+		
+	  	$table = new Piwik_DataTable;
+	  	$table->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>245,'visitors'=>245),
+	  						Piwik_DataTable_Row::DETAILS => array('logo' => 'test.png'),)
+	  	
+	  	);  	
+	  	
+	  	$expected="- 1 ['visits' => 245, 'visitors' => 245] ['logo' => 'test.png'] [idsubtable = ]<br>\n";
+	  	
+	  	/*
+	  	 * RENDER
+	  	 */
+	  	$render = new Piwik_DataTable_Renderer_Console ($table);
+	  	$rendered = $render->render();
+	  	
+	  	$this->assertEqual($expected,$rendered);
+	  	
+	}
+}
\ No newline at end of file

Modified: trunk/tests/modules/DataTable.test.php
===================================================================
--- trunk/tests/modules/DataTable.test.php	2008-01-15 04:59:50 UTC (rev 176)
+++ trunk/tests/modules/DataTable.test.php	2008-01-17 00:23:52 UTC (rev 177)
@@ -224,87 +224,8 @@
 	  	$countAllRows =  count($rows)+count($rows1)+count($rows2) + count($rows1sub);
 	  	$this->assertEqual( $table->getRowsCountRecursive(),$countAllRows);
 	}
-	/**
-	 *  test with a row without child
-	 */
-	function test_rendererConsoleSimple()
-	{
-		
-	  	$table = new Piwik_DataTable;
-	  	$table->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>245,'visitors'=>245),
-	  						Piwik_DataTable_Row::DETAILS => array('logo' => 'test.png'),)
-	  	
-	  	);  	
-	  	
-	  	$expected="- 1 ['visits' => 245, 'visitors' => 245] ['logo' => 'test.png'] [idsubtable = ]<br>\n";
-	  	
-	  	/*
-	  	 * RENDER
-	  	 */
-	  	$render = new Piwik_DataTable_Renderer_Console ($table);
-	  	$rendered = $render->render();
-	  	
-	  	$this->assertEqual($expected,$rendered);
-	  	
-	}
 	
 	/**
-	 *  test with a row without child
-	 * 			  a row with a child that has a child
-	 * 			  a row with w child
-	 */
-	function test_rendererConsole2SubLevelAnd2Different()
-	{
-		
-	  	$table = new Piwik_DataTable;
-	  	$idtable = $table->getId();
-	  	$table->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>245,'visitors'=>245),
-	  						Piwik_DataTable_Row::DETAILS => array('logo' => 'test.png'),)
-	  	
-	  	);  
-	  	
-	  		
-	  	$subsubtable = new Piwik_DataTable;
-	  	$idsubsubtable = $subsubtable->getId();
-	  	$subsubtable->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>2)));
-	  		
-	  	$subtable = new Piwik_DataTable;
-	  	$idsubtable1 = $subtable->getId();
-	  	$subtable->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>1),
-	  						Piwik_DataTable_Row::DATATABLE_ASSOCIATED => $subsubtable));
-	  	
-	  	$table->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>3),
-	  						Piwik_DataTable_Row::DATATABLE_ASSOCIATED => $subtable)
-	  						);  
-	  	
-	  	$subtable2 = new Piwik_DataTable;
-	  	$idsubtable2 = $subtable2->getId();
-	  	$subtable2->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>5),));
-	  	
-	  	$table->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array( 'visits'=>9),
-	  						Piwik_DataTable_Row::DATATABLE_ASSOCIATED => $subtable2)
-	  						);  
-	  	
-	  	
-	  	$expected=
-"- 1 ['visits' => 245, 'visitors' => 245] ['logo' => 'test.png'] [idsubtable = ]<br>
-- 2 ['visits' => 3] [] [idsubtable = $idsubtable1]<br>
-*- 1 ['visits' => 1] [] [idsubtable = $idsubsubtable]<br>
-**- 1 ['visits' => 2] [] [idsubtable = ]<br>
-- 3 ['visits' => 9] [] [idsubtable = $idsubtable2]<br>
-*- 1 ['visits' => 5] [] [idsubtable = ]<br>
-";
-	  	/*
-	  	 * RENDER
-	  	 */
-	  	$render = new Piwik_DataTable_Renderer_Console ($table);
-	  	$render->setPrefixRow('*');
-		$rendered = $render->render();
-	  	
-	  	$this->assertEqual($expected,$rendered);
-	}
-	
-	/**
 	 * Simple test of the DataTable_Row
 	 */
 	function test_Row()



More information about the Piwik-svn mailing list