Skip to content

Commit

Permalink
pkp/pkp-lib#9899 Updated deposite issue tests with mocked job class
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Sep 27, 2024
1 parent ed810df commit 31bf5f3
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 @@ -53,9 +54,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,6 +98,27 @@ public function testRunSerializedJob(): void

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

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

0 comments on commit 31bf5f3

Please sign in to comment.