Elgg/Elgg — pull request #248 by andres-fortier (2012-05-27 22:37:25+00:00)
Title: First refactored release to create fixtures from a clean elgg install.

Install steps:

1) Activate the PHPUnit Tests plugin. A new Settings page (PHPUnit Tests) should appear in the administrators page, with most setting already completed by default. Change them to match your particular installation adn define the users (admin and standard) that will be used in the tests.

When you hit the save button the plugin settings will be updated and the file engine/tests/config.ini will be created/updated to match the settings contents.

IMPORTANT: The engine/tests/ dir should have write permissions

2) In a terminal run engine/tests/php test_install.php
As a result the test DB should be populated and a fixture per table should be created in the engine/tests/fixtures/ dir

IMPORTANT: The engine/tests/fixtures/ dir should have write permissions

3) Go to engine/tests/tests/ and run:

phpunit --process-isolation ElggTestDBReloadTest.php

you should see:

PHPUnit 3.6.10 by Sebastian Bergmann.

..

Time: 4 seconds, Memory: 3.00Mb

and then:
phpunit --process-isolation ElggTestRestoredTablesTest.php

to see:

PHPUnit 3.6.10 by Sebastian Bergmann.

....

Time: 9 seconds, Memory: 3.00Mb

OK (4 tests, 121 assertions)

IMPORTANT: To run these tests (the "meta tests") the DB user must have RELOAD and SUPER DB privileges

---------------------------------------------------------------------------------
Some misc notes:
- The following lines were added to the .gitignore file:
/engine/tests/config.ini
/engine/tests/fixtures/*
!/mod/phpunit_tests/
- Metatests working ok. Next step is to update the elgg tests to their newest versions.

---------------------------------------------------------------------------------
TO DO
- Supress both types of caches after install
- After running the installation, try to change each table engine to in-memory to speedup tests. If a table has column types that are notn suited for MEMORY
tables (see http://dev.mysql.com/doc/refman/5.0/en/memory-storage-engine.html) the alter table will fail and the table shoudl remain as original.
- Create a Fixture class so that we can do smarter things with fixtures like:
- Try truncating the table instead of dropping/creating it if the structure hasn't changed.
- If the previous is achieved and the table is in memory, checking if a fixture si empty so that loading the fixture becomes a non-op
- Add a fixture-exclusion list to the test case to avoid loading fixtures foe given tables (e.g. log). Of course, let this be configurable so that
suclasses can change this
- Remove the warnings from the batch install