0010012: testUpdateContactWithMissingPostalcode fails
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 30 Jun 2014 12:45:27 +0000 (14:45 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 30 Jun 2014 13:18:58 +0000 (15:18 +0200)
* Nominatim no longer returns multiple postcodes
* disables test if mappanel is deactivated by config
* adds verbose TRACE logging of Nominatim places

https://forge.tine20.org/mantisbt/view.php?id=10012

Change-Id: I8d2763edad92af664a3a46743bb899f7935e32f4
Reviewed-on: http://gerrit.tine20.com/customers/806
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Addressbook/ControllerTest.php
tine20/Addressbook/Controller/Contact.php

index dc1e50e..61138fd 100644 (file)
@@ -4,7 +4,7 @@
  * 
  * @package     Addressbook
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2008-2013 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2008-2014 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke@metaways.de>
  * 
  */
@@ -310,6 +310,10 @@ class Addressbook_ControllerTest extends PHPUnit_Framework_TestCase
      */
     public function testUpdateContactWithMissingPostalcode()
     {
+        if (! Tinebase_Config::getInstance()->get(Tinebase_Config::MAPPANEL, TRUE)) {
+            $this->markTestSkipped('Nominatim disabled');
+        }
+        
         Addressbook_Controller_Contact::getInstance()->setGeoDataForContacts(true);
         $contact = $this->_addContact();
         $contact->adr_two_street = null;
@@ -318,7 +322,10 @@ class Addressbook_ControllerTest extends PHPUnit_Framework_TestCase
         $contact->adr_two_region = 'Nordrhein-Westfalen';
         
         $updatedContact = $this->_instance->update($contact);
-        $this->assertEquals('481xx', $updatedContact->adr_two_postalcode);
+        
+        // Nominatim no longer returns multiple postcodes
+        // TODO verify if there are still places with multiple postcodes
+        $this->assertEquals(null, $updatedContact->adr_two_postalcode);
     }
     
     /**
index 076a11c..f07defe 100644 (file)
@@ -424,6 +424,9 @@ class Addressbook_Controller_Contact extends Tinebase_Controller_Record_Abstract
      */
     protected function _applyNominatimPlaceToRecord($address, $record, $place)
     {
+        if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ .
+            ' Place: ' . var_export($place, true));
+        
         $record->{$address . 'lon'} = $place->lon;
         $record->{$address . 'lat'} = $place->lat;
         
@@ -459,7 +462,6 @@ class Addressbook_Controller_Contact extends Tinebase_Controller_Record_Abstract
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
             . ' Got postalcode from Nominatim: ' . $postcode);
         
-        
         // @see 0009424: missing postalcode prevents saving of contact
         if (strpos($postcode, ',') !== false) {
             $postcodes = explode(',', $postcode);