Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#9899 Submodule Update ##touhidurabir/i9899_patch_stable_3_4_0## #1693

Merged
merged 8 commits into from
Nov 8, 2024
2 changes: 1 addition & 1 deletion lib/pkp
Submodule pkp updated 30 files
+4 −19 classes/components/forms/context/PKPAppearanceSetupForm.php
+1 −0 classes/components/forms/publication/ContributorForm.php
+5 −3 classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php
+8 −1 classes/file/PKPLibraryFileManager.php
+4 −2 classes/template/PKPTemplateManager.php
+21 −24 classes/user/Collector.php
+1 −1 jobs/email/EditorialReminder.php
+3 −0 locale/en/manager.po
+6 −0 templates/controllers/grid/plugins/viewPlugin.tpl
+12 −1 tests/PKPTestCase.php
+4 −2 tests/classes/filter/FilterDAOTest.php
+13 −1 tests/jobs/bulk/BulkEmailSenderTest.php
+29 −0 tests/jobs/doi/DepositContextTest.php
+61 −11 tests/jobs/doi/DepositSubmissionTest.php
+58 −2 tests/jobs/email/EditorialReminderTest.php
+24 −3 tests/jobs/metadata/BatchMetadataChangedJobTest.php
+24 −3 tests/jobs/metadata/MetadataChangedJobTest.php
+57 −1 tests/jobs/notifications/NewAnnouncementNotifyUsersTest.php
+55 −2 tests/jobs/notifications/StatisticsReportMailTest.php
+75 −7 tests/jobs/notifications/StatisticsReportNotifyTest.php
+32 −0 tests/jobs/statistics/ArchiveUsageStatsLogFileTest.php
+11 −0 tests/jobs/statistics/CompileContextMetricsTest.php
+1 −1 tests/jobs/statistics/CompileMonthlyMetricsTest.php
+11 −0 tests/jobs/statistics/CompileSubmissionMetricsTest.php
+11 −0 tests/jobs/statistics/RemoveDoubleClicksTest.php
+13 −3 tests/jobs/submissions/RemoveSubmissionFileFromSearchIndexJobTest.php
+13 −3 tests/jobs/submissions/RemoveSubmissionFromSearchIndexJobTest.php
+11 −0 tests/jobs/submissions/UpdateSubmissionSearchJobTest.php
+1 −1 tests/phpunit.xml
+88 −0 tests/support/DoiRegistrationAgency.php
15 changes: 15 additions & 0 deletions tests/jobs/statistics/CompileCounterSubmissionDailyMetricsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ class CompileCounterSubmissionDailyMetricsTest extends PKPTestCase
O:56:"APP\jobs\statistics\CompileCounterSubmissionDailyMetrics":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";}
END;

/**
* @see PKPTestCase::getMockedDAOs()
*/
protected function getMockedDAOs(): array
{
return [
...parent::getMockedDAOs(),
'TemporaryTotalsDAO',
'TemporaryItemInvestigationsDAO',
'TemporaryItemRequestsDAO',
'TemporaryTitleInvestigationsDAO',
'TemporaryTitleRequestsDAO',
];
}

/**
* Test job is a proper instance
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ class CompileCounterSubmissionInstitutionDailyMetricsTest extends PKPTestCase
O:67:"APP\jobs\statistics\CompileCounterSubmissionInstitutionDailyMetrics":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";}
END;

/**
* @see PKPTestCase::getMockedDAOs()
*/
protected function getMockedDAOs(): array
{
return [
...parent::getMockedDAOs(),
'TemporaryTotalsDAO',
'TemporaryItemInvestigationsDAO',
'TemporaryItemRequestsDAO',
'TemporaryTitleInvestigationsDAO',
'TemporaryTitleRequestsDAO',
];
}

/**
* Test job is a proper instance
*/
Expand Down
11 changes: 11 additions & 0 deletions tests/jobs/statistics/CompileSeriesMetricsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ class CompileSeriesMetricsTest extends PKPTestCase
O:40:"APP\jobs\statistics\CompileSeriesMetrics":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";}
END;

/**
* @see PKPTestCase::getMockedDAOs()
*/
protected function getMockedDAOs(): array
{
return [
...parent::getMockedDAOs(),
'TemporaryTotalsDAO',
];
}

/**
* Test job is a proper instance
*/
Expand Down
12 changes: 12 additions & 0 deletions tests/jobs/statistics/CompileSubmissionGeoDailyMetricsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ class CompileSubmissionGeoDailyMetricsTest extends PKPTestCase
O:52:"APP\jobs\statistics\CompileSubmissionGeoDailyMetrics":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";}
END;

/**
* @see PKPTestCase::getMockedDAOs()
*/
protected function getMockedDAOs(): array
{
return [
...parent::getMockedDAOs(),
'TemporaryTotalsDAO',
'TemporaryTitleInvestigationsDAO',
];
}

/**
* Test job is a proper instance
*/
Expand Down
12 changes: 12 additions & 0 deletions tests/jobs/statistics/CompileUniqueInvestigationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ class CompileUniqueInvestigationsTest extends PKPTestCase
O:47:"APP\jobs\statistics\CompileUniqueInvestigations":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";}
END;

/**
* @see PKPTestCase::getMockedDAOs()
*/
protected function getMockedDAOs(): array
{
return [
...parent::getMockedDAOs(),
'TemporaryItemInvestigationsDAO',
'TemporaryTitleInvestigationsDAO',
];
}

/**
* Test job is a proper instance
*/
Expand Down
12 changes: 12 additions & 0 deletions tests/jobs/statistics/CompileUniqueRequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ class CompileUniqueRequestsTest extends PKPTestCase
O:41:"APP\jobs\statistics\CompileUniqueRequests":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";}
END;

