2019-03-20 15:51:31 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* PHP version 5.3
|
|
|
|
*
|
|
|
|
* @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_Payment_Test extends WC_Retailcrm_Test_Case_Helper
|
|
|
|
{
|
|
|
|
/** @var WC_Order */
|
|
|
|
protected $order;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->order = WC_Helper_Order::create_order();
|
2020-07-10 13:14:03 +03:00
|
|
|
$this->setOptions();
|
2019-03-20 15:51:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed $externalId
|
|
|
|
*
|
|
|
|
* @dataProvider dataProvider
|
|
|
|
*/
|
|
|
|
public function test_build($externalId)
|
|
|
|
{
|
2020-07-10 13:14:03 +03:00
|
|
|
$settings = $this->getOptions();
|
|
|
|
$settings['send_payment_amount'] = 'no';
|
|
|
|
$order_payment = new WC_Retailcrm_Order_Payment($settings);
|
2019-03-20 15:51:31 +03:00
|
|
|
|
|
|
|
$data = $order_payment->build($this->order, $externalId)->get_data();
|
|
|
|
|
2020-07-10 13:14:03 +03:00
|
|
|
$this->assertNotEmpty($data);
|
|
|
|
|
|
|
|
if (!empty($externalId)) {
|
|
|
|
$this->assertArrayHasKey('externalId', $data);
|
|
|
|
}
|
|
|
|
|
2020-03-25 10:35:08 +03:00
|
|
|
$this->assertArrayHasKey('type', $data);
|
|
|
|
$this->assertArrayNotHasKey('amount', $data);
|
|
|
|
$this->assertArrayHasKey('order', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed $externalId
|
|
|
|
*
|
|
|
|
* @dataProvider dataProvider
|
|
|
|
*/
|
|
|
|
public function test_build_with_amount($externalId)
|
|
|
|
{
|
|
|
|
$settings = $this->getOptions();
|
|
|
|
$settings['send_payment_amount'] = 'yes';
|
|
|
|
$order_payment = new WC_Retailcrm_Order_Payment($settings);
|
|
|
|
|
|
|
|
$data = $order_payment->build($this->order, $externalId)->get_data();
|
|
|
|
|
2020-07-10 13:14:03 +03:00
|
|
|
$this->assertNotEmpty($data);
|
|
|
|
|
|
|
|
if (!empty($externalId)) {
|
|
|
|
$this->assertArrayHasKey('externalId', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertArrayHasKey('type', $data);
|
2019-03-20 15:51:31 +03:00
|
|
|
$this->assertArrayHasKey('amount', $data);
|
|
|
|
$this->assertArrayHasKey('order', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function dataProvider()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
'externalId' => false
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'externalId' => uniqid()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|