mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-22 04:53:46 +09:00
52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
namespace Box\Tests\Mod\Cart\Api;
|
|
|
|
|
|
class ClientTest extends \PHPUnit_Framework_TestCase {
|
|
/**
|
|
* @var \Box\Mod\Cart\Api\Client
|
|
*/
|
|
protected $clientApi = null;
|
|
|
|
public function setup()
|
|
{
|
|
$this->clientApi = new \Box\Mod\Cart\Api\Client();
|
|
}
|
|
|
|
public function testCheckout()
|
|
{
|
|
$cart = new \Model_Cart();
|
|
$cart->loadBean(new \RedBeanPHP\OODBBean());
|
|
|
|
$serviceMock = $this->getMockBuilder('\Box\Mod\Cart\Service')
|
|
->setMethods(array('getSessionCart', 'checkoutCart'))
|
|
->getMock();
|
|
$serviceMock->expects($this->atLeastOnce())->method('getSessionCart')
|
|
->will($this->returnValue($cart));
|
|
|
|
$checkOutCartResult = array (
|
|
'gateway_id' => 1,
|
|
'invoice_hash' => null,
|
|
'order_id' => 1,
|
|
'orders' => 1,
|
|
);
|
|
$serviceMock->expects($this->atLeastOnce())
|
|
->method('checkoutCart')
|
|
->will($this->returnValue($checkOutCartResult));
|
|
|
|
$this->clientApi->setService($serviceMock);
|
|
|
|
$client = new \Model_Client();
|
|
$client->loadBean(new \RedBeanPHP\OODBBean());
|
|
|
|
$this->clientApi->setIdentity($client);
|
|
|
|
$data = array(
|
|
'id' => rand(1, 100)
|
|
);
|
|
$result = $this->clientApi->checkout($data);
|
|
|
|
$this->assertInternalType('array', $result);
|
|
}
|
|
}
|
|
|