diff --git a/tests/phpunit/RecordLintJobTest.php b/tests/phpunit/RecordLintJobTest.php new file mode 100644 index 00000000..f4f16b76 --- /dev/null +++ b/tests/phpunit/RecordLintJobTest.php @@ -0,0 +1,66 @@ +getMock( Title::class, [ 'getLatestRevID', 'getArticleID' ] ); + $mock->expects( $this->any() )->method( 'getLatestRevID' )->willReturn( $revId ); + $mock->expects( $this->any() )->method( 'getArticleID' )->willReturn( $articleId ); + + return $mock; + } + + public function testRun() { + $error = [ + 'type' => 'fostered', + 'location' => [ 0, 10 ], + 'params' => [], + ]; + $job = new RecordLintJob( $this->getMockTitle(), [ + 'errors' => [ $error ], + 'revision' => 2, + ] ); + $this->assertTrue( $job->run() ); + /** @var LintError[] $errorsFromDb */ + $errorsFromDb = array_values( ( new Database( 1 ) )->getForPage() ); + $this->assertCount( 1, $errorsFromDb ); + $this->assertInstanceOf( LintError::class, $errorsFromDb[0] ); + $this->assertEquals( $error['type'], $errorsFromDb[0]->category ); + $this->assertEquals( $error['location'], $errorsFromDb[0]->location ); + $this->assertEquals( $error['params'], $errorsFromDb[0]->params ); + } +}