/** * @expectedException Ivory\GoogleMap\Exception\HelperException * @expectedExceptionMessage The place autocomplete bound must have coordinates. */ public function testRenderJavascriptsWithInvalidBound() { $autocomplete = new Autocomplete(); $autocomplete->setBound(1, 2, 3, 4); $autocomplete->getBound()->setSouthWest(null); $autocomplete->getBound()->setNorthEast(null); $this->autocompleteHelper->renderJavascripts($autocomplete); }
public function testView() { $this->placesAutocompleteHelperMock->expects($this->once())->method('renderHtmlContainer')->will($this->returnValue('html')); $this->placesAutocompleteHelperMock->expects($this->once())->method('renderJavascripts')->will($this->returnValue('javascripts')); $form = $this->factory->create('places_autocomplete'); $view = $form->createView(); $this->assertSame('html', $view->vars['html']); $this->assertSame('javascripts', $view->vars['javascripts']); }
/** * Get autocomplete form * * @param null $value * * @return mixed * @throws \Ivory\GoogleMap\Exception\AssetException * @throws \Ivory\GoogleMap\Exception\PlaceException * @throws \Ivory\GoogleMap\Exception\TemplatingException */ public function getAutocomplete($value = null) : array { $autocomplete = new Autocomplete(); $autocompleteHelper = new AutocompleteHelper(); $autocomplete->setPrefixJavascriptVariable('location_autocomplete_'); $autocomplete->setInputId('location_input'); $autocomplete->setInputAttributes(['class' => 'form-control', 'name' => 'locationName', 'required' => 'required']); $autocomplete->setInputAttribute('value', $value); $autocomplete->setJavascriptVariable('location_autocomplete'); $autocomplete->setTypes([AutocompleteType::GEOCODE]); $autocomplete->setAsync(true); $autocomplete->setLanguage('en'); $js = str_replace('load_ivory_google_map_api', 'load_ivory_google_map_api_auto', $autocompleteHelper->renderJavascripts($autocomplete)); return ['html' => $autocompleteHelper->renderHtmlContainer($autocomplete), 'js' => $this->removeJsCaller($js)]; }