EllisLab text mark
Advanced Search
5 of 5
Need this?
Sure as hell. I’m craving for nice Tests 135
I’ll probably check it out once its sweet.. 21
Its suspicious - don’t trust what I didn’t code, but I’d copy paste some probably.. 2
Gee, CI Tests class not enough eh? sissy.. 3
Total Votes: 161
You must be a logged-in member to vote
Unit Testing with phpUnit (models+controllers+fixtures) - want it?
Posted: 29 July 2010 03:09 AM   [ # 61 ]   [ Rating: 0 ]
Joined: 2010-05-27
13 posts
sidhartha - 20 July 2010 10:15 AM

if i run ‘phpunit AllTests.php’ in tests directory (system/application/tests) it works fine. but the time when i run’phpunit ModelsAllTests.php’ inside the subdirectory of test i.e(system/application/tests/models) it shows some error. inmy case it is

PHP Warning:  require(/opt/lampp/htdocs/calculator/system/application/libraries/fooStack/fooBase/../../../../../../application/libraries/fooStack/fooBase/Common.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/calculator/system/application/libraries/fooStack/fooBase/CodeIgniter.php on line 39
PHP Fatal error:  require(): Failed opening required ‘/opt/lampp/htdocs/calculator/system/application/libraries/fooStack/fooBase/../../../../../../application/libraries/fooStack/fooBase/Common.php’ (include_path=’.:/opt/lampp/lib/php/PEAR:/root/PEAR’) in /opt/lampp/htdocs/calculator/system/application/libraries/fooStack/fooBase/CodeIgniter.php on line 39

what r the changes i need to do to overcome this?

i also want to know where should i write the test cases for a controller and a model respectively.

Finally I got it working. this problem was due to the wrong path setting in the

      application/libraries/fooStack/fooBase/index.php for $system_folder at line# 26 and for $application_folder at line # 43.

I am using fooStack v0.17 - for CI 1.7.2. in my case

$system_folder = “../../../../../system”; and

$application_folder = “application”;

This may save some hours for somebody who gets this problem.


Posted: 29 July 2010 03:25 AM   [ # 62 ]   [ Rating: 0 ]
Joined: 2010-05-27
13 posts
sidhartha - 21 July 2010 07:38 AM

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

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.

Posted: 21 October 2010 11:13 AM   [ # 63 ]   [ Rating: 0 ]
Joined: 2008-01-01
5 posts

Hello guys,

has someone tried the CIUnit with MatchBox?

I’m facing some problems regarding DB Class initialization and other libraries that are loading from the autoload config file.

Any ideas?

Posted: 21 October 2010 04:58 PM   [ # 64 ]   [ Rating: 0 ]
Joined: 2009-10-18
334 posts

CI is not designed to be unit-testable, so don’t waste your time trying.. If you need this you should try Symfony or Zend


Wallpapers and Images Site: Desktop Wallpapers

Posted: 31 December 2010 08:43 PM   [ # 65 ]   [ Rating: 0 ]
Joined: 2010-12-31
2 posts


I’m not sure if I’m the only one facing this issue. But how did you guys manage to modify the uri you are testing.

Let me explain it with an example.

I have profile pages,

http://example.com/profile/show/1/ => Shows profile of user_id 1
http://example.com/profile/show/2/ => Shows profile of user_id 2

Now, I need to test the profile pages. I was able to set up foostack, set the controller as profile and call the function show. But it looks like the uri functions return 0 and because of which, my phpunit tests are failing.

I tried to set the $_SERVER like

$_SERVER[‘PATH_INFO’] = $_SERVER[‘REQUEST_URI’] = “profile/show/1/”;

But that also didn’t help much..

Any help in this direction is greatly appreciated.

Posted: 04 April 2011 05:08 AM   [ # 66 ]   [ Rating: 0 ]
Joined: 2010-01-27
14 posts

Hi everyone
I’m quite freshly new to TDD’s
I’m about to install Foostack
and was wondering if anyone had experience adding code coverage over it ?
and with which set up may I ask ?
is it truly added value to TDD’s ?


Posted: 05 April 2011 11:07 AM   [ # 67 ]   [ Rating: 0 ]
Joined: 2010-01-27
14 posts

I’ve installed fooStack with latest phpunit 3.5
there were some small changes easily repairable when following the logs
but I get this now , and can’t find a solution

Fatal error: Class 'foostack/fixture' not found in X:\X_Dev\ipm\www\system\application\libraries\Loader.php on line 1065 

if anyone has ever encountered this
I’d love an enlightment

Posted: 05 April 2011 03:28 PM   [ # 68 ]   [ Rating: 0 ]
Joined: 2010-01-27
14 posts

After numerous trial and fail
I gave and started moving files around

Tibor Katelbach - 05 April 2011 03:07 PM
Fatal error: Class 'foostack/fixture' not found in X:\X_Dev\ipm\www\system\application\libraries\Loader.php on line 1065 


so I moved Fixture.php one folder up inlibraries directly
which solved the error

I’m suspecting this might be linked to MatchBox (used on BEP) having changed the CI Loader

now, next issue :

Call to undefined method CI_Loader::viewfile

any ideas ?
I’d love to understand how the fooLoader.php works ?
since that’s where this file is

I feel like I’m redoing to whole process since 2 days :(
first was PEAR issue, then phpUnit, integration with CI
if anybody experienced this , I’d be glad to hear how it ended
I don’t really know if it’s goign to end somewhere

Posted: 06 April 2011 04:34 AM   [ # 69 ]   [ Rating: 0 ]
Joined: 2010-01-27
14 posts

Matchbox doesn’t work with foostack

After a hard fight with my initial set up (containing Matchbox)
I felt like a monkey jumping from error to error
and hidding them under the carpet hoping it’ll pass
This was not the right solution

I ended up , reinstalling a fresh CI, copied foostack in there
and it just worked

so now my question to the authors ,
would they feel the energy to help me get it working with MatchBox ?


Posted: 06 June 2011 10:41 AM   [ # 70 ]   [ Rating: 0 ]
Joined: 2011-03-11
10 posts

Tibor, did you ever get things running? I went through the same process of getting CIUnit linked up with CI2.0 and my project. Was not a pleasant experience. Once I got it running I decided I needed to implement an HMVC structure so I’m not about to get back to fixing the CIUnit/PHPUnit link to get my tests working again. I was wondering if you might have any pointers.

Posted: 31 October 2011 02:57 AM   [ # 71 ]   [ Rating: 0 ]
Joined: 2011-02-13
14 posts

It looks like the main repo for this project has stopped active development.

I found a few resources which everyone may find useful.

Good news! Looks like the next release of CI might include a PHPunit class

An active fork of the orignal repo:

5 of 5