Skip to content

Commit

Permalink
pkp#10306 added unit test for job RemoveExpiredInvitationsJob
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Aug 29, 2024
1 parent 3e1cd67 commit 52a5370
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
1 change: 0 additions & 1 deletion jobs/invitations/RemoveExpiredInvitationsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace PKP\jobs\invitations;

use APP\facades\Repo;
use PKP\invitation\models\InvitationModel;
use PKP\jobs\BaseJob;

Expand Down
54 changes: 54 additions & 0 deletions tests/jobs/invitations/RemoveExpiredInvitationsJobTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/**
* @file tests/jobs/submissions/UpdateSubmissionSearchJobTest.php
*
* Copyright (c) 2024 Simon Fraser University
* Copyright (c) 2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @brief Tests for the submission search reindexing job.
*/

namespace PKP\tests\jobs\submissions;

use PKP\tests\PKPTestCase;
use PKP\jobs\invitations\RemoveExpiredInvitationsJob;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\Attributes\CoversClass;

#[RunTestsInSeparateProcesses]
#[CoversClass(RemoveExpiredInvitationsJob::class)]
class RemoveExpiredInvitationsJobTest extends PKPTestCase
{
/**
* serializion from OJS 3.4.0
*/
protected string $serializedJobData = <<<END
O:48:"PKP\jobs\invitations\RemoveExpiredInvitationsJob":2:{s:10:"connection";s:8:"database";s:5:"queue";s:5:"queue";}
END;

/**
* Test job is a proper instance
*/
public function testUnserializationGetProperJobInstance(): void
{
$this->assertInstanceOf(
RemoveExpiredInvitationsJob::class,
unserialize($this->serializedJobData)
);
}

/**
* Ensure that a serialized job can be unserialized and executed
*/
public function testRunSerializedJob(): void
{
/** @var RemoveExpiredInvitationsJob $removeExpiredInvitationsJob */
$removeExpiredInvitationsJob = unserialize($this->serializedJobData);

// Test that the job can be handled without causing an exception.
$this->assertNull($removeExpiredInvitationsJob->handle());
}
}

0 comments on commit 52a5370

Please sign in to comment.