Skip to content

Commit

Permalink
pkp/pkp-lib#10306 updated tests with support mock
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Nov 14, 2024
1 parent aed2042 commit 6ea1b64
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions tests/jobs/doi/DepositIssueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace APP\tests\jobs\doi;

use APP\core\Application;
use APP\doi\Repository as DoiRepository;
use APP\issue\Repository as IssueRepository;
use APP\jobs\doi\DepositIssue;
Expand Down Expand Up @@ -52,9 +53,6 @@ public function testRunSerializedJob(): void

$this->mockGuzzleClient();

/** @var DepositIssue $depositIssueJob */
$depositIssueJob = unserialize($this->serializedJobData);

$issueMock = Mockery::mock(\APP\issue\Issue::class)
->makePartial()
->shouldReceive([
Expand Down Expand Up @@ -100,7 +98,28 @@ public function testRunSerializedJob(): void

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

$depositIssueJob->handle();
$contextMock = Mockery::mock(get_class(Application::getContextDAO()->newDataObject()))
->makePartial()
->shouldReceive('getData')
->getMock();

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

/**
* @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
*/
$depositIssueMock->handle();

$this->expectNotToPerformAssertions();
}
Expand Down

0 comments on commit 6ea1b64

Please sign in to comment.