$t->cmp_ok($gs->getSeries(), '===', $series, '->getSeries() returns series set by setSeries()'); // ->getSeriesCount() $t->diag('->getSeriesCount()'); $gs = new ChartSource(); $t->cmp_ok($gs->getSeriesCount(), '===', null, '->getSeriesCount() returns a value only if raw_data parameter is set'); $series = array(); $series[] = new ChartDataSerie(array('raw_data' => array(1, 2, 3))); $series[] = new ChartDataSerie(array('raw_data' => array(3, 4, 5))); $gs->setSeries($series); $t->cmp_ok($gs->getSeriesCount(), '===', 2, '->getSeriesCount() counts the number of series in the raw_data array'); // ->getSeriesDataByColumn() $t->diag('->getSeriesDataByColumn()'); $data = Doctrine_Core::getTable('Charge')->findAll(); $gs = new ChartSource(); try { $gs->getSeriesDataByColumn('kilometers'); $t->fail('no code should be executed after throwing an exception'); } catch (Exception $e) { $t->pass('->getSeriesDataByColumn() Raw data must be set before retrieving series'); } $series = array(new ChartDataSerie(array('raw_data' => $data))); $gs->setSeries($series); try { $gs->getSeriesDataByColumn('quantity'); $t->fail('no code should be executed after throwing an exception'); } catch (Exception $e) { $t->pass('->getSeriesDataByColumn() All rows must be defined in charges table to build sets for a given column'); } $series = $gs->getSeriesDataByColumn('kilometers'); $t->cmp_ok(count($series), '===', 1, '->getSeriesDataByColumn() returns an array containing the requested data for each data serie'); $t->cmp_ok(count($series[0]), '===', count($data), '->getSeriesDataByColumn() returns a value for each element in raw_data');