Welcome Guest, Not a member yet? Register   Sign In
PHP Fatal error: Class 'Controller' not found in PHPUnit for CodeIgniter using CIUnit
#1

[eluser]sidhartha[/eluser]
To integrate codeigniter with phpunit i use CIUnit from http://www.knollet.com/foostack/


after following all the steps mentioned in the site http://www.knollet.com/foostack/ i ran

'phpunit AllTests.php' in the tests folder from the command prompt. it runs well.


but when i want to run a test for a controller it produces the following error though my phpunit for general programmes(without mvc) works well.

PHP Fatal error: Class 'Controller' not found in /opt/lampp/htdocs/mytask/system/application/controllers/country.php on line 9


some one please help me. i have stopped here for more than 3 days
#2

[eluser]sidhartha[/eluser]
[quote author="sidhartha" date="1279654406"]To integrate codeigniter with phpunit i use CIUnit from http://www.knollet.com/foostack/


after following all the steps mentioned in the site http://www.knollet.com/foostack/ i ran

'phpunit AllTests.php' in the tests folder from the command prompt. it runs well.


but when i want to run a test for a controller it produces the following error though my phpunit for general programmes(without mvc) works well.

PHP Fatal error: Class 'Controller' not found in /opt/lampp/htdocs/mytask/system/application/controllers/country.php on line 9


some one please help me. i have stopped here for more than 3 days[/quote]


This problem was due to a wrong folder setting. Actually I auto generated the skeleton for a test class using netbean IDE. The generated test file CountryTest.php resided in system/application/tests/system/application/controllers as per PHPUnit.

However for CIUnit point of view it should have been placed in system/application/tests/controllers as country.php is a controller.

similarly for all the test files for models must be placed in system/application/tests/models folder and test files for libraries must be placed in system/application/tests/libs folder and so on in CIUnit.


To have it working, copy/cut the auto generated skeleton file for test and paste it in required folder.
#3

[eluser]2think[/eluser]
Thanks for the solution. It is often the case new users to Codeigniter post in the wrong forum and even if they do find a solution, fail to update the thread so others can benefit.

I'd like to suggest a tip so others could probably find/see your problem and solution: perhaps title your post with PHPUnit in the title? You could still have the error or whatever in the title but if someone is scanning the forum titles looking for PHPUnit, they may pass over it.

Thanks again for posting the solution
#4

[eluser]sidhartha[/eluser]
@2think Thanks for your suggestion to change the title. Do notice the change.


This post is for CodeIgniter users who tend to use PHPUnit.
#5

[eluser]2think[/eluser]
I never said YOU posted in the wrong forum, I said "It is often the case new users...post in the wrong forum and...fail to update the thread...".

What I meant was that you updated your thread and that you also took the time to make sure you were in the right forum.




Theme © iAndrew 2016 - Forum software by © MyBB