diff --git a/src/include/class-wc-retailcrm-history.php b/src/include/class-wc-retailcrm-history.php index 767dfcb..655a3f8 100644 --- a/src/include/class-wc-retailcrm-history.php +++ b/src/include/class-wc-retailcrm-history.php @@ -1006,15 +1006,14 @@ if (!class_exists('WC_Retailcrm_History')) : /** * Returns data for address_1 and address_2(if exist data for this field) for WC order. * - * @param string $addressLine + * @param string $addressLine|null * * @return mixed */ - private function getAddressLines(string $addressLine) + public function getAddressLines(?string $addressLine = '') { if (strpos($addressLine, WC_Retailcrm_Abstracts_Address::ADDRESS_LINE_DIVIDER) !== false) { $addressLines = explode(WC_Retailcrm_Abstracts_Address::ADDRESS_LINE_DIVIDER, $addressLine); - return ['address_1' => $addressLines[0], 'address_2' => $addressLines[1]]; } diff --git a/tests/test-wc-retailcrm-history.php b/tests/test-wc-retailcrm-history.php index 89da0ab..48603bb 100644 --- a/tests/test-wc-retailcrm-history.php +++ b/tests/test-wc-retailcrm-history.php @@ -57,6 +57,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper if (is_object($orderItem)) { $this->assertEquals($product->get_id(), $orderItem->get_product()->get_id()); + $this->assertEquals($product->get_id(), $orderItem->get_product()->get_id()); } $this->assertNotEmpty($wcOrder->get_date_created()); @@ -734,7 +735,23 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper $this->assertEmpty($order->get_customer_id()); } - /** + public function test_get_address_lines() + { + $retailcrm_history = new \WC_Retailcrm_History(); + $this->assertEquals('', $retailcrm_history->getAddressLines()); + + $this->assertEquals('Test', $retailcrm_history->getAddressLines('Test')); + + $this->assertEquals( + [ + 'address_1' => 'Test', + 'address_2' => 'Test 2' + ], + $retailcrm_history->getAddressLines('Test || Test 2') + ); + } + + /** * Mock ordersGet response. * * @param bool $isSuccessful