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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:01:54+00:00 2026-05-18T20:01:54+00:00

Whats the way to unit test Doctrine 2 models? I am using it with

  • 0

Whats the way to unit test Doctrine 2 models? I am using it with Zend Framework 1.11. It has Zend_Test which uses PHPUnit. I think the right thing to use is PHPUnit_Extensions_Database_TestCase. In Zend Framework, I can use Zend_Test_PHPUnit_Db. How can I modify the code to unit test Doctrine Models instead of Zend_Db classes.

1st, I think instead of using Zend_Db stuff, I have to use Doctrine’s stuff instead

class BugsTest extends Zend_Test_PHPUnit_DatabaseTestCase
{
    private $_connectionMock;

    protected function getConnection()
    {
        if($this->_connectionMock == null) {
            $connection = Zend_Db::factory(...);
            $this->_connectionMock = $this->createZendDbConnection(
                $connection, 'zfunittests'
            );
            Zend_Db_Table_Abstract::setDefaultAdapter($connection);
        }
        return $this->_connectionMock;
    }
    ...
}
  • 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-18T20:01:54+00:00Added an answer on May 18, 2026 at 8:01 pm

    I found DoctrineExtensions that has extensions for PHPUnit via ORMTestCase. Usage looks something like

    namespace MyProject\Tests;
    
    use DoctrineExtensions\PHPUnit\OrmTestCase
    
    class EntityFunctionalTest extends OrmTestCase
    {
        protected function createEntityManager()
        {
            return Doctrine\ORM\EntityManager::create(..);
        }
    
        protected function getDataSet()
        {
            return $this->createFlatXmlDataSet(__DIR__."/_files/entityFixture.xml");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the best way to unit test a method that doesn't return anything?
What is the best way to unit test a method that calls into multiple
Whats the best way to implement rollover 'buttons' like Stackoverflow has for 'Questions', 'Tags',
What's the best way to unit test an application accessing the ActiveDirectory and/or mock
I'd like to unit test a Perl program of mine that is using backticks.
We are using Moq to unit test our service classes, but are stuck on
I'm trying to use PHPUnit to unit test some class methods that return SQL.
I've been using Moq framework in c# for mocking in unit tests however there
I would like to know what would be the best way to do unit
Whats the best way to detect collisions in a 2d game sprites? I am

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.