Skip to content

Commit

Permalink
pkp#10306 update context dao determining based on application name
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Sep 15, 2024
1 parent 25261f6 commit 2cad824
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion classes/core/PKPContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ public function environment(string ...$environments): string|bool
*/
public function runningUnitTests(): bool
{
return false;
return $this->isRunningUnitTest;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/PKPTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected function localeToRegExp(string $translation): string

/**
* Mock the mail facade
* @see https://laravel.com/docs/10.x/mocking
* @see https://laravel.com/docs/11.x/mocking
*/
protected function mockMail(): void
{
Expand Down
9 changes: 8 additions & 1 deletion tests/jobs/doi/DepositContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ public function testRunSerializedJob(): void
->andReturn($contextMock)
->getMock();

DAORegistry::registerDAO(substr(strrchr($contextDaoClass, '\\'), 1), $contextDaoMock);
DAORegistry::registerDAO(
match (Application::get()->getName()) {
'ojs2' => 'JournalDAO',
'omp' => 'PressDAO',
'ops' => 'ServerDAO',
},
$contextDaoMock
);

$doiRepoMock = Mockery::mock(app(DoiRepository::class))
->makePartial()
Expand Down
11 changes: 9 additions & 2 deletions tests/jobs/notifications/NewAnnouncementNotifyUsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,15 @@ public function testRunSerializedJob(): void
->withAnyArgs()
->andReturn($contextMock)
->getMock();

DAORegistry::registerDAO(substr(strrchr($contextDaoClass, '\\'), 1), $contextDaoMock);

DAORegistry::registerDAO(
match (Application::get()->getName()) {
'ojs2' => 'JournalDAO',
'omp' => 'PressDAO',
'ops' => 'ServerDAO',
},
$contextDaoMock
);

$emailTemplateMock = Mockery::mock(\PKP\emailTemplate\EmailTemplate::class)
->makePartial()
Expand Down
9 changes: 8 additions & 1 deletion tests/jobs/notifications/StatisticsReportMailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ public function testRunSerializedJob(): void
->andReturn($contextMock)
->getMock();

DAORegistry::registerDAO(substr(strrchr($contextDaoClass, '\\'), 1), $contextDaoMock);
DAORegistry::registerDAO(
match (Application::get()->getName()) {
'ojs2' => 'JournalDAO',
'omp' => 'PressDAO',
'ops' => 'ServerDAO',
},
$contextDaoMock
);

$emailTemplateMock = Mockery::mock(\PKP\emailTemplate\EmailTemplate::class)
->makePartial()
Expand Down

0 comments on commit 2cad824

Please sign in to comment.