Improve test coverage for ApiDelete.php
[lhc/web/wiklou.git] / includes / api / ApiDelete.php
index 72bbe00..a63dee6 100644 (file)
@@ -1,9 +1,5 @@
 <?php
 /**
- *
- *
- * Created on Jun 30, 2007
- *
  * Copyright © 2007 Roan Kattouw "<Firstname>.<Lastname>@gmail.com"
  *
  * This program is free software; you can redistribute it and/or modify
@@ -59,7 +55,7 @@ class ApiDelete extends ApiBase {
 
                // If change tagging was requested, check that the user is allowed to tag,
                // and the tags are valid
-               if ( count( $params['tags'] ) ) {
+               if ( $params['tags'] ) {
                        $tagStatus = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
                        if ( !$tagStatus->isOK() ) {
                                $this->dieStatus( $tagStatus );
@@ -106,7 +102,7 @@ class ApiDelete extends ApiBase {
         *
         * @param Page|WikiPage $page Page or WikiPage object to work on
         * @param User $user User doing the action
-        * @param string|null $reason Reason for the deletion. Autogenerated if null
+        * @param string|null &$reason Reason for the deletion. Autogenerated if null
         * @param array $tags Tags to tag the deletion with
         * @return Status
         */
@@ -120,7 +116,8 @@ class ApiDelete extends ApiBase {
                        $hasHistory = false;
                        $reason = $page->getAutoDeleteReason( $hasHistory );
                        if ( $reason === false ) {
-                               return Status::newFatal( 'cannotdelete', $title->getPrefixedText() );
+                               // Should be reachable only if the page has no revisions
+                               return Status::newFatal( 'cannotdelete', $title->getPrefixedText() ); // @codeCoverageIgnore
                        }
                }
 
@@ -142,7 +139,7 @@ class ApiDelete extends ApiBase {
         * @param Page $page Object to work on
         * @param User $user User doing the action
         * @param string $oldimage Archive name
-        * @param string $reason Reason for the deletion. Autogenerated if null.
+        * @param string &$reason Reason for the deletion. Autogenerated if null.
         * @param bool $suppress Whether to mark all deleted versions as restricted
         * @param array $tags Tags to tag the deletion with
         * @return Status