Skip to content

Commit

Permalink
Add test timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
malberts authored and JeroenDeDauw committed Jul 5, 2024
1 parent ee3b7b3 commit b2ed244
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions tests/Adapters/DatabasePendingApprovalRetrieverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,26 @@ public function testReturnsLatestApprovalStatus(): void {
$this->approverRepository->setApproverCategories( $approverId, [ 'Category1' ] );

$page = $this->createPage( true, [ 'Category1' ] );
$this->insertApprovalLogEntry( $page->getId(), false, '20230102000000' );
$this->insertApprovalLogEntry( $page->getId(), false, '30230102000000' );

$pendingApprovals = $this->retriever->getPendingApprovalsForApprover( $approverId );

$this->assertCount( 1, $pendingApprovals );
$this->assertSame( $page->getTitle()->getText(), $pendingApprovals[0]->title->getText() );
}

public function testReturnsNoApprovalStatusWhenLatestIsApproved(): void {
$approverId = 1;
$this->approverRepository->setApproverCategories( $approverId, [ 'Category1' ] );

$page = $this->createPage( true, [ 'Category1' ] );
$this->insertApprovalLogEntry( $page->getId(), false, '20230102000000' );

$pendingApprovals = $this->retriever->getPendingApprovalsForApprover( $approverId );

$this->assertCount( 0, $pendingApprovals );
}

public function testRespectsLimit(): void {
$approverId = 1;
$this->approverRepository->setApproverCategories( $approverId, [ 'Category1' ] );
Expand Down Expand Up @@ -141,17 +153,19 @@ public function testReturnsNoPendingApprovalsAfterApprovingAnUnapprovedPage(): v
$approverId = 1;
$this->approverRepository->setApproverCategories( $approverId, [ 'Foo' ] );

$page = $this->createPage( true, [ 'Foo' ] );
$page = $this->createPageWithCategories( [ 'Foo' ] );

$this->insertApprovalLogEntry( $page->getId(), true, '20240705000000' );

$pendingApprovals = $this->retriever->getPendingApprovalsForApprover( $approverId );
$this->assertCount( 0, $pendingApprovals );

$this->insertApprovalLogEntry( $page->getId(), false );
$this->insertApprovalLogEntry( $page->getId(), false, '20240706000001' );

$pendingApprovals = $this->retriever->getPendingApprovalsForApprover( $approverId );
$this->assertCount( 1, $pendingApprovals );

$this->insertApprovalLogEntry( $page->getId(), true );
$this->insertApprovalLogEntry( $page->getId(), true, '20240706000002' );

$pendingApprovals = $this->retriever->getPendingApprovalsForApprover( $approverId );
$this->assertCount( 0, $pendingApprovals );
Expand Down

0 comments on commit b2ed244

Please sign in to comment.