Oscar Pérez
Oscar Pérez

Reputation: 4397

Fatal error: Call to undefined function file_iterator_autoload()

We are developping a Symfony2 project on which we wrote several PHPUnit tests.

On some of them (the ones involving large memmory ammounts) we get an error message:

There was 1 failure:

1) GapCoach\Bundle\Tests\Controller\ClientControllerTest::testDesaClient

Fatal error: Call to undefined function file_iterator_autoload() in /usr/share/php/PHPUnit/Util/GlobalState.php on line 379

I installed the last PHPUnit version, and file_iterator_autoload function really exists and is accessible.

How can we solve this error?

Upvotes: 1

Views: 2084

Answers (2)

brian_d
brian_d

Reputation: 11385

If you are using a machine that for one reason or another can not be immediately upgraded to have PHP 5.3.3 or above (which PHPUnit 3.7 requires), then you can fix this error by downgrading packages.

pear list -a should produce something like:

Installed packages, channel pear.phpunit.de:
============================================
Package            Version State
File_Iterator      1.3.3   stable
PHPUnit            3.6.12  stable
PHPUnit_MockObject 1.1.1   stable
PHP_CodeCoverage   1.1.4   stable
PHP_Timer          1.0.4   stable
PHP_TokenStream    1.1.4   stable
Text_Template      1.1.2   stable

You need the 1.3.2 version of File_Iterator, the 1.1.1 version of Text_Template, and the 1.0.3 version of PHP_Timer.

So uninstall the old:

pear uninstall phpunit/PHPUnit
pear uninstall phpunit/PHPUnit_MockObject
pear uninstall phpunit/PHP_CodeCoverage
pear uninstall phpunit/File_Iterator
pear uninstall phpunit/PHP_Timer
pear uninstall phpunit/PHP_TokenStream
pear uninstall phpunit/Text_Template

You should be able to verify that you have no phpunit packages installed:

pear list -a
Installed packages, channel pear.phpunit.de:
============================================
(no packages installed)

Now explicitly install these dependency versions first:

pear install phpunit/File_Iterator-1.3.2
pear install phpunit/PHP_Timer-1.0.3
pear install phpunit/Text_Template-1.1.1

Then PHPUnit:

pear install --alldeps phpunit/PHPUnit

pear list -a
Installed packages, channel pear.phpunit.de:
============================================
Package            Version State
File_Iterator      1.3.2   stable
PHPUnit            3.6.12  stable
PHPUnit_MockObject 1.1.1   stable
PHP_CodeCoverage   1.1.4   stable
PHP_Invoker        1.1.2   stable
PHP_Timer          1.0.3   stable
PHP_TokenStream    1.1.4   stable
Text_Template      1.1.1   stable

All should work now : )

Upvotes: 3

Oscar Pérez
Oscar Pérez

Reputation: 4397

The solution was just to upgrade PHPUnit to version 3.7.13

Upvotes: 2

Related Questions