Skip to content

Commit

Permalink
pkp#10306 removed direct mocking of job class
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Sep 15, 2024
1 parent 9d195fb commit f1aa20b
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions tests/jobs/doi/DepositSubmissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use PHPUnit\Framework\Attributes\CoversClass;
use APP\submission\Repository as SubmissionRepository;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PKP\context\Context;

#[RunTestsInSeparateProcesses]
#[CoversClass(DepositSubmission::class)]
Expand Down Expand Up @@ -156,26 +157,18 @@ public function testRunSerializedJob(): void

app()->instance(DoiRepository::class, $doiRepoMock);

/** @var \PKP\context\Context $contextMock */
$contextMock = Mockery::mock(get_class(Application::getContextDAO()->newDataObject()))
->makePartial()
->shouldReceive('getData')
->getMock();

$depositSubmissionMock = Mockery::mock(DepositSubmission::class, [
0, $contextMock, new \PKP\tests\support\DoiRegistrationAgency
])
->shouldReceive('handle')
->withAnyArgs()
->andReturn(null)
->getMock();
$depositSubmissionMock = new DepositSubmission(
0,
$contextMock,
new \PKP\tests\support\DoiRegistrationAgency
);

/**
* @disregard P1013 PHP Intelephense error suppression
* @see https://github.com/bmewburn/vscode-intelephense/issues/568
*
* As mock defined it should receive `handle`,
* we will have `handle` method on mock object
*/
$depositSubmissionMock->handle();

$this->expectNotToPerformAssertions();
Expand Down

0 comments on commit f1aa20b

Please sign in to comment.