1
0
mirror of synced 2025-01-31 23:31:42 +03:00
woocommerce-module/tests/order/test-wc-retailcrm-order-payment.php

141 lines
3.3 KiB
PHP
Raw Normal View History

2019-03-20 15:51:31 +03:00
<?php
/**
2022-01-10 12:53:00 +03:00
* PHP version 5.6
*
* Class WC_Retailcrm_Order_Payment_Test - Testing WC_Retailcrm_Order_Payment.
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_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();
$this->setOptions();
2019-03-20 15:51:31 +03:00
}
/**
* @param mixed $externalId
*
* @dataProvider dataProvider
*/
public function test_build($externalId)
{
$settings = $this->getOptions();
$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();
$this->assertNotEmpty($data);
if (!empty($externalId)) {
$this->assertArrayHasKey('externalId', $data);
}
2020-03-25 10:35:08 +03:00
$this->assertArrayHasKey('type', $data);
$this->assertArrayHasKey('order', $data);
}
2021-12-20 11:41:41 +03:00
/**
* @param mixed $externalId
*
* @dataProvider dataProvider
*/
public function test_build_payment_type_not_exist($externalId)
{
$order_payment = new WC_Retailcrm_Order_Payment('test');
$data = $order_payment->build($this->order, $externalId)->get_data();
$this->assertEmpty($data);
}
/**
* @param mixed $externalId
*
* @dataProvider dataProvider
*/
public function test_not_new_payment($externalId)
{
$settings = $this->getOptions();
$order_payment = new WC_Retailcrm_Order_Payment($settings);
2022-06-28 18:27:39 +03:00
$order_payment->isNew = false;
2021-12-20 11:41:41 +03:00
$data = $order_payment->build($this->order, $externalId)->get_data();
$this->assertEmpty($data);
}
/**
* @param mixed $externalId
*
* @dataProvider dataProvider
*/
public function test_order_paid($externalId)
{
$settings = $this->getOptions();
$order_payment = new WC_Retailcrm_Order_Payment($settings);
$this->order->update_status('completed');
$data = $order_payment->build($this->order, $externalId)->get_data();
$this->assertNotEmpty($data);
if (!empty($externalId)) {
$this->assertArrayHasKey('externalId', $data);
}
$this->assertArrayHasKey('type', $data);
$this->assertArrayHasKey('order', $data);
}
2020-03-25 10:35:08 +03:00
/**
* @param mixed $externalId
*
* @dataProvider dataProvider
*/
public function test_build_with_amount($externalId)
{
$settings = $this->getOptions();
$order_payment = new WC_Retailcrm_Order_Payment($settings);
$data = $order_payment->build($this->order, $externalId)->get_data();
$this->assertNotEmpty($data);
if (!empty($externalId)) {
$this->assertArrayHasKey('externalId', $data);
}
$this->assertArrayHasKey('type', $data);
2019-03-20 15:51:31 +03:00
$this->assertArrayHasKey('order', $data);
}
/**
* @return array
*/
public function dataProvider()
{
return array(
array(
'externalId' => false
),
array(
'externalId' => uniqid()
)
);
}
}