/**
* @see PKPTestCase::getMockedDAOs()
*/
protected function getMockedDAOs(): array
{
return [
...parent::getMockedDAOs(),
'TemporaryItemRequestsDAO',
'TemporaryTitleRequestsDAO',
];
}

/**
* Test job is a proper instance
*/
Expand Down
16 changes: 16 additions & 0 deletions tests/jobs/statistics/DeleteUsageStatsTemporaryRecordsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ class DeleteUsageStatsTemporaryRecordsTest extends PKPTestCase
O:52:"APP\jobs\statistics\DeleteUsageStatsTemporaryRecords":3:{s:9:"\0*\0loadId";s:25:"usage_events_20240130.log";s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";}
END;

/**
* @see PKPTestCase::getMockedDAOs()
*/
protected function getMockedDAOs(): array
{
return [
...parent::getMockedDAOs(),
'TemporaryTotalsDAO',
'TemporaryItemInvestigationsDAO',
'TemporaryItemRequestsDAO',
'TemporaryTitleInvestigationsDAO',
'TemporaryTitleRequestsDAO',
'TemporaryInstitutionsDAO',
];
}

/**
* Test job is a proper instance
*/
Expand Down
57 changes: 53 additions & 4 deletions tests/jobs/statistics/ProcessUsageStatsLogFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@

namespace APP\tests\jobs\statistics;

use APP\jobs\statistics\ProcessUsageStatsLogFile;
use APP\statistics\StatisticsHelper;
use Mockery;
use ReflectionClass;
use PKP\db\DAORegistry;
use PKP\task\FileLoader;
use PKP\file\FileManager;
use PKP\tests\PKPTestCase;
use ReflectionClass;
use APP\statistics\StatisticsHelper;
use APP\jobs\statistics\ProcessUsageStatsLogFile;

/**
* @runTestsInSeparateProcesses
Expand All @@ -37,7 +38,23 @@ class ProcessUsageStatsLogFileTest extends PKPTestCase
/**
* Content example from OJS 3.4.0
*/
protected $dummyFileContent = '{"time":"2023-08-07 17:27:11","ip":"228dc4e5b6424e9dad52f21261cb2ab5f4651d9cb426d6fdb3d71d5ab8e2ae83","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko\/20100101 Firefox\/115.0","canonicalUrl":"http:\/\/ojs-stable-3_4_0.test\/index.php\/publicknowledge\/index","assocType":256,"contextId":1,"submissionId":null,"representationId":null,"submissionFileId":null,"fileType":null,"country":null,"region":null,"city":null,"institutionIds":[],"version":"3.4.0.0","issueId":null,"issueGalleyId":null}';
protected $dummyFileContent = '{"time":"2023-08-07 17:27:11","ip":"228dc4e5b6424e9dad52f21261cb2ab5f4651d9cb426d6fdb3d71d5ab8e2ae83","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko\/20100101 Firefox\/115.0","canonicalUrl":"http:\/\/ojs-stable-3_4_0.test\/index.php\/publicknowledge\/index","assocType":512,"contextId":1,"submissionId":null,"representationId":null,"submissionFileId":null,"fileType":null,"country":null,"region":null,"city":null,"institutionIds":[],"version":"3.4.0.0","issueId":null,"issueGalleyId":null}';

/**
* @see PKPTestCase::getMockedDAOs()
*/
protected function getMockedDAOs(): array
{
return [
...parent::getMockedDAOs(),
'TemporaryInstitutionsDAO',
'TemporaryTotalsDAO',
'TemporaryItemInvestigationsDAO',
'TemporaryItemRequestsDAO',
'TemporaryTitleInvestigationsDAO',
'TemporaryTitleRequestsDAO',
];
}

/**
* Test job is a proper instance
Expand All @@ -61,6 +78,8 @@ public function testRunSerializedJob(): void
// we need to create a dummy file if not existed as to avoid mocking PHP's built in functions
$dummyFile = $this->createDummyFileIfNeeded($processUsageStatsLogFileJob, 'loadId');

$this->createArchiveDirectoryIfRequired();

$temporaryInstitutionsDAOMock = Mockery::mock(\PKP\statistics\TemporaryInstitutionsDAO::class)
->makePartial()
->shouldReceive([
Expand Down Expand Up @@ -150,10 +169,40 @@ protected function createDummyFileIfNeeded(ProcessUsageStatsLogFile $job, string
. DIRECTORY_SEPARATOR;

if (!file_exists($filePath . $fileName)) {

// create the 'FileLoader::FILE_LOADER_PATH_DISPATCH' directory if not exists
if (!file_exists($filePath)) {
$fileManager = new FileManager();
$fileManager->mkdirtree($filePath);
}

touch($filePath . $fileName);

file_put_contents($filePath . $fileName, $this->dummyFileContent);
return $filePath . $fileName;
}

return null;
}

/**
* Create the archive path/directory as needed
*/
protected function createArchiveDirectoryIfRequired(): bool
{
$filePath = StatisticsHelper::getUsageStatsDirPath()
. DIRECTORY_SEPARATOR
. FileLoader::FILE_LOADER_PATH_ARCHIVE
. DIRECTORY_SEPARATOR;

if (file_exists($filePath)) {
return true;
}

// create the 'FileLoader::FILE_LOADER_PATH_ARCHIVE' directory if not exists
$fileManager = new FileManager();
$fileManager->mkdirtree($filePath);

return file_exists($filePath);
}
}
Loading