Skip to content

Commit 814132a

Browse files
CopilotR0Wi
andauthored
Fix ProcessFileJobTest by removing deprecated OCP\Snowflake\IGenerator dependency (#346)
* Initial plan * Fix ProcessFileJobTest by removing deprecated IGenerator dependency The test was failing because it tried to mock OCP\Snowflake\IGenerator which no longer exists in recent Nextcloud versions. The JobList constructor signature has changed and no longer requires this parameter. Changes: - Removed import of OCP\Snowflake\IGenerator - Changed from concrete JobList class to IJobList interface - Removed unnecessary mocks for IConfig, ITimeFactory, IDBConnection, IQueryBuilder, IExpressionBuilder - Simplified test setup to just create a mock of IJobList - Removed IGenerator property and related setup code This aligns the test with how other Nextcloud server tests handle JobList mocking. Co-authored-by: R0Wi <19730957+R0Wi@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: R0Wi <19730957+R0Wi@users.noreply.github.com>
1 parent 2b634a1 commit 814132a

File tree

1 file changed

+3
-44
lines changed

1 file changed

+3
-44
lines changed

tests/Unit/BackgroundJobs/ProcessFileJobTest.php

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,10 @@
2323

2424
namespace OCA\WorkflowOcr\Tests\Unit\BackgroundJobs;
2525

26-
use OC\BackgroundJob\JobList;
2726
use OCA\WorkflowOcr\BackgroundJobs\ProcessFileJob;
2827
use OCA\WorkflowOcr\Service\IOcrService;
2928
use OCP\AppFramework\Utility\ITimeFactory;
30-
use OCP\DB\QueryBuilder\IExpressionBuilder;
31-
use OCP\DB\QueryBuilder\IQueryBuilder;
32-
use OCP\IConfig;
33-
use OCP\IDBConnection;
34-
use OCP\Snowflake\IGenerator;
29+
use OCP\BackgroundJob\IJobList;
3530
use PHPUnit\Framework\MockObject\MockObject;
3631
use PHPUnit\Framework\TestCase;
3732
use Psr\Log\LoggerInterface;
@@ -43,10 +38,7 @@ class ProcessFileJobTest extends TestCase {
4338
/** @var IOcrService|MockObject */
4439
private $ocrService;
4540

46-
/** @var IGenerator|MockObject */
47-
private $generator;
48-
49-
/** @var JobList */
41+
/** @var IJobList|MockObject */
5042
private $jobList;
5143

5244
/** @var ProcessFileJob */
@@ -71,40 +63,7 @@ public function setUp() : void {
7163
);
7264
$this->processFileJob->setId('111');
7365

74-
/** @var IConfig */
75-
$configMock = $this->createMock(IConfig::class);
76-
/** @var ITimeFactory */
77-
$timeFactoryMock = $this->createMock(ITimeFactory::class);
78-
/** @var MockObject|IDbConnection */
79-
$connectionMock = $this->createMock(IDBConnection::class);
80-
/** @var MockObject|IQueryBuilder */
81-
$queryBuilderMock = $this->createMock(IQueryBuilder::class);
82-
$expressionBuilderMock = $this->createMock(IExpressionBuilder::class);
83-
$this->generator = $this->createMock(IGenerator::class);
84-
85-
$queryBuilderMock->method('delete')
86-
->withAnyParameters()
87-
->willReturn($queryBuilderMock);
88-
$queryBuilderMock->method('set')
89-
->withAnyParameters()
90-
->willReturn($queryBuilderMock);
91-
$queryBuilderMock->method('update')
92-
->withAnyParameters()
93-
->willReturn($queryBuilderMock);
94-
$queryBuilderMock->method('expr')
95-
->withAnyParameters()
96-
->willReturn($expressionBuilderMock);
97-
$connectionMock->method('getQueryBuilder')
98-
->withAnyParameters()
99-
->willReturn($queryBuilderMock);
100-
101-
$this->jobList = new JobList(
102-
$connectionMock,
103-
$configMock,
104-
$timeFactoryMock,
105-
$this->logger,
106-
$this->generator
107-
);
66+
$this->jobList = $this->createMock(IJobList::class);
10867

10968
$this->processFileJob->setArgument($this->argument);
11069
}

0 commit comments

Comments
 (0)