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 8505265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:16:10+00:00 2026-06-11T02:16:10+00:00

I do some unit test in all my doctrine entities in a Symfony2 Project.

  • 0

I do some unit test in all my doctrine entities in a Symfony2 Project. I test setter/getter in a class UserTest and also setter/getter with db persistance in a class UserDbTest, all the files are in an Entity Folder under the test Folder
is it a good think to testing both, and what’s the best place to put the Db classes?

Thx for your advice!

  • 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-11T02:16:12+00:00Added an answer on June 11, 2026 at 2:16 am

    If you do not have custom database logic (which you should not have) in your Entity classes you don’t have to create unit and functional tests. Doctrine is tested, i.e. it is ensured that persist/flush work correctly and you do not have to duplicate these tests.

    However, if you want to test, for example, if your queries work correctly I personally have a XYManager class (where XY is the name of the entity), where I put all custom database logic (and further abstraction) in it. My approach was inspired by the FOSUserBundle (see their UserManager).

    In my projects both the Entity and the EntityManger classes are in the Entity folder of the bundle and the tests for these classes are in the Tests/Entity folder. Since functional tests take a lot longer than unit tests I separate them using the @group annotation of PHPUnit. I add @group unit to all tests that do not require a database and are not of WebTestCase and @group functional to all tests that do require a database or are of WebTestCase.

    If I want to execute only the unit tests I can do

    phpunit -c app/ --group unit`
    

    and

    phpunit -c app/ --group functional
    

    will only execute the functional tests.

    phpunit -c app/
    

    will execute both functional and unit tests.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing some unit test and I have a unit testing base class
Is it possible to write and run with Visual Studio 2008 some unit test
I have different projects written in .NET 3.5 and some unit test projects to
I am new to use moq. I am into creating some unit test case
I am trying to unit test some code, and I need to to replace
I'm having some difficulty writing some Unit Tests to test a custom ModelBinder that
I am trying to learn unit testing. I am trying to unit test some
I have some unit tests I've written to test my Django application. One test
I am having some trouble with writing a unit test that checks my custom
I'm using Google Test Framework to set some unit tests. I have got three

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.