mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-30 12:18:43 +09:00
Clean up test code: remove unused variables, duplicate test data, and fix method call (#3152)
* Initial plan * Remove unused variables and fix test issues in Invoice ServiceTest - Remove unused $itemInvoiceServiceMock variable from testGetDi() - Remove duplicate test data for 'id' => 1 in dataForSearchQuery() - Remove unused $itemInvoiceServiceMock and fix closure in testToApiArray() - Remove duplicate setDi() call in testOnAfterAdminInvoiceReminderSent() - Fix incorrect method call to onAfterAdminInvoiceReminderSent() Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> * Fix test: handle both 'email' and 'Email' service names The onAfterAdminInvoiceReminderSent method calls mod_service('Email') with uppercase E, but the test closure was only checking for lowercase 'email'. Updated the closure to handle both cases. Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> * Fix test: remove return value assertions for void method The onAfterAdminInvoiceReminderSent method has a void return type, so the test should not check for a return value. Removed the result variable and assertions that were expecting a boolean return. Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
This commit is contained in:
1 parent
df51900e23
commit
9d6eb852bf
1 file changed
+4
-16
@@ -19,7 +19,6 @@ final class ServiceTest extends \BBTestCase
|
||||
public function testGetDi(): void
|
||||
{
|
||||
$di = $this->getDi();
|
||||
$itemInvoiceServiceMock = null;
|
||||
$this->service->setDi($di);
|
||||
$getDi = $this->service->getDi();
|
||||
$this->assertEquals($di, $getDi);
|
||||
@@ -87,13 +86,6 @@ final class ServiceTest extends \BBTestCase
|
||||
'client' => 'John',
|
||||
],
|
||||
],
|
||||
[
|
||||
['id' => 1],
|
||||
'AND p.id = :id',
|
||||
[
|
||||
'id' => 1,
|
||||
],
|
||||
],
|
||||
[
|
||||
['created_at' => '1353715200'],
|
||||
"AND DATE_FORMAT(p.created_at, '%Y-%m-%d') = :created_at",
|
||||
@@ -219,12 +211,11 @@ final class ServiceTest extends \BBTestCase
|
||||
->method('getQty');
|
||||
|
||||
$di = $this->getDi();
|
||||
$itemInvoiceServiceMock = null;
|
||||
$di['db'] = $dbMock;
|
||||
$di['mod_service'] = $di->protect(function ($serviceName, $sub = '') use ($itemInvoiceServiceMock, $systemService, $subscriptionServiceMock) {
|
||||
$di['mod_service'] = $di->protect(function ($serviceName, $sub = '') use ($systemService, $subscriptionServiceMock) {
|
||||
$service = null;
|
||||
if ($sub == 'InvoiceItem') {
|
||||
$service = $itemInvoiceServiceMock;
|
||||
$service = $service;
|
||||
}
|
||||
if ($serviceName == 'system') {
|
||||
$service = $systemService;
|
||||
@@ -333,21 +324,18 @@ final class ServiceTest extends \BBTestCase
|
||||
if ($serviceName == 'invoice') {
|
||||
return $serviceMock;
|
||||
}
|
||||
if ($serviceName == 'email') {
|
||||
if ($serviceName == 'email' || $serviceName == 'Email') {
|
||||
return $emailService;
|
||||
}
|
||||
});
|
||||
$di['db'] = $dbMock;
|
||||
|
||||
$this->service->setDi($di);
|
||||
$this->service->setDi($di);
|
||||
$eventMock->expects($this->atLeastOnce())
|
||||
->method('getDi')
|
||||
->willReturn($di);
|
||||
|
||||
$result = $this->service->onAfterAdminInvoicePaymentReceived($eventMock);
|
||||
$this->assertIsBool($result);
|
||||
$this->assertTrue($result);
|
||||
$this->service->onAfterAdminInvoiceReminderSent($eventMock);
|
||||
}
|
||||
|
||||
public function testOnAfterAdminCronRun(): void
|
||||
|
||||
Reference in new issue
Block a user