| 1 |  |  | <?php | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 3 |  |  | class MapExtensionTest extends SapphireTest { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 4 |  |  | 	protected static $fixture_file = 'mappable/tests/mapextensions.yml'; | 
            
                                                                        
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | 	public function setUp() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | 		//Member::add_extension('MapExtension'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | 		parent::setUp(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 10 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 	public function setUpOnce() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 		Member::add_extension('MapExtension'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 		parent::setupOnce(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 17 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	public function testupdateCMSFields() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 22 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	public function testGetMappableLatitude() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 		$instance->Lat = 42.1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 		$instance->write(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 		$this->assertEquals( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 			42.1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 			$instance->getMappableLatitude() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 		); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 33 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	public function testGetMappableLongitude() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		$instance->Lon = 42.1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 		$this->assertEquals( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 			42.1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 			$instance->getMappableLongitude() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 43 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	public function testgetMappableMapContent() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 48 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 	public function testonBeforeWriteMapPinNotEdited() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 		$this->Lat = 0; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		$this->Lon = 0; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 		$instance->write(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		$this->assertFalse($instance->MapPinEdited); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 57 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	public function testonBeforeWriteMapPinEdited() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 		// north | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		$this->showMapPinEdited($instance, 10, 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 		// north west | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		$this->showMapPinEdited($instance, 10, -10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		// west | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 		$this->showMapPinEdited($instance, 0, -10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		// south west | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 		$this->showMapPinEdited($instance, -10, -10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 		// south | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 		$this->showMapPinEdited($instance, -10, 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 		// south east | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 		$this->showMapPinEdited($instance, -10, 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 		// east | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 		$this->showMapPinEdited($instance, 0, 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 		// north east | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 		$this->showMapPinEdited($instance, 10, 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 86 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	public function testgetMappableMapPin() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 91 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 	public function testHasGeoWest() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 		$instance->Lon = -20; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 		$this->assertTrue($instance->HasGeo()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 98 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 	public function testHasGeoEast() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 		$instance->Lon = 20; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 		$this->assertTrue($instance->HasGeo()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 104 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 	public function testHasGeoNorth() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 		$instance->Lat = 20; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 		$this->assertTrue($instance->HasGeo()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 110 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 	public function testHasGeoNorthWest() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 		$instance->Lat = 20; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 		$instance->Lon = -20; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 		$this->assertTrue($instance->HasGeo()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 117 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 	public function testHasGeoNortEast() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 		$instance->Lat = 20; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 		$instance->Lon = 20; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 		$this->assertTrue($instance->HasGeo()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 124 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 	public function testHasGeoSouth() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 		$instance->Lat = -20; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 		$this->assertTrue($instance->HasGeo()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 130 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 	public function testHasGeoSouthWest() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 		$instance->Lat = -20; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 		$instance->Lon = -20; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 		$this->assertTrue($instance->HasGeo()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 137 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	public function testHasGeoSouthEast() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 		$instance->Lat = -20; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 		$instance->Lon = 20; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 		$this->assertTrue($instance->HasGeo()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 144 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 	public function testHasGeoOrigin() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 		$instance->Lat = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 		$instance->Lon = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 		$this->assertFalse($instance->HasGeo()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 151 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 	public function testHasGeoOriginMapLayerExtension() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 		$instance->Lat = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 		$instance->Lon = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 		$this->assertFalse($instance->HasGeo()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 		Page::add_extension('MapLayerExtension'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 		Page::remove_extension('MapLayerExtension'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 		$this->markTestSkipped('TODO'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 161 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	public function testHasGeoOriginPointsOfInterestLayers() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 		$instance->Lat = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 		$instance->Lon = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 		$this->assertFalse($instance->HasGeo()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 		$this->markTestSkipped('TODO'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 169 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 	public function testBasicMap() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 173 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 	public function testgetMapField() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 		$instance = $this->getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 		$this->Lat = 37.1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 		$this->Lon = 28; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 		$this->Zoom = 12; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 		$mapField  = $instance->getMapField(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 		$this->assertInstanceOf('LatLongField', $mapField); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 183 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 	public function testUseCompressedAssets() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 188 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 	private function getInstance() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 		$instance = new Member(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 		return $instance; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 194 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 	private function showMapPinEdited(&$instance, $lat, $lon) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 		$instance->Lat = $lat; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 		$instance->Long = $lon; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 		$instance->write(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 		$this->assertTrue($instance->MapPinEdited); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 201 |  |  | 	} | 
            
                                                        
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 204 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 205 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 206 |  |  |  | 
            
                        
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.