@@ -7,30 +7,44 @@ Header Graphic
77
88// Just a fun test to give the project a header graphic...
99
10- $ pluginConfigOutput = [];
11- exec ('mapnik-config --input-plugins ' , $ pluginConfigOutput );
12- \Mapnik \DatasourceCache::registerDatasources ($ pluginConfigOutput [0 ]);
10+ require_once ('util/test_case.php ' );
1311
14- $ map = new \Mapnik \Map (1280 , 320 );
12+ class HeaderGraphicTest extends MapnikTestCase
13+ {
14+ public function testMakeHeaderGraphic ()
15+ {
16+ $ pluginConfigOutput = [];
17+ exec ('mapnik-config --input-plugins ' , $ pluginConfigOutput );
18+ \Mapnik \DatasourceCache::registerDatasources ($ pluginConfigOutput [0 ]);
1519
16- $ fontConfigOutput = [];
17- exec ( ' mapnik-config --fonts ' , $ fontConfigOutput );
18- $ map -> registerFonts ( $ fontConfigOutput [ 0 ]) ;
20+ // Travis build machine does not have CSV plugin due to incompatible Boost version.
21+ // Just return early if CSV isn't available.
22+ if (! in_array ( ' csv ' , \ Mapnik \DatasourceCache:: getPluginNames ())) return ;
1923
20- $ basePath = realpath (dirname (__FILE__ ) . '/data ' );
21- $ map ->loadXmlFile ($ basePath . '/header_graphic.xml ' , false , $ basePath );
24+ $ map = new \Mapnik \Map (1280 , 320 );
2225
23- $ box = new \Mapnik \Box2D (-134 , -25 , 174 , 67 );
24- $ map ->zoomToBox ($ box );
26+ $ fontConfigOutput = [];
27+ exec ('mapnik-config --fonts ' , $ fontConfigOutput );
28+ $ map ->registerFonts ($ fontConfigOutput [0 ]);
2529
26- $ image = new \Mapnik \Image (1280 , 320 );
27- $ renderer = new \Mapnik \AggRenderer ($ map , $ image );
28- $ renderer ->apply ();
30+ $ basePath = realpath (__DIR__ . '/data ' );
31+ $ map ->loadXmlFile ($ basePath . '/header_graphic.xml ' , false , $ basePath );
2932
30- $ imageFile = realpath (dirname (__FILE__ ) . '/../ ' ) . '/header_graphic.png ' ;
31- $ image ->saveToFile ($ imageFile );
32- print file_exists ($ imageFile );
33+ $ box = new \Mapnik \Box2D (-134 , -25 , 174 , 67 );
34+ $ map ->zoomToBox ($ box );
35+
36+ $ image = new \Mapnik \Image (1280 , 320 );
37+ $ renderer = new \Mapnik \AggRenderer ($ map , $ image );
38+ $ renderer ->apply ();
39+
40+ $ imageFile = realpath (__DIR__ . '/../ ' ) . '/header_graphic.png ' ;
41+ $ image ->saveToFile ($ imageFile );
42+
43+ assert ('file_exists($imageFile) === true ' , 'Header graphic does not exist. ' );
44+ }
45+ }
46+
47+ new HeaderGraphicTest ();
3348
3449?>
35- --EXPECT--
36- 1
50+ --EXPECT--
0 commit comments