public function testInitialState() { $this->assertSame('Ivory\\GoogleMap\\Overlays\\Rectangle', $this->rectangleBuilder->getClass()); $this->assertSame($this->boundBuilder, $this->rectangleBuilder->getBoundBuilder()); $this->assertNull($this->boundBuilder->getPrefixJavascriptVariable()); $this->assertEmpty($this->rectangleBuilder->getBound()); $this->assertEmpty($this->rectangleBuilder->getOptions()); }
/** * {@inheritdoc} */ public function reset() { $this->boundBuilder->reset(); $this->prefixJavascriptVariable = null; $this->url = null; $this->bound = array(); $this->options = array(); return $this; }
/** * {@inheritdoc} * * @return \Ivory\GoogleMap\Overlays\Rectangle The reclangle. */ public function build() { $rectangle = new $this->class(); if ($this->prefixJavascriptVariable !== null) { $rectangle->setPrefixJavascriptVariable($this->prefixJavascriptVariable); } if (!empty($this->bound)) { $bound = $this->boundBuilder->reset()->setSouthWest($this->bound[0], $this->bound[1], $this->bound[2])->setNorthEast($this->bound[3], $this->bound[4], $this->bound[5])->build(); $rectangle->setBound($bound); } if (!empty($this->options)) { $rectangle->setOptions($this->options); } return $rectangle; }
public function testMultipleBuildWithReset() { $this->boundBuilder->setPrefixJavascriptVariable('foo')->setSouthWest(1, 2, true)->setNorthEast(3, 4, false); $bound1 = $this->boundBuilder->build(); $this->boundBuilder->reset(); $bound2 = $this->boundBuilder->build(); $this->assertSame('foo', substr($bound1->getJavascriptVariable(), 0, 3)); $this->assertSame(1, $bound1->getSouthWest()->getLatitude()); $this->assertSame(2, $bound1->getSouthWest()->getLongitude()); $this->assertTrue($bound1->getSouthWest()->isNoWrap()); $this->assertSame(3, $bound1->getNorthEast()->getLatitude()); $this->assertSame(4, $bound1->getNorthEast()->getLongitude()); $this->assertFalse($bound1->getNorthEast()->isNoWrap()); $this->assertSame('bound_', substr($bound2->getJavascriptVariable(), 0, 6)); $this->assertFalse($bound2->hasCoordinates()); }