1
0
mirror of synced 2025-02-07 10:39:24 +03:00
woocommerce-module/tests/order/test-wc-retailcrm-order-address.php

60 lines
1.7 KiB
PHP
Raw Normal View History

2019-03-20 15:51:31 +03:00
<?php
2019-03-20 15:51:31 +03:00
/**
* PHP version 7.0
2022-01-10 12:53:00 +03:00
*
* Class WC_Retailcrm_Order_Address_Test - Testing WC_Retailcrm_Order_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_Order_Address_Test extends WC_Retailcrm_Test_Case_Helper
{
/** @var WC_Order */
protected $order;
public function setUp()
{
parent::setUp();
$this->order = WC_Helper_Order::create_order();
2021-08-27 16:17:18 +03:00
$this->order->set_shipping_postcode('000000');
$this->order->set_shipping_state('TestState');
$this->order->set_shipping_city('TestCity');
$this->order->set_shipping_address_1('TestAddress1');
$this->order->set_shipping_address_2('TestAddress2');
}
2022-09-22 15:17:34 +03:00
public function test_build_address()
2021-08-27 16:17:18 +03:00
{
$order_address = new WC_Retailcrm_Order_Address();
2022-09-22 15:17:34 +03:00
$data = $order_address->build($this->order)->getData();
2021-08-27 16:17:18 +03:00
$this->assertArrayHasKey('index', $data);
$this->assertArrayHasKey('city', $data);
$this->assertArrayHasKey('region', $data);
$this->assertArrayHasKey('text', $data);
$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']);
2019-03-20 15:51:31 +03:00
}
2021-08-27 16:17:18 +03:00
public function test_empty_address()
2019-03-20 15:51:31 +03:00
{
2022-09-22 15:17:34 +03:00
$orderAddress = new WC_Retailcrm_Order_Address();
2019-03-20 15:51:31 +03:00
2022-09-22 15:17:34 +03:00
$addressData = $orderAddress
->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