Yii Framework Forum: Yii Unit Test Not Working ! - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii Unit Test Not Working !

#1 User is offline   amsandun 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 06-November 12
  • Location:Sri Lanka

Posted 07 November 2012 - 12:28 AM

Hi, I am following Agile Web Application Development with Yii 1.1 and PHP5.
In chapter 3, when I tried to go along with the unit testing example described, the following error came up in the command prompt.

C:\wamp\www\yiiprojects\demo\protected\tests>phpunit unit/MessageTest.php
PHPUnit 3.7.9 by Sebastian Bergmann.

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

But functional test example worked well for me. I tried re-installing phpunit and other dependencies many times.still no luck.

Can someone help? thanks.
0

#2 User is offline   Marek Surek 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 07-November 12

Posted 07 November 2012 - 12:36 PM

Try to change the file : 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

#3 User is offline   amsandun 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 06-November 12
  • Location:Sri Lanka

Posted 08 November 2012 - 09:09 AM

View PostMarek Surek, on 07 November 2012 - 12:36 PM, said:

Try to change the file : 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');



Hello Marek Surek,
Well, guess what.. it worked.
Thank you so much. I was searching all over the Internet for this and your solution did work.

It prints a large amount of code like a stack trace of the error in the console window. but when the code is error free it works really fine.

thanks for the support Marek. really appreciate it.
0

#4 User is offline   resurtm 

  • Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 83
  • Joined: 19-December 10

Posted 08 November 2012 - 09:11 AM

Dedicated PR in the Github: https://github.com/y...yii/issues/1563 (just linking with forum topic)
0

#5 User is offline   archman007 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 11-November 11

Posted 30 November 2012 - 02:36 PM

View Postamsandun, on 08 November 2012 - 09:09 AM, said:

Hello Marek Surek,
Well, guess what.. it worked.
Thank you so much. I was searching all over the Internet for this and your solution did work.

It prints a large amount of code like a stack trace of the error in the console window. but when the code is error free it works really fine.

thanks for the support Marek. really appreciate it.

This modification also works for PhPUnit 3.7.9!

Thanks Folks!
0

Share this topic:


Page 1 of 1
  • 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