diff options
Diffstat (limited to 'Thanks/tests/phpunit/ApiFlowThankIntegrationTest.php')
-rw-r--r-- | Thanks/tests/phpunit/ApiFlowThankIntegrationTest.php | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/Thanks/tests/phpunit/ApiFlowThankIntegrationTest.php b/Thanks/tests/phpunit/ApiFlowThankIntegrationTest.php index 7dfb237b..b8185c8e 100644 --- a/Thanks/tests/phpunit/ApiFlowThankIntegrationTest.php +++ b/Thanks/tests/phpunit/ApiFlowThankIntegrationTest.php @@ -3,6 +3,7 @@ use Flow\Model\AbstractRevision; use Flow\Model\PostRevision; use Flow\Model\UUID; +use Flow\Model\Workflow; /** * Integration tests for the Thanks Flow api module @@ -34,10 +35,10 @@ class ApiFlowThankIntegrationTest extends ApiTestCase { /** @var PostRevision */ public $postByMe; - public function setUp() { + public function setUp() : void { parent::setUp(); - if ( !class_exists( 'FlowHooks' ) ) { + if ( !ExtensionRegistry::getInstance()->isLoaded( 'Flow' ) ) { $this->markTestSkipped( 'Flow is not installed' ); } @@ -89,13 +90,13 @@ class ApiFlowThankIntegrationTest extends ApiTestCase { } ) ); - $mockWorkflow = $this->getMock( '\Flow\Model\Workflow' ); + $mockWorkflow = $this->createMock( Workflow::class ); $mockWorkflow->expects( $this->any() ) ->method( 'getOwnerTitle' ) - ->will( $this->returnValue( new Title() ) ); + ->willReturn( $this->createMock( Title::class ) ); $mockWorkflow->expects( $this->any() ) ->method( 'getArticleTitle' ) - ->will( $this->returnValue( new Title() ) ); + ->willReturn( $this->createMock( Title::class ) ); $mockStorage = $this->getMockBuilder( '\Flow\Data\ManagerGroup' ) ->disableOriginalConstructor() @@ -119,12 +120,12 @@ class ApiFlowThankIntegrationTest extends ApiTestCase { $container[ 'storage' ] = $mockStorage; $container[ 'templating' ] = $mockTemplating; - $this->doLogin( 'sysop' ); \DeferredUpdates::clearPendingUpdates(); } public function testRequestWithoutToken() { - $this->setExpectedException( 'ApiUsageException', 'The "token" parameter must be set.' ); + $this->expectException( ApiUsageException::class ); + $this->expectExceptionMessage( 'The "token" parameter must be set.' ); $this->doApiRequest( [ 'action' => 'flowthank', 'postid' => UUID::create( '42' )->getAlphadecimal(), @@ -132,7 +133,8 @@ class ApiFlowThankIntegrationTest extends ApiTestCase { } public function testInvalidRequest() { - $this->setExpectedException( 'ApiUsageException', 'The "postid" parameter must be set.' ); + $this->expectException( ApiUsageException::class ); + $this->expectExceptionMessage( 'The "postid" parameter must be set.' ); $this->doApiRequestWithToken( [ 'action' => 'flowthank' ] ); } @@ -145,7 +147,8 @@ class ApiFlowThankIntegrationTest extends ApiTestCase { } public function testRequestWithInvalidId() { - $this->setExpectedException( 'ApiUsageException', 'Post ID is not valid' ); + $this->expectException( ApiUsageException::class ); + $this->expectExceptionMessage( 'Post ID is not valid' ); list( $result,, ) = $this->doApiRequestWithToken( [ 'action' => 'flowthank', 'postid' => UUID::create( '42' )->getAlphadecimal(), @@ -153,7 +156,8 @@ class ApiFlowThankIntegrationTest extends ApiTestCase { } public function testRequestWithOwnId() { - $this->setExpectedException( 'ApiUsageException', 'You cannot thank yourself' ); + $this->expectException( ApiUsageException::class ); + $this->expectExceptionMessage( 'You cannot thank yourself' ); list( $result,, ) = $this->doApiRequestWithToken( [ 'action' => 'flowthank', 'postid' => $this->postByMe->getPostId()->getAlphadecimal(), @@ -161,7 +165,7 @@ class ApiFlowThankIntegrationTest extends ApiTestCase { } protected function assertSuccess( $result ) { - $this->assertEquals( 1, $result[ 'result' ][ 'success' ] ); + $this->assertSame( 1, $result[ 'result' ][ 'success' ] ); } /** @@ -191,7 +195,7 @@ class ApiFlowThankIntegrationTest extends ApiTestCase { 'rev_type' => 'post', 'rev_user_id' => $userId, 'rev_user_ip' => $userIp, - 'rev_user_wiki' => wfWikiId(), + 'rev_user_wiki' => wfWikiID(), 'rev_parent_id' => null, 'rev_flags' => 'html', 'rev_content' => 'test content', @@ -214,7 +218,7 @@ class ApiFlowThankIntegrationTest extends ApiTestCase { 'tree_orig_create_time' => wfTimestampNow(), 'tree_orig_user_id' => $userId, 'tree_orig_user_ip' => $userIp, - 'tree_orig_user_wiki' => wfWikiId(), + 'tree_orig_user_wiki' => wfWikiID(), 'tree_parent_id' => null, ]; } |