2019-03-20 15:51:31 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2022-01-10 12:53:00 +03:00
|
|
|
* PHP version 5.6
|
|
|
|
*
|
|
|
|
* Class WC_Retailcrm_Customer_Address_Test - Testing WC_Retailcrm_Customer_Address.
|
2019-03-20 15:51:31 +03:00
|
|
|
*
|
|
|
|
* @category Integration
|
|
|
|
* @author RetailCRM <integration@retailcrm.ru>
|
|
|
|
* @license http://retailcrm.ru Proprietary
|
|
|
|
* @link http://retailcrm.ru
|
|
|
|
* @see http://help.retailcrm.ru
|
|
|
|
*/
|
|
|
|
class WC_Retailcrm_Customer_Address_Test extends WC_Retailcrm_Test_Case_Helper
|
|
|
|
{
|
|
|
|
protected $customer;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->customer = WC_Helper_Customer::create_customer();
|
2021-08-27 16:17:18 +03:00
|
|
|
|
|
|
|
$this->customer->set_billing_country('CO');
|
|
|
|
$this->customer->set_billing_postcode('000000');
|
|
|
|
$this->customer->set_billing_state('TestState');
|
|
|
|
$this->customer->set_billing_city('TestCity');
|
|
|
|
$this->customer->set_billing_address_1('TestAddress1');
|
|
|
|
$this->customer->set_billing_address_2('TestAddress2');
|
2019-03-20 15:51:31 +03:00
|
|
|
}
|
|
|
|
|
2022-09-22 15:17:34 +03:00
|
|
|
public function test_build_address()
|
2019-03-20 15:51:31 +03:00
|
|
|
{
|
2021-08-27 16:17:18 +03:00
|
|
|
$customer_address = new WC_Retailcrm_Customer_Address();
|
2022-09-22 15:17:34 +03:00
|
|
|
$data = $customer_address->build($this->customer)->getData();
|
2019-03-20 15:51:31 +03:00
|
|
|
|
|
|
|
$this->assertArrayHasKey('index', $data);
|
|
|
|
$this->assertArrayHasKey('city', $data);
|
|
|
|
$this->assertArrayHasKey('region', $data);
|
|
|
|
$this->assertArrayHasKey('text', $data);
|
|
|
|
$this->assertArrayHasKey('countryIso', $data);
|
2021-08-27 16:17:18 +03:00
|
|
|
$this->assertEquals('000000', $data['index']);
|
|
|
|
$this->assertEquals('TestCity', $data['city']);
|
|
|
|
$this->assertEquals('TestState', $data['region']);
|
2022-09-22 15:17:34 +03:00
|
|
|
$this->assertEquals('TestAddress1 || TestAddress2', $data['text']);
|
2021-08-27 16:17:18 +03:00
|
|
|
$this->assertEquals('CO', $data['countryIso']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test_empty_address()
|
|
|
|
{
|
2022-09-22 15:17:34 +03:00
|
|
|
$customerAddress = new WC_Retailcrm_Customer_Address();
|
2021-08-27 16:17:18 +03:00
|
|
|
|
2022-09-22 15:17:34 +03:00
|
|
|
$addressData = $customerAddress
|
|
|
|
->build(null)
|
|
|
|
->getData();
|
|
|
|
|
|
|
|
$this->assertInternalType('array', $addressData);
|
|
|
|
$this->assertEquals([], $addressData);
|
2019-03-20 15:51:31 +03:00
|
|
|
}
|
|
|
|
}
|
2021-08-27 16:17:18 +03:00
|
|
|
|