Yii Framework Forum: Phpunit Not Working With Yii Ctestcase (Phpunit_Autoload Not Found) - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Phpunit Not Working With Yii Ctestcase (Phpunit_Autoload Not Found) Rate Topic: ***** 1 Votes

#21 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 258
  • Joined: 15-August 12

Posted 18 October 2012 - 12:43 PM

View Postmsoa, on 18 October 2012 - 12:22 PM, said:

I tired from install/remove packages and search in google. is anyone how to i can completely remove PEAR Packages? I am going to a fresh install from scratch.
PLEASE HELP

This is latest error:
phpunit unit/DbTest.php 
PHP Warning:  require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to open stream: No such file or directory in /var/www/yii/framework/test/CWebTestCase.php on line 12
PHP Fatal error:  require_once(): Failed opening required 'PHPUnit/Extensions/SeleniumTestCase.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/yii/framework/test/CWebTestCase.php on line 12


Solved
By downgrade to phpunit-3.7.1 solved. my instructions:
1- remove phpunit-3.7.* (with all of dependencies If required)
2- install phpunit-3.7.1 with all dependencies, make sure installed phpunit_selenium.
Goodluck
0

#22 User is offline   kory 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 28-June 12

Posted 05 November 2012 - 08:32 PM

phpunit unit/DbTest.php 
PHPUnit 3.7.6 by Sebastian Bergmann.

Function 'phpunit_autoload' not found (function 'phpunit_autoload' not found or invalid function name)


You can see the issue here: github.com/yiisoft/yii/issues/1563
and fixed in: github.com/yiisoft/yii/commit/5357ebe46dc00794e6b46f54843cff897b280ef0

You need to modify yii/framework/test/CTestCase.php
require_once('PHPUnit/Runner/Version.php');
require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
require_once('PHPUnit/Autoload.php');
if (in_array('phpunit_autoload', spl_autoload_functions())) { // PHPUnit >= 3.7 'phpunit_alutoload' was obsoleted
    spl_autoload_unregister('phpunit_autoload');
    Yii::registerAutoloader('phpunit_autoload');
}

0

#23 User is offline   Hesam 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 66
  • Joined: 12-November 12
  • Location:Toronto

Posted 12 November 2012 - 12:30 PM

View Postkory, on 05 November 2012 - 08:32 PM, said:

phpunit unit/DbTest.php 
PHPUnit 3.7.6 by Sebastian Bergmann.

Function 'phpunit_autoload' not found (function 'phpunit_autoload' not found or invalid function name)


You can see the issue here: github.com/yiisoft/yii/issues/1563
and fixed in: github.com/yiisoft/yii/commit/5357ebe46dc00794e6b46f54843cff897b280ef0

You need to modify yii/framework/test/CTestCase.php
require_once('PHPUnit/Runner/Version.php');
require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
require_once('PHPUnit/Autoload.php');
if (in_array('phpunit_autoload', spl_autoload_functions())) { // PHPUnit >= 3.7 'phpunit_alutoload' was obsoleted
    spl_autoload_unregister('phpunit_autoload');
    Yii::registerAutoloader('phpunit_autoload');
}



It worked for me, thanks.
0

#24 User is offline   Blizz 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 14-March 10

Posted 18 November 2012 - 05:20 PM

@msoa: That last one is just a missing dependency. All you have to do to fix that is install it (pear install phpunit/PHPUnit_Selenium). That being said, I really hope they come up with somekind of fix soon, because I really hate to have to modify stock code. It really messes with trying to stay up to date...


0

#25 User is offline   Jing Guo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 25-August 12

Posted 22 November 2012 - 11:55 PM

This issue is solved by modify the files "yii/framework/test/CTestCase.php"

check this issue at github.com:

Yii 1.1.12 CTestCase doesn't work with PHPUnit 3.7.7

github.com/yiisoft/yii/issues/1563

0

#26 User is offline   Ivo Renkema 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 20-April 12

Posted 09 May 2013 - 02:02 PM

It looks like you are in dead end, if you install PHPUnit.phar (3.7.19).

I tried this in CTestCase.php

require_once('phar://phpunit.phar/PHPUnit/Runner/Version.php');
require_once('phar://phpunit.phar/PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
require_once('phar://phpunit.phar/PHPUnit/Autoload.php');


This works for Version.php and Filesystem.php, but fails for Autoload.php with the error:

require_once(phar://phpunit.phar/Autoload.php): failed to open stream:


Does anybody know why? And how to fix this?
0

#27 User is offline   qxb 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 27-January 14

Posted 27 January 2014 - 01:39 AM

View PostIvo Renkema, on 09 May 2013 - 02:02 PM, said:

It looks like you are in dead end, if you install PHPUnit.phar (3.7.19).

I tried this in CTestCase.php

require_once('phar://phpunit.phar/PHPUnit/Runner/Version.php');
require_once('phar://phpunit.phar/PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
require_once('phar://phpunit.phar/PHPUnit/Autoload.php');


This works for Version.php and Filesystem.php, but fails for Autoload.php with the error:

require_once(phar://phpunit.phar/Autoload.php): failed to open stream:


Does anybody know why? And how to fix this?


Just open CTestCase.php and comment those 'require_once' lines:
//require_once('PHPUnit/Runner/Version.php');
//require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
//require_once('PHPUnit/Autoload.php');
1

#28 User is offline   al2357 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 13-May 14

Posted 13 May 2014 - 07:22 AM

View Postqxb, on 27 January 2014 - 01:39 AM, said:

Just open CTestCase.php and comment those 'require_once' lines:
//require_once('PHPUnit/Runner/Version.php');
//require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
//require_once('PHPUnit/Autoload.php');


For the past week I had the same problem. Commenting out these lines helped - thanks!

So are these 'require_once' libraries/files optional? You don't have use them but if you've installed them with PHPUnit they will load.
If so shouldn't they be commented out by default?
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users