99use OCP \DB \IResult ;
1010use PHPUnit \Framework \TestCase ;
1111
12+ /**
13+ * @coversDefaultClass \OCA\Solid\JtiReplayDetector
14+ * @covers ::__construct
15+ * @covers ::<!public>
16+ */
1217class 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