Files
FOSSBilling/tests/bb-modules/Cart/Api/ClientTest.php
T
2014-11-03 09:00:47 +02:00

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);
}
}