Merge "Introduce basic SpecialEditWatchlistTest"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 24 Mar 2016 15:06:30 +0000 (15:06 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 24 Mar 2016 15:06:30 +0000 (15:06 +0000)
includes/specials/SpecialWatchlist.php
tests/phpunit/includes/specials/SpecialWatchlistTest.php [new file with mode: 0644]

index 2dda093..27e5829 100644 (file)
@@ -382,7 +382,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        }
 
                        if ( isset( $watchedItemStore ) ) {
-                               $rcTitleValue = new TitleValue( $obj->rc_namespace, $obj->rc_title );
+                               $rcTitleValue = new TitleValue( (int)$obj->rc_namespace, $obj->rc_title );
                                $rc->numberofWatchingusers = $watchedItemStore->countWatchers( $rcTitleValue );
                        } else {
                                $rc->numberofWatchingusers = 0;
diff --git a/tests/phpunit/includes/specials/SpecialWatchlistTest.php b/tests/phpunit/includes/specials/SpecialWatchlistTest.php
new file mode 100644 (file)
index 0000000..6e702b6
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * @author Addshore
+ *
+ * @group Database
+ *
+ * @covers SpecialWatchlist
+ */
+class SpecialWatchlistTest extends SpecialPageTestBase {
+
+       /**
+        * Returns a new instance of the special page under test.
+        *
+        * @return SpecialPage
+        */
+       protected function newSpecialPage() {
+               return new SpecialWatchlist();
+       }
+
+       public function testNotLoggedIn_throwsException() {
+               $this->setExpectedException( 'UserNotLoggedIn' );
+               $this->executeSpecialPage();
+       }
+
+       public function testUserWithNoWatchedItems_displaysNoWatchlistMessage() {
+               $user = new TestUser( __METHOD__ );
+               list( $html, ) = $this->executeSpecialPage( '', null, 'qqx', $user->getUser() );
+               $this->assertContains( '(nowatchlist)', $html );
+       }
+
+}