Manual:PHP unit testing/PostgreSQL

StatusEdit

MediaWiki's PHPUnit test suite as a whole runs ok on a PostgreSQL configuration.

Hints for devsEdit

Setting up a pgsql environment on Ubuntu Linux:

  • apt-get install postgresql php5-pgsql
  • Follow notes from eg [1] on setting up a password for 'postgres' special user
  • If lazy, throw that 'postgres' username and password straight into MediaWiki's installer

Ideally, you should probably set up an account for the wiki etc, but who knows man!

Possible problemsEdit

It kinda looks like things are modifying the core database that shouldn't... after running the unit tests a couple times through, I saw my wiki has been cluttered with extra users:

    Altuseruser (Created on 24 October 2011 at 15:42)
    Apitestsysop (Created on 24 October 2011 at 15:42)
    Apitestuser (Created on 24 October 2011 at 15:42)
    Brionv‏‎ (administrator, bureaucrat) (Created on 24 October 2011 at 15:39)
    Uploadstashtestsysop (Created on 24 October 2011 at 15:40)
    Uploadstashtestuser (Created on 24 October 2011 at 15:40)
    Useruser (Created on 24 October 2011 at 15:42)
    UTApiBlockee (Created on 24 October 2011 at 15:42)
    UTBlockee (Created on 24 October 2011 at 15:42)
    UTSysop (Created on 24 October 2011 at 15:40)

The unit tests should not alter the live database, and these don't end up visible on a MySQL instance...

Ditto with the #Test failures below, looks like a live count is being updated?


Had to bump up $wgMaxShellMemory and $wgMaxShellFileSize to make some shell-out commands happy.

Test failuresEdit

There was 1 failure:

1) ParserTests::testParserTest with data set #182 ('Magic Word: {{NUMBEROFFILES}}', '{{NUMBEROFFILES}}', '<p>2
</p>', '', '')
Magic Word: {{NUMBEROFFILES}}
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-<p>2
+<p>366
 </p>

/var/www/pg/tests/phpunit/includes/parser/NewParserTest.php:540
/var/www/pg/tests/phpunit/MediaWikiTestCase.php:61
/var/www/pg/tests/phpunit/MediaWikiPHPUnitCommand.php:31
/var/www/pg/tests/phpunit/phpunit.php:60

We have a larger number than expected, not really sure why. Possibly something's awry with the test table setup.


Skipped testsEdit

There were 5 skipped tests:

1) SearchEngineTest::testFullWidth
MySQL or SQLite with FTS3 only

/var/www/pg/tests/phpunit/includes/search/SearchEngineTest.php:29
/var/www/pg/tests/phpunit/MediaWikiTestCase.php:61
/var/www/pg/tests/phpunit/MediaWikiPHPUnitCommand.php:31
/var/www/pg/tests/phpunit/phpunit.php:60
2) SearchEngineTest::testTextSearch
MySQL or SQLite with FTS3 only

/var/www/pg/tests/phpunit/includes/search/SearchEngineTest.php:29
/var/www/pg/tests/phpunit/MediaWikiTestCase.php:61
/var/www/pg/tests/phpunit/MediaWikiPHPUnitCommand.php:31
/var/www/pg/tests/phpunit/phpunit.php:60
3) SearchEngineTest::testTextPowerSearch
MySQL or SQLite with FTS3 only

/var/www/pg/tests/phpunit/includes/search/SearchEngineTest.php:29
/var/www/pg/tests/phpunit/MediaWikiTestCase.php:61
/var/www/pg/tests/phpunit/MediaWikiPHPUnitCommand.php:31
/var/www/pg/tests/phpunit/phpunit.php:60
4) SearchEngineTest::testTitleSearch
MySQL or SQLite with FTS3 only

/var/www/pg/tests/phpunit/includes/search/SearchEngineTest.php:29
/var/www/pg/tests/phpunit/MediaWikiTestCase.php:61
/var/www/pg/tests/phpunit/MediaWikiPHPUnitCommand.php:31
/var/www/pg/tests/phpunit/phpunit.php:60
5) SearchEngineTest::testTextTitlePowerSearch
MySQL or SQLite with FTS3 only

/var/www/pg/tests/phpunit/includes/search/SearchEngineTest.php:29
/var/www/pg/tests/phpunit/MediaWikiTestCase.php:61
/var/www/pg/tests/phpunit/MediaWikiPHPUnitCommand.php:31
/var/www/pg/tests/phpunit/phpunit.php:60


Probably these test cases need updating to make sure they run on PG's search engine as well.