MakeGood + PHPUnit + Eclipse Luna - php

I try to do tests with PHPUnit & MakeGood on Eclipse but when i run the test from MakeGood i have an error like that :
"Class 'PHPUnit_Framework_TestSuite' not found in D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\piece\stagehand-testrunner\src\Collector\PHPUnitCollector.php on line 124
Call Stack:
0.0029 267904 1. {main}()
D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\bin\testrunner.php:0
0.3527 2733800 2. Symfony\Component\Console\Application->run() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\bin\testrunner.php:55
0.3988 3124008 3. Symfony\Component\Console\Application->doRun() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\symfony\console\Symfony\Component\Console\Application.php:124
0.4046 3125048 4. Symfony\Component\Console\Application->doRunCommand() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\symfony\console\Symfony\Component\Console\Application.php:193
0.4052 3125472 5. Symfony\Component\Console\Command\Command->run() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\symfony\console\Symfony\Component\Console\Application.php:887
0.4398 3131080 6. Stagehand\TestRunner\CLI\TestRunnerApplication\Command\PluginCommand->execute() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\symfony\console\Symfony\Component\Console\Command\Command.php:252
0.6717 4411720 7. Stagehand\TestRunner\CLI\TestRunnerApplication\Command\PluginCommand->createTestRunner() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\piece\stagehand-testrunner\src\CLI\TestRunnerApplication\Command\PluginCommand.php:149
0.6718 4411848 8. Stagehand\TestRunner\Core\ApplicationContext->createComponent() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\piece\stagehand-testrunner\src\CLI\TestRunnerApplication\Command\PluginCommand.php:295
0.6718 4411912 9. Stagehand\ComponentFactory\ComponentFactory->create() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\piece\stagehand-testrunner\src\Core\ApplicationContext.php:104
0.6720 4412416 10. Symfony\Component\DependencyInjection\Container->get() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\piece\stagehand-componentfactory\src\Stagehand\ComponentFactory\ComponentFactory.php:76
0.6721 4413008 11. Stagehand\TestRunner\DependencyInjection\PHPUnitContainer->getTestRunnerService() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\symfony\dependency-injection\Symfony\Component\DependencyInjection\Container.php:312
0.6854 4475880 12. Symfony\Component\DependencyInjection\Container->get() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\piece\stagehand-testrunner\src\DependencyInjection\PHPUnitContainer.php:448
0.6856 4476408 13. Stagehand\TestRunner\DependencyInjection\PHPUnitContainer->getPhpunit_CollectorService() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\symfony\dependency-injection\Symfony\Component\DependencyInjection\Container.php:312
0.6943 4601016 14. Stagehand\TestRunner\Collector\Collector->__construct() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\piece\stagehand-testrunner\src\DependencyInjection\PHPUnitContainer.php:302
0.6943 4601120 15. Stagehand\TestRunner\Collector\PHPUnitCollector->createTestSuite() D:\Downloads\eclipse\plugins\com.piece_framework.makegood.stagehandtestrunner_3.1.1.v201409021510\resources\php\vendor\piece\stagehand-testrunner\src\Collector\Collector.php:92
"
I correctly import the phpunit.phar in my project on Eclipse (because after this december Pear will be no longer available with PHPUnit) but MakeGood look as he doesn't really happy ...
Thank you in advance for your help.

Currently, MakeGood does not support phpunit.phar. Use PHPUnit as a Composer package as the following:
composer require --dev phpunit/phpunit "4.4.*"

Related

Symfony - Circular reference detected only only cache-clear prod

