public function testGetCenterShouldReturnALatLngObject() { $bounds = new Bounds(new LatLng(2.5678, 1.1234), new LatLng(4.5678, 3.1234)); $center = new LatLng(3.5678, 2.1234); $this->assertEquals($center, $bounds->getCenter()); $bounds = new Bounds(new LatLng(-45, 179), new LatLng(45, -179)); $center = new LatLng(0, 180); $this->assertEquals($center, $bounds->getCenter()); }
/** * @covers MultiMaps\Bounds::getCenter * @covers MultiMaps\Bounds::getData * @covers MultiMaps\Bounds::extend */ public function testGetCenterAndExtend() { $this->assertFalse($this->object->getCenter()); $this->assertNull($this->object->getData()); $point = new Point(10, 2); $this->object->extend($point); $this->assertEquals($this->object->getCenter(), $point); $this->object->extend(array(new Point(20, 1))); $this->assertEquals($this->object->getCenter(), new Point(15, 1.5)); $this->assertEquals($this->object->getData(), array('ne' => array('lat' => 20, 'lon' => 2), 'sw' => array('lat' => 10, 'lon' => 1))); $this->assertEquals("{$this->object->diagonal}", "1116519.1690062"); $pointWithBounds = new Point(); $bounds1 = new Bounds(array(new Point(40, 40), new Point(30, 30))); $pointWithBounds->bounds = $bounds1; $this->object->extend($pointWithBounds); $this->assertEquals($this->object->getData(), array('ne' => array('lat' => 40, 'lon' => 40), 'sw' => array('lat' => 10, 'lon' => 1))); $bounds2 = new Bounds(array(new Point(-40, 0), new Point(0, -30))); $pointWithBounds->bounds = $bounds2; $this->object->extend($pointWithBounds); $this->assertEquals($this->object->getData(), array('ne' => array('lat' => 40, 'lon' => 40), 'sw' => array('lat' => -40, 'lon' => -30))); }