Hello guys,

First of all, has anybody written unit tests for MongoDB document
objects?. I've been playing around with Symfony2 and MongoDB and I've
had problems when running unit tests for Mongo.

Basically I have a test in myBundle/Tests/Document/UserTest.php

class UserTest extends \Doctrine\ODM\MongoDB\Tests\BaseTest
{
    // stuff...
    public function testAdding()
    {
        foreach ($this->testData as $email => &$data)
        {
            $user = new User();
            $user->setEmail($email);
            $this->dm->persist($user);
        }

        $this->dm->flush();

        $this->assertTrue();
    }
}

The first problem that I faced was the availability of BaseTest, I had
to add (ugly, just while I figure out what's going on):

require_once __DIR__ . '/../../../../vendor/doctrine-mongodb-odm/tests/
bootstrap.php';

And then in vendor/doctrine-mongodb-odm/tests/bootstrap.php, I
replaced this line:
require_once __DIR__ . '/../lib/vendor/doctrine-common/lib/Doctrine/
Common/ClassLoader.php';
for
require_once __DIR__ . '/../../doctrine-common/lib/Doctrine/Common/
ClassLoader.php';

Now I can use the namespace and the class BaseTest is reachable.
However, I get this error:

Class Application\myBundle\Document\User is not a valid document or
mapped super class

However, the document is valid 'cause it works on both production and
development environments.

I know this might happen when there is no a proper driver for mapping
or interpreting meta-tag annotations. However my config_test.yml looks
like:


doctrine_odm.mongodb:
    default_database: testing_db
    auto_generate_hydrator_classes: true
    auto_generate_proxy_classes: true
    mappings:
        WebsiteBundle: ~


Can somebody give me a hand on this? If you know the way to go to
solve it and there is a bug in the framework, just tell me that I'll
fix it and and I'll commit it or send a patch.

Cheers!

Mauricio.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to