1

I am trying to run PHPUnit test at CakePHP 2.0. There's no problem with my model tests but when i try to run my Controllers tests i get this error:

Fatal error: Class 'Controller' not found in `/Applications/MAMP/htdocs/mysite/app/Controller/AppController.php on line 7`

What's going on? Thanks.

1 Answer 1

4

you always need to properly define the used classes (which you want to extend) - even in your controllers:

App::uses('Controller', 'Controller');

class AppController extends Controller {}

you miss the App::uses statement.

Sign up to request clarification or add additional context in comments.

3 Comments

No, all controllers work well. I have that line in my code. The problem is only when i try to Test them with PHPUnit tests.
the controllers will always work well (from the application itself). so you are 100% sure that the App::uses() statement is in the app controller? and you don't use the Controller class itself before the AppController class is called? I am pretty sure that is your problem. You can work around by adding the same statement to your test case - at the very top. But it would be cleaner to fix the issue with the correct include order.
You are completely right Mark :) Thanks for all and sorry for my previous reply, i didn't read it well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.