somethings is weird with my cache:clear : in dev environment there's no error but if I did with cache:clear --env=prod , I've got a "Circular reference detected for service".
What's wrong ?
Copy of the stacktrace :
Exception trace:
() at /var/www/nf-platform/symfony/app/bootstrap.php.cache:2235
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/ Symfony/Bridge/Doctrine/ManagerRegistry.php:35
Symfony\Bridge\Doctrine\ManagerRegistry->getService() at /var/www/nf-platform/symfony/vendor/doctrine/common/lib/D octrine/Common/Persistence/AbstractManagerRegistry.php:183
Doctrine\Common\Persistence\AbstractManagerRegistry->getManager() at /var/www/nf-platform/symfony/vendor/lexik/tra nslation-bundle/Lexik/Bundle/TranslationBundle/Storage/AbstractDoctrineStorage.php:48
Lexik\Bundle\TranslationBundle\Storage\AbstractDoctrineStorage->getManager() at /var/www/nf-platform/symfony/vendo r/lexik/translation-bundle/Lexik/Bundle/TranslationBundle/Storage/DoctrineORMStorage.php:19
Lexik\Bundle\TranslationBundle\Storage\DoctrineORMStorage->translationsTablesExist() at /var/www/nf-platform/symfo ny/vendor/lexik/translation-bundle/Lexik/Bundle/TranslationBundle/EventDispatcher/GetDatabaseResourcesListener.php: 41
Lexik\Bundle\TranslationBundle\EventDispatcher\GetDatabaseResourcesListener->onGetDatabaseResources() at n/a:n/a
call_user_func() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Even tDispatcher.php:184
Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() at /var/www/nf-platform/symfony/vendor/symfony/sym fony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:46
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at /var/www/nf-platform/symfony/vendor/lexik/transla tion-bundle/Lexik/Bundle/TranslationBundle/Translation/Translator.php:28
Lexik\Bundle\TranslationBundle\Translation\Translator->addDatabaseResources() at /var/www/nf-platform/symfony/app/ cache/pro_/appProdProjectContaine_.php:3871
appProdProjectContaine_->getLexikTranslation_TranslatorService() at /var/www/nf-platform/symfony/app/bootstrap.php .cache:2261
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/app/cache/pro_/appProdProje ctContaine_.php:7820
appProdProjectContaine_->getTwigService() at /var/www/nf-platform/symfony/app/bootstrap.php.cache:2261
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/app/cache/pro_/appProdProje ctContaine_.php:3908
appProdProjectContaine_->getMailManagerService() at /var/www/nf-platform/symfony/app/bootstrap.php.cache:2261
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/app/cache/pro_/appProdProje ctContaine_.php:2025
appProdProjectContaine_->getFei_DoctrineListener_UserService() at /var/www/nf-platform/symfony/app/bootstrap.php.c ache:2261
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/app/cache/pro_/appProdProje ctContaine_.php:1235
appProdProjectContaine_->getDoctrine_Dbal_DefaultConnectionService() at /var/www/nf-platform/symfony/app/bootstrap .php.cache:2261
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/app/cache/pro_/appProdProje ctContaine_.php:1349
appProdProjectContaine_->getDoctrine_Orm_DefaultEntityManagerService() at /var/www/nf-platform/symfony/app/bootstr ap.php.cache:2261
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/ Symfony/Bridge/Doctrine/ManagerRegistry.php:35
Symfony\Bridge\Doctrine\ManagerRegistry->getService() at /var/www/nf-platform/symfony/vendor/doctrine/common/lib/D octrine/Common/Persistence/AbstractManagerRegistry.php:231
Doctrine\Common\Persistence\AbstractManagerRegistry->getManagers() at /var/www/nf-platform/symfony/vendor/symfony/ symfony/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php:49
Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer->warmUp() at /var/www/nf-platform/symfony/vendor/symfony/symf ony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:48
Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() at /var/www/nf-platform/symfony/app/bootst rap.php.cache:2775
Symfony\Component\HttpKernel\Kernel->initializeContainer() at /var/www/nf-platform/symfony/app/bootstrap.php.cache :2542
Symfony\Component\HttpKernel\Kernel->boot() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/Symfony/Bun dle/FrameworkBundle/Command/CacheClearCommand.php:134
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at /var/www/nf-platform/symfony/vendor/symfony/ symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:96
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at /var/www/nf-platform/symfony/vendor/symfony /symfony/src/Symfony/Component/Console/Command/Command.php:241
Symfony\Component\Console\Command\Command->run() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/Symfon y/Component/Console/Application.php:861
Symfony\Component\Console\Application->doRunCommand() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/S ymfony/Component/Console/Application.php:193
Symfony\Component\Console\Application->doRun() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/Symfony/ Bundle/FrameworkBundle/Console/Application.php:84
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/nf-platform/symfony/vendor/symfony/symfony /src/Symfony/Component/Console/Application.php:117
Symfony\Component\Console\Application->run() at /var/www/nf-platform/symfony/app/console:27
cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [-- ansi] [--no-ansi] [-n|--no-interaction] [-s|--shell] [--process-isolation] [-e|--env ENV] [--no-debug] [--] <comman d>
In my experience with Symfony I find that in some cases the cache:clear command isn't enough. Sometimes I have to clear the cache completely at file system level. Use one of the following commands instead (assuming you're in a Unix like environment).
For Symfony 2.x:
rm -rf ./app/cache/*
For Symfony 3.x and 4.x:
rm -rf ./var/cache/*
If you had any .gitkeep files in there you'll need to touch them again before committing.
You should not need to run cache:clear again after doing this, as Symfony will warm up a brand new cache on your first application request. Expect your first request to take noticeably longer to process though. (10-20 seconds can be expected depending on your app.)
About the circular reference specifically I'd suggest you have two custom service classes both of which have the Symfony service container injected into them, then try to reference each other via $this->container->get('the_other_service')->whatever();.
As of Symfony 4.0 this is no longer supported, forcing you to use dependency injection instead. (Service classes should no longer have the service container injected into them, as tempting and easy as it may appear.) -- I know the struggle this can be particularly when upgrading from Symfony 2.x or 3.x, but we're told it's for the best.

Updated composer.json, now PHP autoload does not work. PHPUnit cannot find my classes

I am a user of the EWZSearchBundle and want to update it to work with Symfony 3.x
Updating the composer.json file should be easy, but I don't manage to get the unit tests running.
Here is the link to my fork of the bundle with some "improvements": link to commit
When I run the phpunit tests, I get the following error:
$ vendor/bin/phpunit Tests/Lucene/FieldTest.php
PHPUnit 5.7.26 by Sebastian Bergmann and contributors.
PHP Fatal error: Call to undefined method Zend\Search\Lucene\Document\Field::getType() in /tmp/azine/EWZSearchBundle/Tests/Lucene/FieldTest.php on line 18
PHP Stack trace:
PHP 1. {main}() /tmp/azine/EWZSearchBundle/vendor/phpunit/phpunit/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /tmp/azine/EWZSearchBundle/vendor/phpunit/phpunit/phpunit:52
PHP 3. PHPUnit_TextUI_Command->run() /tmp/azine/EWZSearchBundle/vendor/phpunit/phpunit/src/TextUI/Command.php:116
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /tmp/azine/EWZSearchBundle/vendor/phpunit/phpunit/src/TextUI/Command.php:186
PHP 5. PHPUnit_Framework_TestSuite->run() /tmp/azine/EWZSearchBundle/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:517
PHP 6. PHPUnit_Framework_TestCase->run() /tmp/azine/EWZSearchBundle/vendor/phpunit/phpunit/src/Framework/TestSuite.php:733
PHP 7. PHPUnit_Framework_TestResult->run() /tmp/azine/EWZSearchBundle/vendor/phpunit/phpunit/src/Framework/TestCase.php:868
PHP 8. PHPUnit_Framework_TestCase->runBare() /tmp/azine/EWZSearchBundle/vendor/phpunit/phpunit/src/Framework/TestResult.php:686
PHP 9. PHPUnit_Framework_TestCase->runTest() /tmp/azine/EWZSearchBundle/vendor/phpunit/phpunit/src/Framework/TestCase.php:913
PHP 10. ReflectionMethod->invokeArgs() /tmp/azine/EWZSearchBundle/vendor/phpunit/phpunit/src/Framework/TestCase.php:1062
PHP 11. EWZ\Bundle\SearchBundle\Tests\Lucene\FieldTest->testGetType() /tmp/azine/EWZSearchBundle/vendor/phpunit/phpunit/src/Framework/TestCase.php:1062
Steps to reproduce:
$ git clone git#github.com:azine/EWZSearchBundle.git
$ cd EWZSearchBundle
$ composer install
$ vendor/bin/phpunit Tests/Lucene/FieldTest.php
The cause of this error is, that the EWZ\Bundle\SearchBundle\Lucene\Field class is not (properly) autoloaded, but the Zend\Search\Lucene\Document\Field from the vendor directory is autoloaded but doesn't have that method.
Can anyone tell me why the autoloading of the classes in the namespace EWZ\Bundle\SearchBundle from the root directory does not work?
All help is highly appreciated.
The class is properly autoloaded. The problem is with the code itself.
When you're initiating a $binaryField by code
$binaryField = Field::Binary('Binary', 'value');
the result is of class \Zend\Search\Lucene\Document\Field, not of \EWZ\Bundle\SearchBundle\Lucene\Field.
Because it executes
return new self($name, $value, '', true, false, false, true);
inside of \Zend\Search\Lucene\Document\Field, and this runs a constructor of \Zend\Search\Lucene\Document\Field, not your extended class.

Codeception 'Undefined variable output' when trying to run a unit test

When attempting to run a simple unit test, as follows
// tests
public function testMe()
{
$this->assertEquals(1+1, 2);
}
I get the following error:
PHP Notice: Undefined variable: output in phar://C:/bin/codecept.phar/src/Codeception/Lib/Parser.php on line 129
PHP Stack trace:
PHP 1. {main}() C:\bin\codecept.phar:0
PHP 2. require_once() C:\bin\codecept.phar:7
PHP 3. Codeception\Application->run() phar://C:/bin/codecept.phar/codecept:36
PHP 4. Symfony\Component\Console\Application->run() phar://C:/bin/codecept.phar/src/Codeception/Application.php:103
PHP 5. Symfony\Component\Console\Application->doRun() phar://C:/bin/codecept.phar/vendor/symfony/console/Application.php:117
PHP 6. Symfony\Component\Console\Application->doRunCommand() phar://C:/bin/codecept.phar/vendor/symfony/console/Application.php:186
PHP 7. Symfony\Component\Console\Command\Command->run() phar://C:/bin/codecept.phar/vendor/symfony/console/Application.php:815
PHP 8. Codeception\Command\Run->execute() phar://C:/bin/codecept.phar/vendor/symfony/console/Command/Command.php:256
PHP 9. Codeception\Command\Run->runSuites() phar://C:/bin/codecept.phar/src/Codeception/Command/Run.php:256
PHP 10. Codeception\Codecept->run() phar://C:/bin/codecept.phar/src/Codeception/Command/Run.php:329
The line in question, 129 in Parser.phpis the following:
public static function validate($file)
{
$config = Configuration::config();
if (empty($config['settings']['lint'])) { // lint disabled in config
return;
}
exec("php -l ".escapeshellarg($file)." 2>&1", $output, $code);
if ($code !== 0) {
throw new TestParseException($file, implode("\n", $output));
}
}
The line 129 is exec("php -l ".escapeshellarg($file)." 2>&1", $output, $code);
I have tried googling around, and couldn't find any one else with the issue. This is in a completely "empty" php project, with only this unit test. I installed Codeception with composer.
I created the test as follows:
codecept generate:test unit Example
filled in the above and
codecept run unit
Codeception version: 2.2.2
Php version: 5.6.21
Ok I found more information, namely here:
https://github.com/Codeception/Codeception/issues/3324
It seems that this is a very new problem with version "2.2.*"
The possible solutions are:
Disable linting
Insert
settings:
lint: false
Into the codeception.yaml file.
Downgrade
Since validation is introduced in version 2.2, downgrading to the latest version (2.1.11) should also fix the issue according to the devs.

PHP / Composer cannot redeclare

I was happily working away in my development environment and suddenly I started getting the following error:
PHP Fatal error: Cannot redeclare composerRequire7a368ac394ae1d2e857becf2a235ebaa() (previously declared in [APP_ROOT]/vendor/composer/autoload_real.php:56) in [APP_ROOT]/vendor/composer/autoload_real.php on line 59
I haven't made any changes to speak of in composer dependencies (although I think I did do a composer update somewhere in that timeframe but no changes to the dependencies/packages used so nothing big should have changed.
Notably, when I checkout the repo on my laptop I do NOT get this error but if I git clone a clean repo and then composer install on my main development machine I DO get this error. So I'm assuming it must have some machine-specific origin but I'm running out of ideas on what that might be.
Any help would be greatly appreciated.
Note: I'm running PHP 5.3.28 on OSX; my app uses namespacing and is PSR0 compliant
Also of note is that I'm running PHPUnit 4.0.17 and the error is triggered at the very first stages of trying to run a unit test (it doesn't matter WHICH unit test). Here's the stack trace:
0.0009 636648 1. {main}() [APP_BASE]/vendor/phpunit/phpunit/phpunit:0
0.0465 1423664 2. PHPUnit_TextUI_Command::main() [APP_BASE]/vendor/phpunit/phpunit/phpunit:54
0.0465 1424280 3. PHPUnit_TextUI_Command->run() [APP_BASE]/vendor/phpunit/phpunit/src/TextUI/Command.php:132
0.0465 1424280 4. PHPUnit_TextUI_Command->handleArguments() [APP_BASE]/vendor/phpunit/phpunit/src/TextUI/Command.php:141
0.0674 2123344 5. PHPUnit_TextUI_Command->handleBootstrap() [APP_BASE]/vendor/phpunit/phpunit/src/TextUI/Command.php:638
0.0681 2139872 6. PHPUnit_Util_Fileloader::checkAndLoad() [APP_BASE]/vendor/phpunit/phpunit/src/TextUI/Command.php:808
0.0681 2140008 7. PHPUnit_Util_Fileloader::load() [APP_BASE]/vendor/phpunit/phpunit/src/Util/Fileloader.php:77
0.0774 2144176 8. include_once('[APP_BASE]/tests/test-loader.php') [APP_BASE]/vendor/phpunit/phpunit/src/Util/Fileloader.php:93
0.0775 2146736 9. include('[APP_BASE]/vendor/autoload.php') [APP_BASE]/tests/test-loader.php:2
Delete composer.lock and vendor/ and run composer update again.
I had this problem when I made a copy of an existing project directory and tried to run phpunit on the new directory. Finally figured out that when I executed phpunit, it was running out of the old directory. I ran this:
which phpunit
And saw that it was running from my composer vendor directory:
/home/vagrant/Code/MYOLDPROJECT/api/vendor/bin/phpunit
I ran phpunit from the new directory and the problem disappeared:
/home/vagrant/Code/mynewproject/api/vendor/bin/phpunit

How can i get phpunit to run tests from all files in a folder?

From what I've read, it seems like I should be able to set up a folder, e.g. tests/ , put a few files in it with unit test classes, and then run phpunit on that file and have it find and run the tests.
For whatever reason, in my installation (on OS X), it thinks the folder tests/ is a file, or so it would seem:
$ ls tests
test1.php test2.php
$ phpunit tests/test1.php
PHPUnit 3.5.3 by Sebastian Bergmann.
F
Time: 0 seconds, Memory: 5.00Mb
There was 1 failure:
1) FailingTest::testFail
Your test successfully failed!
/Users/****/tmp/tests/test1.php:4
FAILURES!
Tests: 1, Assertions: 0, Failures: 1.
$ phpunit tests/test2.php
PHPUnit 3.5.3 by Sebastian Bergmann.
.
Time: 0 seconds, Memory: 5.00Mb
OK (1 test, 1 assertion)
$ phpunit tests
PHP Fatal error: Uncaught exception 'PHPUnit_Framework_Exception' with message 'Neither "tests.php" nor "tests.php" could be opened.' in /usr/local/PEAR/PHPUnit/Util/Skeleton/Test.php:102
Stack trace:
#0 /usr/local/PEAR/PHPUnit/TextUI/Command.php(157): PHPUnit_Util_Skeleton_Test->__construct('tests', '')
#1 /usr/local/PEAR/PHPUnit/TextUI/Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#2 /usr/local/bin/phpunit(53): PHPUnit_TextUI_Command::main()
#3 {main}
thrown in /usr/local/PEAR/PHPUnit/Util/Skeleton/Test.php on line 102
Fatal error: Uncaught exception 'PHPUnit_Framework_Exception' with message 'Neither "tests.php" nor "tests.php" could be opened.' in /usr/local/PEAR/PHPUnit/Util/Skeleton/Test.php:102
Stack trace:
#0 /usr/local/PEAR/PHPUnit/TextUI/Command.php(157): PHPUnit_Util_Skeleton_Test->__construct('tests', '')
#1 /usr/local/PEAR/PHPUnit/TextUI/Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#2 /usr/local/bin/phpunit(53): PHPUnit_TextUI_Command::main()
#3 {main}
thrown in /usr/local/PEAR/PHPUnit/Util/Skeleton/Test.php on line 102
I have what I hope is a fairly standard installation of phpunit via PEAR, following these instructions http://www.newmediacampaigns.com/page/install-pear-phpunit-xdebug-on-macosx-snow-leopard, on OS X Snow Leopard.
$ pear version
PEAR Version: 1.9.1
PHP Version: 5.3.2
Zend Engine Version: 2.3.0
Running on: **** 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386
$ phpunit --version
PHPUnit 3.5.3 by Sebastian Bergmann.
I'm hoping someone else out there ran into this issue and it's just a simple fix, or else I'm just doing something wrong?
It is not a bug, it is a feature.
You have a directory full of .php files, in your case they all contain testcases.
But as your testsuite grows, you will likely want to have other php files inside tests directory, files that do not contains tests, that exist solely to support tests. Those files should never be executed by PHPUnit itself.
This is a very common scenario.
So how would PHPUnit know which files it needs to run and which ones not?
Checking the file name suffix is one option for doing it - by default PHPUnit considers everything with name ending with Test.php as being a test and ignores everything else.
You can change that behaviour if you really want to - by creating a file named phpunit.xml in your tests directory with the following content
<?xml version="1.0" encoding="utf-8" ?>
<phpunit>
<testsuite name='Name your suite'>
<directory suffix='.php'>./</directory>
</testsuite>
</phpunit>
Once you have done that, PHPUnit will run all files with '.php' at the end of the file name
(in this context file extension is considered to be part of the file name)
But it really is better to get used to the convention and name your tests accordingly.
The simpler way to running test on folder is to add "Test.php" at the end all of your tests and run phpunit specifing your folder like this
phpunit .
or
phpunit your_test_folder/.
Annoying little quirk, but I figured it out.
At least with the default configuration, test files have to end with "Test.php", eg. fooTest.php, or they are not found by the test runner.

Categories