diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-12-15 14:28:20 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-12-15 14:28:20 +0000 |
commit | c29c23763f1a0055aac81758bb5d293534a27d09 (patch) | |
tree | a21762cdae5813fa41f2ae9c2bd4a47bc9d3515a | |
parent | a66577e2a622b63a0037901635850ac6abb639a4 (diff) | |
download | zetacomponents-graph-c29c23763f1a0055aac81758bb5d293534a27d09.zip zetacomponents-graph-c29c23763f1a0055aac81758bb5d293534a27d09.tar.gz |
- Moced compare methods to ezcGraphTestCase
-rw-r--r-- | tests/dataset_average_test.php | 31 | ||||
-rw-r--r-- | tests/date_axis_test.php | 31 | ||||
-rw-r--r-- | tests/driver_flash_test.php | 40 | ||||
-rw-r--r-- | tests/driver_svg_test.php | 31 | ||||
-rw-r--r-- | tests/font_test.php | 67 | ||||
-rw-r--r-- | tests/image_map_test.php | 31 | ||||
-rw-r--r-- | tests/legend_test.php | 31 | ||||
-rw-r--r-- | tests/logarithmical_axis_test.php | 31 | ||||
-rw-r--r-- | tests/pie_test.php | 31 | ||||
-rw-r--r-- | tests/renderer_2d_test.php | 31 | ||||
-rw-r--r-- | tests/renderer_3d_test.php | 31 | ||||
-rw-r--r-- | tests/test_case.php | 72 |
12 files changed, 105 insertions, 353 deletions
diff --git a/tests/dataset_average_test.php b/tests/dataset_average_test.php index 5915048..f3947fc 100644 --- a/tests/dataset_average_test.php +++ b/tests/dataset_average_test.php @@ -9,13 +9,15 @@ * @license http://ez.no/licenses/new_bsd New BSD License */ +require_once dirname( __FILE__ ) . '/test_case.php'; + /** * Tests for ezcGraph class. * * @package ImageAnalysis * @subpackage Tests */ -class ezcGraphDataSetAverageTest extends ezcTestCase +class ezcGraphDataSetAverageTest extends ezcGraphTestCase { protected $basePath; @@ -41,33 +43,6 @@ class ezcGraphDataSetAverageTest extends ezcTestCase } } - /** - * Compares a generated image with a stored file - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function compare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - if ( md5_file( $generated ) !== md5_file( $compare ) ) - { - // Adding a diff makes no sense here, because created XML uses - // only two lines - $this->fail( 'Rendered image is not correct.'); - } - } - public function testCreateDatasetFromDataset() { $arrayDataSet = new ezcGraphArrayDataSet( array( -1 => 1, 0 => 0, 1 => 1 ) ); diff --git a/tests/date_axis_test.php b/tests/date_axis_test.php index 1f4d5bf..dde9e86 100644 --- a/tests/date_axis_test.php +++ b/tests/date_axis_test.php @@ -9,13 +9,15 @@ * @license http://ez.no/licenses/new_bsd New BSD License */ +require_once dirname( __FILE__ ) . '/test_case.php'; + /** * Tests for ezcGraph class. * * @package ImageAnalysis * @subpackage Tests */ -class ezcGraphDateAxisTest extends ezcTestCase +class ezcGraphDateAxisTest extends ezcGraphTestCase { protected $basePath; @@ -50,33 +52,6 @@ class ezcGraphDateAxisTest extends ezcTestCase unset( $this->chart ); } - /** - * Compares a generated image with a stored file - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function compare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - if ( md5_file( $generated ) !== md5_file( $compare ) ) - { - // Adding a diff makes no sense here, because created XML uses - // only two lines - $this->fail( 'Rendered image is not correct.'); - } - } - public function testManualScaling() { $this->chart->xAxis->startDate = 0; diff --git a/tests/driver_flash_test.php b/tests/driver_flash_test.php index ffeaf21..50ab236 100644 --- a/tests/driver_flash_test.php +++ b/tests/driver_flash_test.php @@ -9,13 +9,15 @@ * @license http://ez.no/licenses/new_bsd New BSD License */ +require_once dirname( __FILE__ ) . '/test_case.php'; + /** * Tests for ezcGraph class. * * @package ImageAnalysis * @subpackage Tests */ -class ezcGraphFlashDriverTest extends ezcTestCase +class ezcGraphFlashDriverTest extends ezcGraphTestCase { protected $driver; @@ -61,42 +63,6 @@ class ezcGraphFlashDriverTest extends ezcTestCase } } - /** - * Compares to flash files comparing the output of `swftophp` - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function swfCompare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - $executeable = ezcBaseFeatures::findExecutableInPath( 'swftophp' ); - - if ( !$executeable ) - { - $this->markTestSkipped( 'Could not find swftophp executeable to compare flash files. Please check your $PATH.' ); - } - - $generatedCode = shell_exec( $executeable . ' ' . escapeshellarg( $generated ) ); - $compareCode = shell_exec( $executeable . ' ' . escapeshellarg( $compare ) ); - - $this->assertEquals( - $generatedCode, - $compareCode, - 'Rendered image is not correct.' - ); - } - public function testDrawLine() { $filename = $this->tempDir . __FUNCTION__ . '.swf'; diff --git a/tests/driver_svg_test.php b/tests/driver_svg_test.php index 2ac8cad..09aad3c 100644 --- a/tests/driver_svg_test.php +++ b/tests/driver_svg_test.php @@ -9,13 +9,15 @@ * @license http://ez.no/licenses/new_bsd New BSD License */ +require_once dirname( __FILE__ ) . '/test_case.php'; + /** * Tests for ezcGraph class. * * @package ImageAnalysis * @subpackage Tests */ -class ezcGraphSvgDriverTest extends ezcTestCase +class ezcGraphSvgDriverTest extends ezcGraphTestCase { protected $driver; @@ -54,33 +56,6 @@ class ezcGraphSvgDriverTest extends ezcTestCase } } - /** - * Compares a generated image with a stored file - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function compare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - if ( md5_file( $generated ) !== md5_file( $compare ) ) - { - // Adding a diff makes no sense here, because created XML uses - // only two lines - $this->fail( 'Rendered image is not correct.'); - } - } - public function testRenderToOutput() { $filename = $this->tempDir . __FUNCTION__ . '.svg'; diff --git a/tests/font_test.php b/tests/font_test.php index 6048dba..0521f0d 100644 --- a/tests/font_test.php +++ b/tests/font_test.php @@ -9,13 +9,15 @@ * @license http://ez.no/licenses/new_bsd New BSD License */ +require_once dirname( __FILE__ ) . '/test_case.php'; + /** * Tests for ezcGraph class. * * @package ImageAnalysis * @subpackage Tests */ -class ezcGraphFontTest extends ezcImageTestCase +class ezcGraphFontTest extends ezcGraphTestCase { protected $tempDir; @@ -42,69 +44,6 @@ class ezcGraphFontTest extends ezcImageTestCase } } - /** - * Compares to flash files comparing the output of `swftophp` - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function swfCompare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - $executeable = ezcBaseFeatures::findExecutableInPath( 'swftophp' ); - - if ( !$executeable ) - { - $this->markTestSkipped( 'Could not find swftophp executeable to compare flash files. Please check your $PATH.' ); - } - - $generatedCode = shell_exec( $executeable . ' ' . escapeshellarg( $generated ) ); - $compareCode = shell_exec( $executeable . ' ' . escapeshellarg( $compare ) ); - - $this->assertEquals( - $generatedCode, - $compareCode, - 'Rendered image is not correct.' - ); - } - - /** - * Compares a generated image with a stored file - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function compare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - if ( md5_file( $generated ) !== md5_file( $compare ) ) - { - // Adding a diff makes no sense here, because created XML uses - // only two lines - $this->fail( 'Rendered image is not correct.'); - } - } - public function testSetGeneralFont() { $chart = new ezcGraphPieChart(); diff --git a/tests/image_map_test.php b/tests/image_map_test.php index 92cf5b4..d4a4140 100644 --- a/tests/image_map_test.php +++ b/tests/image_map_test.php @@ -9,13 +9,15 @@ * @license http://ez.no/licenses/new_bsd New BSD License */ +require_once dirname( __FILE__ ) . '/test_case.php'; + /** * Tests for ezcGraph class. * * @package ImageAnalysis * @subpackage Tests */ -class ezcGraphImageMapTest extends ezcTestCase +class ezcGraphImageMapTest extends ezcGraphTestCase { protected $basePath; @@ -45,33 +47,6 @@ class ezcGraphImageMapTest extends ezcTestCase } } - /** - * Compares a generated image with a stored file - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function compare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - if ( md5_file( $generated ) !== md5_file( $compare ) ) - { - // Adding a diff makes no sense here, because created XML uses - // only two lines - $this->fail( 'Rendered image is not correct.'); - } - } - public function testReturnFrom2dSvgLineChart() { $filename = $this->tempDir . __FUNCTION__ . '.svg'; diff --git a/tests/legend_test.php b/tests/legend_test.php index 00ef63e..9be8a77 100644 --- a/tests/legend_test.php +++ b/tests/legend_test.php @@ -9,13 +9,15 @@ * @license http://ez.no/licenses/new_bsd New BSD License */ +require_once dirname( __FILE__ ) . '/test_case.php'; + /** * Tests for ezcGraph class. * * @package ImageAnalysis * @subpackage Tests */ -class ezcGraphLegendTest extends ezcTestCase +class ezcGraphLegendTest extends ezcGraphTestCase { public static function suite() { @@ -38,33 +40,6 @@ class ezcGraphLegendTest extends ezcTestCase } } - /** - * Compares a generated image with a stored file - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function compare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - if ( md5_file( $generated ) !== md5_file( $compare ) ) - { - // Adding a diff makes no sense here, because created XML uses - // only two lines - $this->fail( 'Rendered image is not correct.'); - } - } - protected function addSampleData( ezcGraphChart $chart ) { $chart->data['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); diff --git a/tests/logarithmical_axis_test.php b/tests/logarithmical_axis_test.php index c22b495..80034b3 100644 --- a/tests/logarithmical_axis_test.php +++ b/tests/logarithmical_axis_test.php @@ -9,13 +9,15 @@ * @license http://ez.no/licenses/new_bsd New BSD License */ +require_once dirname( __FILE__ ) . '/test_case.php'; + /** * Tests for ezcGraph class. * * @package ImageAnalysis * @subpackage Tests */ -class ezcGraphLogarithmicalAxisTest extends ezcTestCase +class ezcGraphLogarithmicalAxisTest extends ezcGraphTestCase { protected $basePath; @@ -41,33 +43,6 @@ class ezcGraphLogarithmicalAxisTest extends ezcTestCase } } - /** - * Compares a generated image with a stored file - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function compare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - if ( md5_file( $generated ) !== md5_file( $compare ) ) - { - // Adding a diff makes no sense here, because created XML uses - // only two lines - $this->fail( 'Rendered image is not correct.'); - } - } - public function testChartElementLogarithmicalAxisPropertyMin() { $options = new ezcGraphChartElementLogarithmicalAxis(); diff --git a/tests/pie_test.php b/tests/pie_test.php index 54c1cf7..c360291 100644 --- a/tests/pie_test.php +++ b/tests/pie_test.php @@ -9,13 +9,15 @@ * @license http://ez.no/licenses/new_bsd New BSD License */ +require_once dirname( __FILE__ ) . '/test_case.php'; + /** * Tests for ezcGraph class. * * @package ImageAnalysis * @subpackage Tests */ -class ezcGraphPieChartTest extends ezcImageTestCase +class ezcGraphPieChartTest extends ezcGraphTestCase { protected $basePath; @@ -45,33 +47,6 @@ class ezcGraphPieChartTest extends ezcImageTestCase } } - /** - * Compares a generated image with a stored file - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function compare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - if ( md5_file( $generated ) !== md5_file( $compare ) ) - { - // Adding a diff makes no sense here, because created XML uses - // only two lines - $this->fail( 'Rendered image is not correct.'); - } - } - public function testPieChartOptionsPropertyLabel() { $options = new ezcGraphPieChartOptions(); diff --git a/tests/renderer_2d_test.php b/tests/renderer_2d_test.php index 652975b..0773d3b 100644 --- a/tests/renderer_2d_test.php +++ b/tests/renderer_2d_test.php @@ -9,13 +9,15 @@ * @license http://ez.no/licenses/new_bsd New BSD License */ +require_once dirname( __FILE__ ) . '/test_case.php'; + /** * Tests for ezcGraph class. * * @package ImageAnalysis * @subpackage Tests */ -class ezcGraphRenderer2dTest extends ezcTestCase +class ezcGraphRenderer2dTest extends ezcGraphTestCase { protected $basePath; @@ -66,33 +68,6 @@ class ezcGraphRenderer2dTest extends ezcTestCase } } - /** - * Compares a generated image with a stored file - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function compare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - if ( md5_file( $generated ) !== md5_file( $compare ) ) - { - // Adding a diff makes no sense here, because created XML uses - // only two lines - $this->fail( 'Rendered image is not correct.'); - } - } - public function testRenderLabeledPieSegment() { $this->driver diff --git a/tests/renderer_3d_test.php b/tests/renderer_3d_test.php index 29704b8..eae4b31 100644 --- a/tests/renderer_3d_test.php +++ b/tests/renderer_3d_test.php @@ -9,13 +9,15 @@ * @license http://ez.no/licenses/new_bsd New BSD License */ +require_once dirname( __FILE__ ) . '/test_case.php'; + /** * Tests for ezcGraph class. * * @package ImageAnalysis * @subpackage Tests */ -class ezcGraphRenderer3dTest extends ezcImageTestCase +class ezcGraphRenderer3dTest extends ezcGraphTestCase { protected $basePath; @@ -47,33 +49,6 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase } } - /** - * Compares a generated image with a stored file - * - * @param string $generated Filename of generated image - * @param string $compare Filename of stored image - * @return void - */ - protected function compare( $generated, $compare ) - { - $this->assertTrue( - file_exists( $generated ), - 'No image file has been created.' - ); - - $this->assertTrue( - file_exists( $compare ), - 'Comparision image does not exist.' - ); - - if ( md5_file( $generated ) !== md5_file( $compare ) ) - { - // Adding a diff makes no sense here, because created XML uses - // only two lines - $this->fail( 'Rendered image is not correct.'); - } - } - public function testRenderBackgroundImage() { $driver = $this->getMock( 'ezcGraphSvgDriver', array( diff --git a/tests/test_case.php b/tests/test_case.php new file mode 100644 index 0000000..2c0568a --- /dev/null +++ b/tests/test_case.php @@ -0,0 +1,72 @@ +<?php + +ezcTestRunner::addFileToFilter( __FILE__ ); + +class ezcGraphTestCase extends ezcImageTestCase +{ + + /** + * Compares to flash files comparing the output of `swftophp` + * + * @param string $generated Filename of generated image + * @param string $compare Filename of stored image + * @return void + */ + protected function swfCompare( $generated, $compare ) + { + $this->assertTrue( + file_exists( $generated ), + 'No image file has been created.' + ); + + $this->assertTrue( + file_exists( $compare ), + 'Comparision image does not exist.' + ); + + $executeable = ezcBaseFeatures::findExecutableInPath( 'swftophp' ); + + if ( !$executeable ) + { + $this->markTestSkipped( 'Could not find swftophp executeable to compare flash files. Please check your $PATH.' ); + } + + $generatedCode = shell_exec( $executeable . ' ' . escapeshellarg( $generated ) ); + $compareCode = shell_exec( $executeable . ' ' . escapeshellarg( $compare ) ); + + $this->assertEquals( + $generatedCode, + $compareCode, + 'Rendered image is not correct.' + ); + } + + /** + * Compares a generated image with a stored file + * + * @param string $generated Filename of generated image + * @param string $compare Filename of stored image + * @return void + */ + protected function compare( $generated, $compare ) + { + $this->assertTrue( + file_exists( $generated ), + 'No image file has been created.' + ); + + $this->assertTrue( + file_exists( $compare ), + 'Comparision image does not exist.' + ); + + if ( md5_file( $generated ) !== md5_file( $compare ) ) + { + // Adding a diff makes no sense here, because created XML uses + // only two lines + $this->fail( 'Rendered image is not correct.'); + } + } +} + +?> |