fatal error 'File/Iterator/Autoload.php' not found when running phpunit

后端 未结 11 1214
滥情空心
滥情空心 2020-12-09 08:30

I am getting this error while i tried to run testclass in phpunit.

C:\\xampp\\htdocs\\unittest>phpunit UnitTest usertest.php
PHP Warning:  require_once(Fi         


        
相关标签:
11条回答
  • 2020-12-09 08:48

    I had the same issue with windows 7 and xampp(php 5.6.11), I tried all reinstalling pear and phpunit but it didn't work. When I checked the permission of the C:\xammp\php\pear directory it was read-only, After I changed the permission it started working.

    0 讨论(0)
  • 2020-12-09 08:50

    I am using Ubuntu 14.04 and I installed phpunit via Ubuntu Software Center which didn't work.

    Finally I remove it and I followed instructions from here

    wget https://phar.phpunit.de/phpunit.phar  
    chmod +x phpunit.phar  
    sudo mv phpunit.phar /usr/local/bin/phpunit
    
    0 讨论(0)
  • 2020-12-09 08:56

    Your phpunit installation is broken. The easiest fix for this is

    pear install --force --alldeps phpunit/phpunit
    

    and see if what worked out.

    You will need the most current pear version 1.9.4. If you don't have that version install it using the go-pear.phar. If you are running from xammp for something don't try to fix the pear installation they ship. Usually it's a LOT easier to reinstall it.

    If you want to you can try to just install the missing package too:

    pear install phpunit/File_Iterator
    

    (add a --force if pear tells you that it is already installed)

    0 讨论(0)
  • 2020-12-09 08:57

    For me the fix was simple (Ubuntu 12.04). First I did a search to make sure the file existed and where it was located:

    locate Autoload.php
    

    Which should return results similar to this:

    /usr/share/php/File/Iterator/Autoload.php
    /usr/share/php/PHP/CodeCoverage/Autoload.php
    /usr/share/php/PHP/Depend/Autoload.php
    /usr/share/php/PHP/Invoker/Autoload.php
    /usr/share/php/PHP/Timer/Autoload.php
    /usr/share/php/PHP/Token/Stream/Autoload.php
    /usr/share/php/PHPCPD/Autoload.php
    /usr/share/php/PHPUnit/Autoload.php
    /usr/share/php/PHPUnit/Framework/MockObject/Autoload.php
    /usr/share/php/PHP_CodeBrowser/Autoload.php
    /usr/share/php/Text/Template/Autoload.php
    

    Then I checked my include_path, which was set correctly in /etc/php5/apache2/php.ini, but was still commented out in /etc/php5/cli/php.ini (the command line interface).

    Uncommenting this line worked for me:

    include_path = ".:/usr/share/php:/usr/include/php5"
    

    Pretty basic I know, but it's always the little things when setting up a new machine ;-)

    0 讨论(0)
  • 2020-12-09 08:57

    Also, using open-server bundle one can notice that it reports way too short include_path.

    To fix this on Windows 7 you can do

    cd c:\Windows
    mklink php.ini c:\OpenServer\userdata\temp\config\php.ini
    
    0 讨论(0)
  • 2020-12-09 09:00

    All kind of nice things I have read on this one. First check where the Autoload.php is located. Use:

    $ find . -name 'Autoload.php' -type f
    

    I assume that your files are located in:

    /usr/local/pear/share/pear
    


    I have Apple OSX 10.8.4 MAMP and MAMP-PRO installed and I have several other PHP installations.
    For the last one I have done the following: First check if there is a php.ini in the directory: /private/etc
    If not, do:

    $ sudo cp /private/etc/php.ini.default /private/etc/php.ini
    

    Add the following lines at the bottom of the 'php.ini' file:

    ; *** Added by <your-name> ****
    include_path=".:/usr/local/pear/share/pear"
    ; *** Ended addition ****
    

    Done.

    0 讨论(0)
提交回复
热议问题