Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"drupal/webform": "^6.0",
"drupal/geocoder": "^3.20",
"localgovdrupal/localgov_os_places_geocoder_provider": "1.x-dev"
},
"require-dev": {
"geocoder-php/nominatim-provider": "^5.2"
}
}
2 changes: 1 addition & 1 deletion js/address_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
central_hub_webfrom_address_entry.find('input.js-localgov-forms-webform-uk-address--postcode').val(addressSelected.postcode);

// add UPRN
central_hub_webfrom_address_entry.find('input.js-localgov-forms-webform-uk-address--uprn').val(parseInt(addressSelected.uprn));
central_hub_webfrom_address_entry.find('input.js-localgov-forms-webform-uk-address--uprn').val(addressSelected.uprn);

// Add any extra fields from centrahub for Twig access.
// @See DRUP-1287.
Expand Down
6 changes: 3 additions & 3 deletions src/AddressLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Drupal\localgov_forms;

use Geocoder\Location;
use LocalgovDrupal\OsPlacesGeocoder\Model\LocationUprnInterface;
use LocalgovDrupal\OsPlacesGeocoder\Model\AddressUprnInterface;

/**
* Address lookup service.
Expand Down Expand Up @@ -80,8 +80,8 @@ public static function reformat(Location $addr) :array {
$longitude = $coordinate->getLongitude();
}

$is_lgd_address = $addr instanceof LocationUprnInterface;
if ($is_lgd_address) {
$has_uprn = $addr instanceof AddressUprnInterface;
if ($has_uprn) {
$uprn = $addr->getUprn();
$unique_id = $uprn;
$display_name = $addr->getDisplayName();
Expand Down
2 changes: 1 addition & 1 deletion src/Element/AddressLookupElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static function processAddressLookupElement(&$element, FormStateInterface
'#attributes' => [
'class' => ['js-address-select'],
],
'#address_type' => isset($element['#address_type']) ? $element['#address_type'] : 'residential',
'#address_type' => $element['#address_type'] ?? 'residential',
];

if ($form_state->isProcessingInput()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\ReverseQuery;
use Geocoder\Provider\Provider as ProviderInterface;
use LocalgovDrupal\OsPlacesGeocoder\Model\UprnAddress;
use LocalgovDrupal\OsPlacesGeocoder\Model\OsPlacesAddress;

/**
* A Mock PHP Geocoder provider.
Expand Down Expand Up @@ -40,7 +40,7 @@ public function geocodeQuery(GeocodeQuery $query) :LocationCollectionInterface {
$is_bhcc_hq = !strcasecmp($search_string, 'BN1 1JE');

if ($is_bhcc_hq) {
$results[] = UprnAddress::createFromArray([
$results[] = OsPlacesAddress::createFromArray([
'providedBy' => $this->getName(),
'org' => 'Brighton & Hove City Council',
'houseName' => 'Bartholomew House',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* Sets up and tests a Geocoder-based address lookup plugin.
*/
class GeocoderAddressLookup extends WebDriverTestBase {
class GeocoderAddressLookupTest extends WebDriverTestBase {

/**
* Modules to enable.
Expand Down Expand Up @@ -65,11 +65,17 @@ public function testAddressLookup() {
$this->assertNotEmpty($town_textfield);
$postcode_textfield = $page->find('css', '#edit-address-postcode');
$this->assertNotEmpty($postcode_textfield);
$uprn_hidden_field = $page->find('css', '[data-drupal-selector="edit-address-uprn"]');
$this->assertNotEmpty($uprn_hidden_field);
$latitude_hidden_field = $page->find('css', '[data-drupal-selector="edit-address-lat"]');
$this->assertNotEmpty($latitude_hidden_field);

$this->assertEquals('Brighton & Hove City Council, Bartholomew House', $address1_textfield->getValue());
$this->assertEquals('Bartholomew Square', $address2_textfield->getValue());
$this->assertEquals('Brighton', $town_textfield->getValue());
$this->assertEquals('BN1 1JE', $postcode_textfield->getValue());
$this->assertEquals('000022062038', $uprn_hidden_field->getValue());
$this->assertEquals('-0.140979', $latitude_hidden_field->getValue());
}

}