mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-09 05:24:58 +09:00
* Began implementing Sentry.io support * Added to the installer * Added the ID to the bug report template and UI * Hook it into our error handler, added the ability to filter by error code * Attempting to add the DSN via GH actions * Spelling and making PHPstan happy * Skip exceptions for various incomplete configurations Also brings in some of the category suggestions made by @Anuril in #195 * Update tests to account for changes * Added & renamed exception classes * Fix tests * Change a bunch of items to be InformationExceptions * Use a lighter HTTP client, fixed API error reporting * I guess that's not needed now? Arighty then * Improvements, additional info added * Update SentryHelper.php * Improved error logging, added instance ID to error page Also made it so that errors are correctly sent to Sentry rather than exclusively exceptions * Make the tests happy * Added the link, improved wording Also removed the "performance" part of the reporting as it needs to be added to the front-end and I'm not currently implementing that * Began implementing UI alerts and info * Added the ability to toggle, fixed tests, use path constants * Added some useful info & links to the page * These should be InformationException * Fix the automated Sentry DSN entry * Fix the install number text * Minor cleanup, converted more to InformationException * Replaced some direct config references with constants We have the BB_DEBUG constant to indicate if we have debug mode enabled or not, so we shouldn't be directly referencing it in the config file unless we actually need to do so. Using the constant means there's less locations to update the reference if the config structure is changed * Bugfix * Consistency & fixed a PHPDoc * Corrections * We actually do want exceptions thrown here * Change how we get the instance ID * Stability improvements Having support for translatable error pages was proving to be problematic, so I had to remove it. I also had to update the exception class to handle cases where the trans function wasn't setup yet (needed for the /run-patcher page if an error occurs) * Missed this change on git * Also fix the variable names... * Re-added new deps after rebase * This should also accept "Error" types * Added more info to the bug report and removed a dug line * This wasn't supposed to get renamed * Updated some missed references to Box_Exception
95 lines
2.7 KiB
PHP
95 lines
2.7 KiB
PHP
<?php
|
|
|
|
|
|
namespace Box\Tests\Mod\Client;
|
|
|
|
class ServiceBalanceTest extends \BBTestCase
|
|
{
|
|
|
|
public function testgetDi()
|
|
{
|
|
$di = new \Pimple\Container();
|
|
$service = new \Box\Mod\Client\ServiceBalance();
|
|
$service->setDi($di);
|
|
$getDi = $service->getDi();
|
|
$this->assertEquals($di, $getDi);
|
|
}
|
|
|
|
public function testdeductFunds()
|
|
{
|
|
$di = new \Pimple\Container();
|
|
|
|
$clientBalance = new \Model_ClientBalance();
|
|
$clientBalance->loadBean(new \DummyBean());
|
|
|
|
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
|
|
$dbMock->expects($this->atLeastOnce())
|
|
->method('dispense')
|
|
->with('ClientBalance')
|
|
->willReturn($clientBalance);
|
|
$dbMock->expects($this->atLeastOnce())
|
|
->method('store')
|
|
->with($clientBalance);
|
|
$di['db'] = $dbMock;
|
|
|
|
$service = new \Box\Mod\Client\ServiceBalance();
|
|
$service->setDi($di);
|
|
|
|
$clientModel = new \Model_Client();
|
|
$clientModel->loadBean(new \DummyBean());
|
|
|
|
$description = 'Charged for product';
|
|
$amount = 5.55;
|
|
|
|
$extra = array(
|
|
'rel_id' => 1,
|
|
);
|
|
|
|
$result = $service->deductFunds($clientModel, $amount, $description, $extra);
|
|
|
|
$this->assertInstanceOf('\Model_ClientBalance', $result);
|
|
$this->assertEquals(-$amount, $result->amount);
|
|
$this->assertEquals($description, $result->description);
|
|
$this->assertEquals($extra['rel_id'], $result->rel_id);
|
|
$this->assertEquals('default', $result->type);
|
|
}
|
|
|
|
public function testdeductFunds_InvalidDescription()
|
|
{
|
|
$service = new \Box\Mod\Client\ServiceBalance();
|
|
|
|
$clientModel = new \Model_Client();
|
|
$clientModel->loadBean(new \DummyBean());
|
|
|
|
$description = ' ';
|
|
$amount = 5.55;
|
|
|
|
$extra = array(
|
|
'rel_id' => 1,
|
|
);
|
|
|
|
$this->expectException(\FOSSBilling\Exception::class);
|
|
$this->expectExceptionMessage('Funds description is invalid');
|
|
$service->deductFunds($clientModel, $amount, $description, $extra);
|
|
}
|
|
|
|
public function testdeductFunds_InvalidAmount()
|
|
{
|
|
$service = new \Box\Mod\Client\ServiceBalance();
|
|
|
|
$clientModel = new \Model_Client();
|
|
$clientModel->loadBean(new \DummyBean());
|
|
|
|
$description = 'Charged';
|
|
$amount = "5.5adadzxc";
|
|
|
|
$extra = array(
|
|
'rel_id' => 1,
|
|
);
|
|
|
|
$this->expectException(\FOSSBilling\Exception::class);
|
|
$this->expectExceptionMessage('Funds amount is invalid');
|
|
$service->deductFunds($clientModel, $amount, $description, $extra);
|
|
}
|
|
}
|
|
|