I am trying to get PHPUnit (for TDD) working with CodeIgniter.
A perfectly reasonable guide that I am following is here: http://www.jamesfairhurst.co.uk/posts/view/codeigniter_phpunit_and_netbeans
But the problem I am getting is this:
c:\projects\project1\tests>phpunit .
Fatal error: Call to undefined function get_instance() in c:\....\PostTest.php on line 7
which almost sounds like my whole CodeIgniter framework is not being seen.
I've modified the bootstrap.php file to have an explicit path to the system and application folders, just to be sure that it's not something simple like that. But no luck.
What does get_instance depend on to run? It's part of the core CodeIgniter framework.
I got the same error.
The problem is in the file phpunit.xml
You need to place it on
c:\projects\project1\tests>
and you need to create the file bootstrap.php as on your link :
http://www.jamesfairhurst.co.uk/posts/view/codeigniter_phpunit_and_netbeans
that's how your tests connect to your codeigniter
Related
I have an _ide_helper.php file in the root of my project, that Codeception is picking up, ignoring code to tell it not to, and leading to an error:
PHP Fatal error: Cannot redeclare class App (in _ide_helper.php)
Is it possible to force Codeception to not look at this file?
The underlying issue ended up being the way Codeception was handling Laravel defaults
hi i am running someone Else's code based on Yii.I tried to run it but i found the error.
Fatal error: Class 'YumUserController' not found in C:\wamp\www\msl\framework\YiiBase.php on line 204And also it displays html/php content,can any one please suggest me what the actual issue occurring.I have installed yii in my /www/yii/, and in yii folder i put my framework along with the project file in www/yii/framework,and my project
I am a newbie with phpunit but I need it to test something
So, suppose that have the following folders
mainFolder/SRC/x/y/sourceFiles.php
mainFolder/TESTS/x/y/testFiles.php
mainFolder/TESTS/bootstrap.php
When I run phpunit mainFolder it tells me:
Fatal error: Class 'x/y/sourceFile' not found in mainfolder/tests/x/y/testfile.php on line 28
Note that I am a newbie, and I need some help.
Thanks
The test files should be able to find the tested classes. Which means you have to require them, or set up a proper autoloading mechanism or pre-load them in a bootstrap file. And probably there are lots of other ways to do this. The test files behave exactly the same in this sense like simple php files.
I'm struggling to get the Yii crud tool to work for me. I'm using Gii and this is the error I'm getting in my log file:
PHP Fatal error: Cannot redeclare class CController in /var/www/includes/framework/web/CController.php on line 77
These are the only steps I have taken:
1) Downloaded yii and extracted 'framework' into /var/www/includes
1.5) Created a table called me in my database [EDIT]
2) Executed /var/www/framework/yiic webapp /var/www/web
3) uncommented 'gii'=>array(....) in config/main.php
3.5) Added my database configurations [EDIT]
4) Browsed to http:///index.php?r=gii
5) Navigated through Model generator to create 'me'
6) Navigated through Crud generator using me
7) Browsed to http:///index.php?r=me
Any ideas? I've spent ages on this and now I'm rather annoyed. :(
Thanks for your help in advance.
It looks like you have the framework in /var/www/framework/ AND /var/www/includes/framework/. Thus it is being included twice and you get an error that you are declaring the class twice. Remove the second copy from the /includes folder and stick with the one in /www. It's also best practice to make sure your framework folder is not accessible from the web.
I'm not sure why this worked but it did.
I simply renamed the framework directory to yii and it worked. I did nothing else.
This has confused me but at least it now works.
Greetings,
I've encountered a seemingly bizarre issue, and was wondering if anyone is able to shed a light.
I created a simple controller two levels down from the traditional /application/controllers/ directory and I'm seeing a CI-generated 404 when hitting said controller.
To elaborate, my directory structure is as follows:
/ci/application/controllers/dir1/dir2/myfile.php
The file itself has a simple function with an echo statement. When I move said file up one level such that it is located in:
/ci/application/controllers/dir1/myfile.php
It works.
I've tried changing the name of the "dir2" directory in the example above, the name of the controller, the names of the functions within the controller -- to no avail. I'm able to hit the same php file without going through the Code Igniter framework, and I'm on a Windows machine working normally so I can't imagine this to be a permissions-related issue.
I'm led to think that CI simply isn't willing to go into the controllers directory more than one level. Is this possible, or am I missing something?
Try this out: http://glennpratama.wordpress.com/2009/10/20/multi-level-subfolder-for-controller-in-codeigniter/
Basically, you need to override the default codeigniter router with your own MY_Router class
"Out of the box", Codeigniter only supports a single level directory structure for Controllers.
There are ways to extend the default Router class to enable this feature.