| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Maps\Test; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Maps\Elements\WmsOverlay; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Maps\WmsOverlayParser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @covers Maps\WmsOverlayParser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * @licence GNU GPL v2+ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @author Mathias Mølster Lidal <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | class WmsOverlayParserTest extends \ValueParsers\Test\StringValueParserTest { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 	public function setUp() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 		if ( !defined( 'MEDIAWIKI' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 			$this->markTestSkipped( 'MediaWiki is not available' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 	 * @see ValueParserTestBase::validInputProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	public function validInputProvider() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 		$argLists = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 		$valid = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 			"http://demo.cubewerx.com/demo/cubeserv/cubeserv.cgi? Foundation.GTOPO30" => | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 				[ "http://demo.cubewerx.com/demo/cubeserv/cubeserv.cgi?", "Foundation.GTOPO30" ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 			"http://maps.imr.no:80/geoserver/wms? vulnerable_areas:Identified_coral_area coral_identified_areas" => | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 				[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 					"http://maps.imr.no:80/geoserver/wms?", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 					"vulnerable_areas:Identified_coral_area", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 					"coral_identified_areas" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 				] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		foreach ( $valid as $value => $expected ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 			$expectedOverlay = new WmsOverlay( $expected[0], $expected[1] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 			if ( count( $expected ) == 3 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 				$expectedOverlay->setWmsStyleName( $expected[2] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 			$argLists[] = [ (string)$value, $expectedOverlay ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		return $argLists; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 	protected function getParserClass() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		return WmsOverlayParser::class; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	 * @see ValueParserTestBase::requireDataValue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	 * @return boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 	protected function requireDataValue() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  | 	protected function getInstance() { | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  | 		return new WmsOverlayParser(); | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 73 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 74 |  |  |  |