createMock( WebRequest::class ); } public function testGetScript() { $module = new CiteDataModule(); $context = $this->createResourceLoaderContext(); $this->assertSame( 've.init.platform.addMessages({"cite-tool-definition.json":' . '"[{\"name\":\"n\",\"title\":\"t\"}]"});', $module->getScript( $context ) ); } public function testGetDependencies() { $module = new CiteDataModule(); $this->assertContainsOnly( 'string', $module->getDependencies() ); } public function testGetDefinitionSummary() { $module = new CiteDataModule(); $context = $this->createResourceLoaderContext(); $this->assertSame( $module->getScript( $context ), $module->getDefinitionSummary( $context )[0]['script'] ); } /** * @return ResourceLoaderContext */ private function createResourceLoaderContext() { $msg = $this->createMock( Message::class ); $msg->method( 'inContentLanguage' ) ->willReturnSelf(); $msg->method( 'plain' ) ->willReturnOnConsecutiveCalls( '', '[{"name":"n"}]', '[{"name":"n","title":"t"}]' ); $msg->method( 'text' ) ->willReturn( 't' ); $context = $this->createMock( ResourceLoaderContext::class ); $context->method( 'msg' ) ->withConsecutive( [ 'cite-tool-definition.json' ], [ 'visualeditor-cite-tool-definition.json' ], [ 'visualeditor-cite-tool-name-n' ], [ 'cite-tool-definition.json' ] ) ->willReturn( $msg ); return $context; } }