(bug 41833) Test: Add AutoLoaderTest.
authorTimo Tijhof <ttijhof@wikimedia.org>
Wed, 7 Nov 2012 01:27:30 +0000 (02:27 +0100)
committerAntoine Musso <hashar@free.fr>
Sat, 10 Nov 2012 17:36:13 +0000 (18:36 +0100)
commit7c6c05a45926bd47eefc21ef75c9a3af83ae6cfc
tree97fd1275be9c86d6501c03cb335b8a4688b726e2
parent2c85e0dd5b690f819832d447a616781d2e7bdb8c
(bug 41833) Test: Add AutoLoaderTest.

* Move scattered pieces from tests/* in main AutoLoader.php
  into tests/TestsAutoLoader.php.
  Verified with:
  'ack -Q i --ignore-dir tests/phpunit/ <classname>'
  on mediawiki/core that these classes are not used outside
  tests/phpunit/.

* Moved entry for maintenance/backup.inc to the main AutoLoader.

* Refactored assertion logic in maintenance/checkAutoLoader.php
  into a public static method used in it's execute method
  and in the (new) AutoLoaderTest suite.

* The new test was immediately failing, added missing classes
  and removed old ones that don't exist.

  And CheckAutoLoader itself, so that it can actually be used
  in AutoLoaderTest.php

* Per discussion on Gerrit, moved the logic into the unit test
  instead of refactoring the maintenance script, we no longer
  need the maintenance script.

* Fixed the regex to also detect abstract, final and interface.
  The test was failing badly, claiming many classes did not
  exist.

* Improved the logic to also catch entries in the AutoLoader
  configuration for inexisting classes in existing files.
  So far it only catched entries with wrong files and missing
  entries for classes in known files.
  An entry like "BlablaSomethingHere => includes/Action.php"
  did not emit any kind of warning. The refactored logic
  builds a reverse index and uses a simple assertEquals to
  find any inconsistencies (whatever the cause).

Change-Id: I0a307f23175d52345180cdfc7c2d5e172536be1b
includes/AutoLoader.php
maintenance/checkAutoLoader.php [deleted file]
tests/TestsAutoLoader.php
tests/phpunit/AutoLoaderTest.php [new file with mode: 0644]