2

I have a project on Cakephp 2.9.7. When I run test on my local machine I do not get any errors. But, when I try to run ./Console/cake test app Controller/AlarmsController or test any other controller in my docker image, which actually has the same PHPUnit version and Cakephp version, I get an error MissingControllerException: Controller class AlarmsControllerController could not be found. So, the word Controller in the controller name is being used twice. The problem happens in https://github.com/cakephp/cakephp/blob/2.next/lib/Cake/TestSuite/ControllerTestCase.php#L339 this function. So the error trace looks the following way:

/project/lib/Cake/TestSuite/ControllerTestCase.php:347
/project/lib/Cake/TestSuite/ControllerTestCase.php:362

So the error causes the call of getMock function(https://github.com/cakephp/cakephp/blob/2.next/lib/Cake/TestSuite/ControllerTestCase.php#L362). But I cannot undestand what happens there, and why it works on my local machine with equal conditions(PHPUnit, Cakephp version, the same project), but in the docker container I an get error.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
handkock
  • 1,067
  • 2
  • 11
  • 23
  • What if you try `./Console/cake test app Controller/Alarms` ? – Robert May 31 '17 at 13:41
  • @Robert, it iw not working, I get `Cannot open file "/project/app/Test/Case/Controller/AlarmsTest.php".`. The same one `./Console/cake test app Controller/AlarmsController` works on my local mashine. And the same error hapens when I try to test all the Controllers: `./Console/cake test app AllController`. – handkock May 31 '17 at 15:02
  • Random shot... You use Windows, Docker runs Linux and the controller file name has the wrong case? – Álvaro González May 31 '17 at 15:06
  • 1
    I use Linux, the docker image hast linux. All the versions are the same – handkock May 31 '17 at 15:09

1 Answers1

0

You must specify the controller name without the suffix Controller:

./Console/cake test app Controller/Alarms

Docs

Robert
  • 33,429
  • 8
  • 90
  • 94
  • it iw not working, I get `Cannot open file "/project/app/Test/Case/Controller/AlarmsTest.php".`. The same one `./Console/cake test app Controller/AlarmsController` works on my local mashine. And the same error hapens when I try to test all the Controllers: `./Console/cake test app AllController`. – handkock May 31 '17 at 15:01