Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
AddressMappingUtilTest.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
38  {
39  public static function setUpBeforeClass()
40  {
41  parent::setUpBeforeClass();
42  $super = SecurityTestHelper::createSuperAdmin();
43  if (Yii::app()->params['testGoogleGeoCodeApiKey'] != null)
44  {
46  'googleMapApiKey',
47  Yii::app()->params['testGoogleGeoCodeApiKey']);
48  }
49  Yii::app()->user->userModel = $super;
51  }
52 
53  public function testCollectionFetchAndGeocodeFetchForAddress()
54  {
55  $super = User::getByUsername('super');
56  Yii::app()->user->userModel = $super;
57 
58  $address = array();
59  $address['street1'] = '123 Knob Street';
60  $address['street2'] = 'Apartment 4b';
61  $address['city'] = 'Chicago';
62  $address['state'] = 'Illinois';
63  $address['postalCode'] = '60606';
64  $address['country'] = 'USA';
65  $account1 = AddressGeoCodeTestHelper::createTestAccountsWithBillingAddressAndGetAccount($address, $super);
66  $accountId1 = $account1->id;
67  unset($account1);
68 
69  $address = array();
70  $address['street1'] = '1600 Amphitheatre Parkway';
71  $address['street2'] = '';
72  $address['city'] = 'Mountain View';
73  $address['state'] = 'California';
74  $address['postalCode'] = '94043';
75  $address['country'] = 'USA';
76  $account2 = AddressGeoCodeTestHelper::createTestAccountsWithBillingAddressAndGetAccount($address, $super);
77  $accountId2 = $account2->id;
78  unset($account2);
79 
80  $address = array();
81  $address['street1'] = '36826 East Oak Road';
82  $address['street2'] = '';
83  $address['city'] = 'New York';
84  $address['state'] = 'NY';
85  $address['postalCode'] = '10001';
86  $address['country'] = 'USA';
87  $account3 = AddressGeoCodeTestHelper::createTestAccountsWithBillingAddressAndGetAccount($address, $super);
88  $accountId3 = $account3->id;
89  unset($account3);
90 
91  $address = array();
92  $address['street1'] = '24948 West Thomas Trail';
93  $address['street2'] = '';
94  $address['city'] = 'Milwaukee';
95  $address['state'] = 'WI';
96  $address['postalCode'] = '53219';
97  $address['country'] = '';
98  $account4 = AddressGeoCodeTestHelper::createTestAccountsWithBillingAddressAndGetAccount($address, $super);
99  $accountId4 = $account4->id;
100  unset($account4);
101 
102  $account1 = Account::getById($accountId1);
103  $this->assertEquals(null, $account1->billingAddress->latitude);
104  $this->assertEquals(null, $account1->billingAddress->longitude);
105  $this->assertEquals(0 , $account1->billingAddress->invalid);
106 
107  $account2 = Account::getById($accountId2);
108  $this->assertEquals(null, $account2->billingAddress->latitude);
109  $this->assertEquals(null, $account2->billingAddress->longitude);
110  $this->assertEquals(0 , $account2->billingAddress->invalid);
111 
112  $account3 = Account::getById($accountId3);
113  $this->assertEquals(null, $account3->billingAddress->latitude);
114  $this->assertEquals(null, $account3->billingAddress->longitude);
115  $this->assertEquals(0 , $account3->billingAddress->invalid);
116 
117  $account4 = Account::getById($accountId4);
118  $this->assertEquals(null, $account4->billingAddress->latitude);
119  $this->assertEquals(null, $account4->billingAddress->longitude);
120  $this->assertEquals(0 , $account4->billingAddress->invalid);
121 
123  $this->assertEquals(2, count($addressCollection));
124 
125  $account1 = Account::getById($accountId1);
126  $addressString = $account1->billingAddress->makeAddress();
127  $latitudeLongitudeCoordinates = AddressMappingUtil::fetchGeocodeForAddress($addressString);
128 
129  $this->assertTrue(is_array($latitudeLongitudeCoordinates));
130  $this->assertEquals(2, count($latitudeLongitudeCoordinates));
131  $this->assertTrue(isset($latitudeLongitudeCoordinates['latitude']));
132  $this->assertTrue(isset($latitudeLongitudeCoordinates['longitude']));
133  //$this->assertEquals(round('42.11469', 4), round($latitudeLongitudeCoordinates['latitude'], 4));
134  //$this->assertEquals(round('-87.979699', 4), round($latitudeLongitudeCoordinates['longitude'], 4));
135  }
136  }
137 ?>
static fetchGeocodeForAddress($addressString)
static getByUsername($username)
Definition: User.php:49
static fetchChangedAddressCollection($count)
static createAndRemoveAccountWithAddress($owner)
static getById($id, $modelClassName=null)
static setByModuleName($moduleName, $key, $value, $cache=true)
Generated on Sat Aug 15 2020 07:10:31
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.