diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2008-01-21 11:16:12 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2008-01-21 11:16:12 +0000 |
commit | 47923ec162b928ed64d714a7659173a02881b84f (patch) | |
tree | f7685e0447cbea7b9189a47eb49ea2cefd1974ba /tests/labeled_axis_test.php | |
parent | a391fab6faf6c7040bf789de3868c3082ff826f6 (diff) | |
download | zetacomponents-graph-47923ec162b928ed64d714a7659173a02881b84f.zip zetacomponents-graph-47923ec162b928ed64d714a7659173a02881b84f.tar.gz |
- Resolved task #12406: Use data container instead of mt_rand in tests.
# No visual differences in test files, but slight value differences
Diffstat (limited to 'tests/labeled_axis_test.php')
-rw-r--r-- | tests/labeled_axis_test.php | 76 |
1 files changed, 20 insertions, 56 deletions
diff --git a/tests/labeled_axis_test.php b/tests/labeled_axis_test.php index a3d5d3c..81bea21 100644 --- a/tests/labeled_axis_test.php +++ b/tests/labeled_axis_test.php @@ -44,6 +44,19 @@ class ezcGraphLabeledAxisTest extends ezcGraphTestCase } } + protected function getRandomData( $count, $min = 0, $max = 1000, $randomize = 23 ) + { + $data = parent::getRandomData( $count, $min, $max, $randomize ); + + foreach ( $data as $k => $v ) + { + $data[(string) ($k + 2000)] = $v; + unset( $data[$k] ); + } + + return $data; + } + public function testFactoryLabeledAxis() { $chart = new ezcGraphLineChart(); @@ -320,14 +333,7 @@ class ezcGraphLabeledAxisTest extends ezcGraphTestCase public function testAutomaticLabelingWithLotsOfLabels2() { $labelCount = 31; - - // Make this reproducible - mt_srand( 2 ); - - for ( $i = 0; $i < $labelCount; ++$i ) - { - $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 ); - } + $data = $this->getRandomData( $labelCount, 500, 2000, 2 ); $chart = new ezcGraphLineChart(); $chart->data['sample'] = new ezcGraphArrayDataSet( $data ); @@ -354,14 +360,7 @@ class ezcGraphLabeledAxisTest extends ezcGraphTestCase public function testAutomaticLabelingWithLotsOfLabels3() { $labelCount = 32; - - // Make this reproducible - mt_srand( 2 ); - - for ( $i = 0; $i < $labelCount; ++$i ) - { - $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 ); - } + $data = $this->getRandomData( $labelCount, 500, 2000, 2 ); $chart = new ezcGraphLineChart(); $chart->data['sample'] = new ezcGraphArrayDataSet( $data ); @@ -387,14 +386,7 @@ class ezcGraphLabeledAxisTest extends ezcGraphTestCase public function testAutomaticLabelingWithLotsOfLabels4() { $labelCount = 165; - - // Make this reproducible - mt_srand( 2 ); - - for ( $i = 0; $i < $labelCount; ++$i ) - { - $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 ); - } + $data = $this->getRandomData( $labelCount, 500, 2000, 2 ); $chart = new ezcGraphLineChart(); $chart->data['sample'] = new ezcGraphArrayDataSet( $data ); @@ -443,14 +435,7 @@ class ezcGraphLabeledAxisTest extends ezcGraphTestCase $filename = $this->tempDir . __FUNCTION__ . '.svg'; $labelCount = 32; - - // Make this reproducible - mt_srand( 2 ); - - for ( $i = 0; $i < $labelCount; ++$i ) - { - $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 ); - } + $data = $this->getRandomData( $labelCount, 500, 2000, 2 ); $chart = new ezcGraphLineChart(); $chart->data['sample'] = new ezcGraphArrayDataSet( $data ); @@ -497,14 +482,7 @@ class ezcGraphLabeledAxisTest extends ezcGraphTestCase $filename = $this->tempDir . __FUNCTION__ . '.svg'; $labelCount = 4; - - // Make this reproducible - mt_srand( 2 ); - - for ( $i = 0; $i < $labelCount; ++$i ) - { - $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 ); - } + $data = $this->getRandomData( $labelCount, 500, 2000, 2 ); $chart = new ezcGraphLineChart(); $chart->data['sample'] = new ezcGraphArrayDataSet( $data ); @@ -525,14 +503,7 @@ class ezcGraphLabeledAxisTest extends ezcGraphTestCase $filename = $this->tempDir . __FUNCTION__ . '.svg'; $labelCount = 4; - - // Make this reproducible - mt_srand( 2 ); - - for ( $i = 0; $i < $labelCount; ++$i ) - { - $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 ); - } + $data = $this->getRandomData( $labelCount, 500, 2000, 2 ); $chart = new ezcGraphLineChart(); $chart->data['sample'] = new ezcGraphArrayDataSet( $data ); @@ -553,14 +524,7 @@ class ezcGraphLabeledAxisTest extends ezcGraphTestCase $filename = $this->tempDir . __FUNCTION__ . '.svg'; $labelCount = 35; - - // Make this reproducible - mt_srand( 2 ); - - for ( $i = 0; $i < $labelCount; ++$i ) - { - $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 ); - } + $data = $this->getRandomData( $labelCount, 500, 2000, 2 ); $chart = new ezcGraphLineChart(); $chart->data['sample'] = new ezcGraphArrayDataSet( $data ); |