Get ~100% test coverage for ApiEditPage.php and fix a couple of bugs
authorAryeh Gregor <ayg@aryeh.name>
Tue, 20 Mar 2018 13:25:26 +0000 (15:25 +0200)
committerAryeh Gregor <ayg@aryeh.name>
Wed, 28 Mar 2018 12:33:24 +0000 (15:33 +0300)
commit0b9edb467bbe687ff4e29088a4e5f008770a07a8
tree7ce6d5b1dc970d4796b4550b56d1c6ffc071df22
parent6f9c30c67b31b12d39f2d54b431e141869895eca
Get ~100% test coverage for ApiEditPage.php and fix a couple of bugs

Bugs fixed:

* The major one was that appendtext and prependtext seemingly didn't
  work at all on empty pages in the MediaWiki namespace, because
  $this->getTitle() was being used in place of $titleObj.
* Negative undo/undoafter were not rejected in a correct fashion.
* If a logged-in user who was not allowed to upload images tried to
  create an image redirect, the error message used a nonexistent key.

I also replaced assertEquals with assertSame.

I also removed a bit of clearly dead code.  This includes a "break"
following dieStatus().  If we actually want this break so that nobody
adds a case after the default and then removes the dieStatus() so the
switch incorrectly falls through, it could be re-added with
@codeCoverageIgnore.

I put the fixes in the same commit as the test changes because I like to
keep fixes together with the tests for those fixes.

All code now shows up as covered locally, except for one line that seems
to be a PHPUnit bug.

Change-Id: I9375bc5f40268fd681a2d447c66a03f40b23390a
includes/api/ApiEditPage.php
tests/common/TestsAutoLoader.php
tests/phpunit/includes/api/ApiEditPageTest.php
tests/phpunit/mocks/content/DummyContentHandlerForTesting.php
tests/phpunit/mocks/content/DummySerializeErrorContentHandler.php [new file with mode: 0644]