mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-01 21:02:54 +09:00
* Rename tests to tests-legacy * Groundwork for live tests * Somewhat working tests on a live instance * Hmmmmmm * Fix * Fixed the other bug * Added a handful of various tests * Typos, all these are admin endpoints * Bypass this check for testing envs * Disable it for now * Mini cleanup * Cleanup from debugging, ran PHP-CS-Fixer
78 lines
2.5 KiB
PHP
78 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace Box\Mod\Servicehosting\Api;
|
|
|
|
class GuestTest extends \BBTestCase
|
|
{
|
|
/**
|
|
* @var Guest
|
|
*/
|
|
protected $api;
|
|
|
|
public function setup(): void
|
|
{
|
|
$this->api = new Guest();
|
|
}
|
|
|
|
public function testfreeTlds()
|
|
{
|
|
$di = new \Pimple\Container();
|
|
$validatorMock = $this->getMockBuilder('\\' . \FOSSBilling\Validate::class)->disableOriginalConstructor()->getMock();
|
|
$validatorMock->expects($this->atLeastOnce())
|
|
->method('checkRequiredParamsForArray')
|
|
->willReturn(null);
|
|
|
|
$di['validator'] = $validatorMock;
|
|
|
|
$model = new \Model_Product();
|
|
$model->loadBean(new \DummyBean());
|
|
$model->type = \Model_Product::HOSTING;
|
|
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
|
|
$dbMock->expects($this->atLeastOnce())
|
|
->method('getExistingModelById')
|
|
->willReturn($model);
|
|
|
|
$di['db'] = $dbMock;
|
|
|
|
$serviceMock = $this->getMockBuilder('\\' . \Box\Mod\Servicehosting\Service::class)->getMock();
|
|
$serviceMock->expects($this->atLeastOnce())
|
|
->method('getFreeTlds')
|
|
->with($model)
|
|
->willReturn([]);
|
|
$this->api->setService($serviceMock);
|
|
$this->api->setDi($di);
|
|
|
|
$result = $this->api->free_tlds(['product_id' => 1]);
|
|
$this->assertIsArray($result);
|
|
}
|
|
|
|
public function testfreeTldsProductTypeIsNotHosting()
|
|
{
|
|
$di = new \Pimple\Container();
|
|
$validatorMock = $this->getMockBuilder('\\' . \FOSSBilling\Validate::class)->disableOriginalConstructor()->getMock();
|
|
$validatorMock->expects($this->atLeastOnce())
|
|
->method('checkRequiredParamsForArray')
|
|
->willReturn(null);
|
|
|
|
$di['validator'] = $validatorMock;
|
|
|
|
$model = new \Model_Product();
|
|
$model->loadBean(new \DummyBean());
|
|
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
|
|
$dbMock->expects($this->atLeastOnce())
|
|
->method('getExistingModelById')
|
|
->willReturn($model);
|
|
|
|
$di['db'] = $dbMock;
|
|
|
|
$serviceMock = $this->getMockBuilder('\\' . \Box\Mod\Servicehosting\Service::class)->getMock();
|
|
$serviceMock->expects($this->never())->method('getFreeTlds');
|
|
$this->api->setService($serviceMock);
|
|
$this->api->setDi($di);
|
|
|
|
$this->expectException(\FOSSBilling\Exception::class);
|
|
$this->expectExceptionMessage('Product type is invalid');
|
|
$this->api->free_tlds(['product_id' => 1]);
|
|
}
|
|
}
|