Skip to content

Commit 4aeb908

Browse files
committed
Add unit-test code-coverage docblocks.
1 parent 0a5733f commit 4aeb908

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

solid/tests/Unit/JtiReplayDetectorTest.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
use OCP\DB\IResult;
1010
use PHPUnit\Framework\TestCase;
1111

12+
/**
13+
* @coversDefaultClass \OCA\Solid\JtiReplayDetector
14+
* @covers ::__construct
15+
* @covers ::<!public>
16+
*/
1217
class JtiReplayDetectorTest extends TestCase
1318
{
14-
public static function setUpBeforeClass(): void
15-
{
16-
require_once __DIR__.'/../../lib/JtiReplayDetector.php';
17-
}
18-
1919
private function createMocks($result)
2020
{
2121
$mockIDBConnection = $this->createMock(IDBConnection::class);
2222
$mockQueryBuilder = $this->createMock(IQueryBuilder::class);
2323
$mockExpr = $this->createMock(IExpressionBuilder::class);
2424
$mockResult = $this->createMock(IResult::class);
25-
25+
2626
$mockIDBConnection->expects($this->any())
2727
->method('getQueryBuilder')
2828
->willReturn($mockQueryBuilder);
@@ -34,7 +34,7 @@ private function createMocks($result)
3434
->willReturn($mockExpr);
3535
$mockExpr->expects($this->any())
3636
->method('eq')
37-
->willReturn("");
37+
->willReturn('');
3838
$mockQueryBuilder->expects($this->once())
3939
->method('from')
4040
->willReturnSelf();
@@ -67,27 +67,33 @@ private function createMocks($result)
6767
return $mockIDBConnection;
6868
}
6969

70+
/**
71+
* @covers ::detect
72+
*/
7073
public function testJtiDetected(): void
71-
{
74+
{
7275
$dateInterval = new DateInterval('PT90S');
7376
$mockIDBConnection = $this->createMocks(true);
74-
77+
7578
$detector = new JtiReplayDetector($dateInterval, $mockIDBConnection);
76-
79+
7780
$mockUUID = 'mockUUID-with-some-more-text';
7881
$mockURI = 'mockURI';
7982
$result = $detector->detect($mockUUID, $mockURI);
8083

8184
$this->assertTrue($result);
8285
}
8386

87+
/**
88+
* @covers ::detect
89+
*/
8490
public function testJtiNotDetected(): void
8591
{
8692
$dateInterval = new DateInterval('PT90S');
8793
$mockIDBConnection = $this->createMocks(false);
88-
94+
8995
$detector = new JtiReplayDetector($dateInterval, $mockIDBConnection);
90-
96+
9197
$mockUUID = 'mockUUID-with-some-more-text';
9298
$mockURI = 'mockURI';
9399
$result = $detector->detect($mockUUID, $mockURI);

0 commit comments

Comments
 (0)