Files
FOSSBilling/tests/modules/Cart/Api/ClientTest.php
T
Belle Aerni 9faa981c58 Replace usage of array_get (#989)
* Replace usage of array_get

* Fixes

* And a few more

* Remove remaining references

* Update Service.php

* Few more fixes

* Fix.. I think?

* Fix Client / Invoice updates

* Fix stats

* Fix issues noticed during code review

* More fixes

* And some more fixes :)
2023-03-27 23:44:30 -07:00

55 lines
1.4 KiB
PHP

<?php
namespace Box\Tests\Mod\Cart\Api;
class ClientTest extends \BBTestCase {
/**
* @var \Box\Mod\Cart\Api\Client
*/
protected $clientApi = null;
public function setup(): void
{
$this->clientApi = new \Box\Mod\Cart\Api\Client();
}
public function testCheckout()
{
$cart = new \Model_Cart();
$cart->loadBean(new \DummyBean());
$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 \DummyBean());
$this->clientApi->setIdentity($client);
$data = array(
'id' => rand(1, 100)
);
$di = new \Box_Di();
$this->clientApi->setDi($di);
$result = $this->clientApi->checkout($data);
$this->assertIsArray($result);
}
}