Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7848239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:07:55+00:00 2026-06-02T18:07:55+00:00

I currently test my CodeIgniter app with phpunit by using CIUnit (https://bitbucket.org/kenjis/my-ciunit). The problem

  • 0

I currently test my CodeIgniter app with phpunit by using CIUnit (https://bitbucket.org/kenjis/my-ciunit). The problem is that I have multiple controllers with the same name. I have a controller in the root controller directory named “Blog” and I have a controller called “Blog” in the controller/ajax/ directory.
The reason is to seperate all ajax requests from the main controller.

When I am running tests on both files, I get the following error:

PHP Fatal error: Cannot redeclare class Blog in …

Well, I am not suprised I am getting this error.

What are my options to resolve this?

  1. Prefix controllers in ajax directory with “ajax” (looks only a bit stupid url/ajax/ajax_blog)
  2. Use namespaces (I guess I need to namespace codeigniter too then)
  3. Create 3 seperate phpunit.xml files

This aren’t really solutions I am looking for. Do I have any other options? Is it somehow possible to run each testsuite seperatly, but still in one command? Can I “clean” objects between testsuites? Anything else?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:07:57+00:00Added an answer on June 2, 2026 at 6:07 pm

    There are no other options except those you mentioned, as it is impossible to “unload” class definitions in PHP.

    Naming two controllers the same is not a problem when you run CI normally, since only one controller is instantiated per request, but something that should be avoided.

    If it is just the ajax-url you don’t like, maybe override it in a route (in config/routes.php):

    $routes['ajax/blog'] = 'ajax/ajax_blog';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have written a small codeigniter test app that is currently running on my
We currently have a suite of integration tests that run via MbUnit test suites.
I am using the following configuration for NGinx currently to test my app :
I am currently using CodeIgniter. I am trying to write a function that can
I have action methods that do things like this: productTable.AddOrUpdate(viewModel.Account); I don't currently test
I have a controller index test that gets an ActiveRecord scope. The test currently
I currently use a block eval to test that I've set an attribute as
I am currently using XAMPP to test and Run my website on my Laptop.
I have a test driver program that launches a separate test server process. The
I'm currently writing a test script for our MLS( Multiple Listing System ) systems.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.