[TYPO3-dev] OT (somewhat): unit testing with typo3 4.x
Christoph Koehler
christoph.koehler at gmail.com
Fri Mar 9 20:47:44 CET 2007
Hello all,
We would like to start unit testing our extensions. One big requirement is
the use of the command line to implement post commit hooks etc, so
Robert's extension t3unit is unfortunately not an option.
Now, I needed to include the typo3 environment in all my tests and ended
up just copying most of index.php and index_ts.php into the test. However,
I ran into some problems and already talked to the author about it [1],
but no luck; so in case I am missing something, I am presenting it here to
make sure I am doing things correctly.
First, you can download all the files from my site [2].
Second, remove the .txt and put the files into your typo3 root.
Third, run the test via 'phpunit exampleTest'. It should tell you that the
extension cms isn't loaded.
Fourth, add a debug call in the TYPO3 source in file
class.t3lib_extmgm.php, around line 922, to display the contents of
$TYPO3_CONF_VARS, right after the statement 'global $TYPO3_CONF_VARS; it
will show up empty.
To make it simpler, I made a test case. That's the bugtest file. Run it
from the command line via 'php bugtest.php' and 'phpunit bugtest' and you
should see that global variable is handled differently when called from an
outside class 'tester'; correctly in php, incorrectly in phpunit.
Obviously this makes unit testing from without the TYPO3 environment
impossible.
Am I missing something here? Is there a way around this?
Thanks!
Christoph
[1] http://phpunit.de/ticket/99
[2] http://www.zerodeviation.net/unittest/
More information about the TYPO3-dev
mailing list