PHPUnit + CodeIgniter multiple objects with the same name

I am currently testing the CodeIgniter application using phpunit using CIUnit (https://bitbucket.org/kenjis/my-ciunit). The problem is that I have several controllers with the same name. I have a controller in the root controller directory called "Blog", and I have a controller called "Blog" in the controller / ajax / directory. The reason is to separate all ajax requests from the main controller.

When I run tests for both files, I get the following error:

PHP Fatal error: unable to update Blog class in ...

Well, I'm not surprised, I get this error.

What are my solutions to this problem?

  • Prefix controllers in ajax directory with "ajax" (looks just a little dumb url / ajax / ajax_blog)
  • Use namespaces (in my opinion, I also need a namespace using codeigniter)
  • Create 3 separate phpunit.xml files

These are not the real solutions I'm looking for. Do I have any other options? Is it possible to somehow run each testuite separately, but still in the same command? Can I "clean" objects between testuites? Anything else?

0
source share
1 answer

There are no other options besides those that you mentioned as it is impossible to "unload" class definitions in PHP.

CI , , -, .

ajax-url, , , ( config/routes.php):

$routes['ajax/blog'] = 'ajax/ajax_blog';
+1

All Articles