Skip to content

Commit

Permalink
enabled parameter "transpose" and added phpunit test.
Browse files Browse the repository at this point in the history
Change-Id: Ibc8ab676cf4bf6534e9e050da9da35d9eebf17ff
  • Loading branch information
JeroenDeDauw committed Nov 16, 2013
1 parent 86a1f5c commit 8dd9886
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
16 changes: 6 additions & 10 deletions includes/queryprinters/TableResultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ protected function getResultText( SMWQueryResult $res, $outputmode ) {
$tableAttrs['width'] = '100%';
}

// @note A table is only transposable if header elements are visible
// $this->mShowHeaders !== SMW_HEADERS_HIDE && $this->params['transpose']
// if transpose is enabled, please adopt the unit test as well
return $this->tableFormatter->transpose( false )->getTable( $tableAttrs );
return $this->tableFormatter->transpose( $this->mShowHeaders !== SMW_HEADERS_HIDE && $this->params['transpose'] )->getTable( $tableAttrs );
}

/**
Expand Down Expand Up @@ -209,12 +206,11 @@ public function getParamDefinitions( array $definitions ) {
'default' => 'sortable wikitable smwtable',
);

// Uncomment to enable this feature
// $params['transpose'] = array(
// 'type' => 'boolean',
// 'default' => false,
// 'message' => 'smw-paramdesc-table-transpose',
// );
$params['transpose'] = array(
'type' => 'boolean',
'default' => false,
'message' => 'smw-paramdesc-table-transpose',
);

return $params;
}
Expand Down
24 changes: 24 additions & 0 deletions tests/phpunit/includes/queryprinters/TableResultPrinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,30 @@ public function standardTableDataProvider() {
)
);

// #3 "transpose=true"
$parameters = array(
'headers' => SMW_HEADERS_PLAIN,
'class' => 'tableClass',
'format' => 'table',
'offset' => 0,
'transpose' => true
);

//TODO add proper matching data, which I can't seem to get to work.
//MWJames would you mind doing the honors?
$matcher = array();

$provider[] = array(
array(
'parameters' => $parameters,
'queryResult' => $queryResult,
'outputMode' => SMW_OUTPUT_FILE
),
array(
'matcher' => $matcher
)
);

return $provider;

}
Expand Down

0 comments on commit 8dd9886

Please sign in to comment.