예제 #1
0
    $d2[] = strtotime($value['date']);
}
$dates = array_unique(array_merge($d1, $d2));
sort($dates);
$g = new ChartSource();
$g->setSeries(array($s1, $s2));
$x_series = $g->getSeriesDataByColumn('date', 'datetime');
$x = $g->buildXAxisData($x_series);
$t->cmp_ok($x, '===', $dates, '->buildXAxisData() returns an array containing the unique values of all series data for the requestes column');
// buildXAxisDataByRangeTypeAndCalculationBase()
$t->diag('::buildXAxisDataByRangeTypeAndCalculationBase');
$rt = 'anything';
$bt = 'date';
$options = array();
try {
    $x = $g->buildXAxisDataByRangeTypeAndCalculationBase($rt, $bt, $options);
    $t->fail('no code should be executed after throwing an exception');
} catch (Exception $e) {
    $t->pass('->buildXAxisDataByRangeTypeAndCalculationBase() only accepts range types defined by ChartTable::getRangeTypes()');
}
$rt = 'date';
$bt = 'sdgsd';
$options = array();
try {
    $x = $g->buildXAxisDataByRangeTypeAndCalculationBase($rt, $bt, $options);
    $t->fail('no code should be executed after throwing an exception');
} catch (Exception $e) {
    $t->pass('->buildXAxisDataByRangeTypeAndCalculationBase() only accepts base types defined by ChartTable::getRangeTypes()');
}
$rt = 'date';
$bt = 'date';