The introduction of Composer support in TYPO3 Flow has caused some confusion when it comes to installing and using PHPUnit. In the past, PHPUnit was usually installed using PEAR and available as a system-wide command.Now there are additional options: installation through Composer and as a standalone PHAR archive, each of them posing some issues.
PHPUnit installed via PEAR
Installing PHPUnit via PEAR is described in the PHPUnit manual, and besides the usual issues people seem to be having with PEAR in general, there is not much to say. If you have the phpunit command running, testing TYPO3 Flow applications boils down to
phpunit -c Build/BuildEssentials/PhpUnit/UnitTests.xml
phpunit -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml
PHPUnit installed via Composer
Installing PHPUnit via Composer is easy. Just edit the composer.json file at the top level of your project and require phpunit next to the vfsstream dependency:
"require-dev": {
"typo3/kickstart": "dev-master",
"typo3/buildessentials": "dev-master",
"phpunit/phpunit": "3.7.*",
"mikey179/vfsstream": "1.1.*"
},
Afterwards, the installation can be done with
composer update --dev phpunit/phpunit
You will end up with a PHPUnit binary at bin/phpunit and can thus run
bin/phpunit -c Build/BuildEssentials/PhpUnit/UnitTests.xml
bin/phpunit -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml
Attention (former) PEAR users: if you have PHPUnit installed globally and PEAR libraries are still in your include path, this may lead to very weird results. Just imagine PHPUnit from the composer install being used, but some parts of it are loaded from the PEAR path, possibly with mismatching versions…
So, if you use Composer to install PHPUnit, make sure no other version(s) of PHPUnit clutter your system.
PHPUnit standalone archive
Using the PHPUnit standalone archive is currently not possible. The problem is caused by the Flow bootstrap code and manifests in this error:
PHP Warning: require_once(PHPUnit/Autoload.php): failed to open stream: No such file or directory in …/TYPO3/Flow/Core/Bootstrap.php on line 92
Since the class loading in the archive seems to be handled differently (it might well be that adding the archive to the include_path would help), our assumption that this file exists breaks (some) tests.
Conclusion
If you have PHPUnit installed via PEAR, there is currently no reason to change that. We might at some point make PHPUnit a (dev) requirement for TYPO3 Flow, but until then it's your choice.
If you do not have PHPUnit installed right now, using Composer is the easiest choice.
Karsten Dambekalns |
If you decide to use PHPUnit via Composer and run into issues running tests with PhpStorm afterwards, make sure to vote on http://youtrack.jetbrains.com/issue/WI-13429 - the issue also contains a workaround: setting the autoload.php file for your project via configuration. That is a solution until the issue is officially resolved.
Akshay | 03.10.2013
This is definitely bteter than previous versions. However I still have issues with it on osx platform that are extremely annoying to me:- file save and load dialogs are aliens. UGLY non native contraptions that should never been let through the QA! Is there ANY hope for native file dialogs?- same goes for font and color dialogs!!!- Preferences window is amazing in one aspect -you can configure almost anything. But it looks terribly ugly and disorganized and simply does not have the polish that mac users would expect.- maybe I am missing something, but see no way to hide hidden files ( dot folders ) from the project tree.On the whole I think it is one of the bteter PHP ide's for mac, but general lack of polish, attention to details and disregard for native dialogs and conventions is what drags this product down.
Atmadeep | 15.10.2013
I'm using lots of javascript indise my smarty template (I know I should do that). Can PhpStorm somehow detect this javascript (for autocompletition). The same problem is with CSS included in template file. It is, probably, not detected correctly and therefore the color boxes (really great help) are not displayed. Both Javascript and CSS is working correctly when indise CSS and JS separate file.