With further testiing, I've verified the following:

1. The Controller see's no tables at all. Printing the results of $em-
>getConnection()->getSchemaManager()->createSchema() in
testSomething() outputs the expected schema, whereas running the same
line in the action for /things/1.html outputs an empty schema.

2. The Controller and Test classes *are* using different connections.
Printing the results of spl_object_hash($em->getConnection()) in both
classes results in a different hash.

I'll continue to investigate further, but I'd still appreciate some
input if anyone has any helpful pointers.

Thanks.


On May 2, 3:40 pm, Donald <chekot...@gmail.com> wrote:
> I'm in the middle of upgrading my project to use Symfony 2 Beta 1,
> from it's current version of PR11, and I've run into a problem with
> the tests that I can't work out.
>
> I use pdo_sqlite for my tests, and create the schema in the setup
> method of each test. This would work fine in PR11, but in Beta 1,
> something has changed where the Client doesn't see the database that
> my Test created.
>
> Here's an example test:
>
> class MyTest extends WebTestCase {
>
>   protected function setUp() {
>     $this->client = $this->createClient();
>     $this->client->followRedirects(false);
>
>     $this->container = $this->kernel->getContainer();
>
>     $em = $this->container->get('doctrine.orm.entity_manager');
>
>     $tool = new SchemaTool($em);
>     $metaData = $em->getMetaDataFactory()->getAllMetaData();
>     $tool->createSchema($metaData);
>
>     $thing1 = new Thing();
>     $thing1->name = 'Bob';
>
>     $em->persist($thing1);
>     $em->flush();
>   }
>
>   public function testSomething() {
>     // just to demonstrate that the database and object *does* exist,
> this works:
>     $em = $this->container->get('doctrine.orm.entity_manager');
>     echo get_class($em->find('MyBundle:Thing', 1));
>
>     // This however, fails (assuming that the action at this URL will
> attempt to load Thing1)
>     $this->client->request('GET', sprintf('/things/1.html'));
>     $response = $this->client->getResponse();
>
>     // Response will be a stack trace stating "General error: 1 no
> such table: thing"
>     print_r($response);
>   }
>
> }
>
> I've updated all my config files with the new cleaner dbal
> configuration style, and as demonstrated by the fact that the fixtures
> and the first couple of lines of this test works, it is configured
> correctly.
>
> Can anyone point me in the direction of what changed to break this? It
> seems as if the MyTest and Client instances are not working from the
> same EntityManager and/or Connection.
>
> Thanks,
>
> Donald

-- 
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 symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to