Nik has submitted this change and it was merged.
Change subject: Wikibase and configuration setup test inserted.
......................................................................
Wikibase and configuration setup test inserted.
Change-Id: I806ce24c83723ffd31ead9cab83afa34cd7e12b7
---
M tests/phpunit/PubSubHubbubTest.php
1 file changed, 57 insertions(+), 25 deletions(-)
Approvals:
Nik: Looks good to me, approved
WikidataJenkins: Verified
diff --git a/tests/phpunit/PubSubHubbubTest.php
b/tests/phpunit/PubSubHubbubTest.php
index 778ebc1..fd49384 100644
--- a/tests/phpunit/PubSubHubbubTest.php
+++ b/tests/phpunit/PubSubHubbubTest.php
@@ -18,11 +18,25 @@
$this->setMwGlobals( array(
'wgContLang' => \Language::factory( 'en' ),
'wgLanguageCode' => 'en',
+ 'wgPubSubHubbubHubURL' => 'https://www.example.com',
) );
}
protected function tearDown() {
parent::tearDown();
+ }
+
+ /**
+ * @dataProvider configData
+ *
+ * @param $HubURL
+ */
+ public function testIsConfigurationSetUp( $HubURL ) {
+ global $wgPubSubHubbubHubURL;
+ $this->setMwGlobals( array(
+ 'wgPubSubHubbubHubURL' => $HubURL,
+ ) );
+ $this->assertEquals( isset( $wgPubSubHubbubHubURL ),
PubSubHubbub::isConfigurationSetUp() );
}
/**
@@ -53,37 +67,40 @@
*
* @param string $titleText
* @param string $urlText
- * @param string $hubURL
*/
- public function testCreateLinkHeader( $titleText, $urlText, $hubURL ) {
- global $wgScript, $wgServer;
+ public function testCreateLinkHeader( $titleText, $urlText) {
+ global $wgScript, $wgServer, $wgPubSubHubbubHubURL;
$title = \Title::newFromText( $titleText );
$article = new \Article( $title );
$titleURL = $wgServer . $wgScript . "?title=" . $urlText .
"&action=raw";
- $linkHeader = "Link: <" . $hubURL . ">; rel=\"hub\", <" .
$titleURL . ">; rel=\"self\"";
+ $linkHeader = "Link: <" . $wgPubSubHubbubHubURL . ">;
rel=\"hub\", <" . $titleURL . ">; rel=\"self\"";
- $this->assertEquals( $linkHeader,
PubSubHubbub::createLinkHeader( $hubURL, $article ) );
+ $this->assertEquals( $linkHeader,
PubSubHubbub::createLinkHeader( $wgPubSubHubbubHubURL, $article ) );
}
- public function testPageHeaders() {
- global $wgPubSubHubbubHubURL;
- $title = \Title::newFromText( "test" );
- $page = new \Article( $title );
+ /**
+ * @dataProvider WBLinkHeaderData
+ *
+ * @param string $titleText
+ * @param string $urlText
+ */
+ public function testCreateWBLinkHeader( $titleText, $urlText) {
+ if ( defined( 'WB_VERSION' ) ) {
+ global $wgScript, $wgServer, $wgPubSubHubbubHubURL;
- $url = $title->getCanonicalURL();
- $rawURL = PubSubHubbub::getPageURL( $title );
- $linkheader = PubSubHubbub::createLinkHeader(
$wgPubSubHubbubHubURL, $page );
+ $ns = \Wikibase\NamespaceUtils::getEntityNamespace(
'wikibase-item' );
+ $title = \Title::newFromText( $titleText, $ns );
+ $article = new \Article( $title );
- $headers = get_headers( $url );
- $this->assertTrue( in_array( $linkheader, $headers ) );
- $count_array = array_count_values( $headers );
- $this->assertEquals( $count_array[$linkheader], 1 );
+ $titleURL = $wgServer . $wgScript .
"/Special:EntityData/" . $urlText . ".json";
+ $linkHeader = "Link: <" . $wgPubSubHubbubHubURL . ">;
rel=\"hub\", <" . $titleURL . ">; rel=\"self\"";
- $headers = get_headers( $rawURL );
- $this->assertTrue( in_array( $linkheader, $headers ) );
- $count_array = array_count_values( $headers );
- $this->assertEquals( $count_array[$linkheader], 1 );
+ $this->assertEquals( $linkHeader,
PubSubHubbub::createLinkHeader( $wgPubSubHubbubHubURL, $article ) );
+ }
+ else {
+ $this->markTestSkipped('The Wikibase-extension is not
available.');
+ }
}
public function contentSaveData() {
@@ -108,12 +125,27 @@
return $data;
}
- public function linkHeaderData() {
+ public function linkHeaderData() {
return array(
- array( 'test', 'Test', 'https://pshbwiki.example.com/'
),
- array( 'Foo1', 'Foo1', 'https://pshbwiki.example.com/'
),
- array( '2bar', '2bar', 'https://pshbwiki.example.com/'
),
- array( 'Fär', 'F%C3%A4r',
'https://pshbwiki.example.com/' )
+ array( 'test', 'Test' ),
+ array( 'Foo1', 'Foo1' ),
+ array( '2bar', '2bar' ),
+ array( 'Fär', 'F%C3%A4r' )
+ );
+ }
+
+ public function WBLinkHeaderData() {
+ return array(
+ array( 'Item:Q2', 'Q2' ),
+ array( 'Item:Q100', 'Q100' ),
+ array( 'Item:Q5', 'Q5' ),
+ );
+ }
+
+ public function configData() {
+ return array(
+ array( null ),
+ array( 'https://www.example.com' )
);
}
}
--
To view, visit https://gerrit.wikimedia.org/r/123635
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I806ce24c83723ffd31ead9cab83afa34cd7e12b7
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/PubSubHubbub
Gerrit-Branch: master
Gerrit-Owner: Alexander.lehmann <[email protected]>
Gerrit-Reviewer: Nik <[email protected]>
Gerrit-Reviewer: WikidataJenkins <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits