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

  • Home
  • SEARCH
  • 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 6468741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:55:05+00:00 2026-05-25T05:55:05+00:00

I have a symfony2 application and I’m using phpunit. I have some unit tests

  • 0

I have a symfony2 application and I’m using phpunit.

I have some unit tests where I use mocks to mock the AppKernel and functional tests which make “real” requests to the application. When running the unit tests or the functional tests alone, everything works fine.

It get’s nasty when I want to run all tests at once. As soon as the unit tests are finished, phpunit stops, telling me:


Fatal error: Cannot redeclare class AppKernel in C:\Users\sebastian\workspace\ppInterface\app\AppKernel.php on line 35

I don’t understand this, as I thought phpunit would run each test within it’s own environment. This seems to be not the case. What can I do to get things right and “reset” the environment in which the tests run?

  • 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-05-25T05:55:05+00:00Added an answer on May 25, 2026 at 5:55 am

    PHPUnit does not reset everything by default, although it’s possible.

    Includes – the problem in your case – are not resetted (and cannot in one single process). A solution would be to use require_once instead of require, or to use process isolation either in your phpunit.xml file or in the test case (@runTestsInSeparateProcesses) or test method (@runInSeparateProcess).

    You can also influence the what is resetted between tests:

    • @backupGlobals
    • @backupStaticAttributes
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an application using Symfony. I have some reusable components that I
I have a Symfony application which use a mysql database to store session data,
I am using jQuery in my Symfony2 application and I have a ReferenceError: jQuery
When using the ACL implementation in Symfony2 in a web application, we have come
I'm constructing an ecommerce application in Symfony, and I have a page which lists
I would like to ask about some advices, how to use Symfony2 SonataAdminBundle. I
I have developed an application in symfony which will have to be made live
I am an experienced Symfony user and have started using Symfony2 and absolutely love
I have an application written in symfony 1.4, and I'd like to use the
I have a Symfony 1.2.4 application, taken and modified from the Symfony sandbox application

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.