Files
FOSSBilling/tests/modules/Cart/Api/ClientTest.php
T
Belle Aerni 50043e6211 Run Rector against our tests (#1761)
* Update rector config to include tests

* Run Rector against the tests

* Delete test-results

* Update .gitignore

* Correctly set the PHP min to 8.1, split the configs

* Corrected PHPDoc

* Deleted tests we can't really get to pass

PHPunit is hard-coded to fail when a class has a return type of `never`, which is the correct return type of our redirect function (and rightfully so).

No way to disable the exception as far as we can tell
2023-11-11 18:41:09 +00: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::class)
->onlyMethods(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' => random_int(1, 100)
);
$di = new \Pimple\Container();
$this->clientApi->setDi($di);
$result = $this->clientApi->checkout($data);
$this->assertIsArray($result);
}
}