/** * @return \Doctrine\DBAL\Connection */ private function mockDoctrineConnection() { $doctrineMySqlPlatformMock = new \mock\Doctrine\DBAL\Platforms\MySqlPlatform(); $this->mockGenerator()->orphanize('__construct'); $doctrineConnectionMock = new \mock\Doctrine\DBAL\Connection(); $doctrineConnectionMock->getMockController()->getDatabasePlatform = $doctrineMySqlPlatformMock; $doctrineConnectionMock->getMockController()->exec = null; $doctrineConnectionMock->getMockController()->executeUpdate = null; return $doctrineConnectionMock; }
public function beforeTestMethod($testMethod) { $this->mockGenerator->shuntParentClassCalls(); $this->mockGenerator->orphanize('__construct'); $pdo = new \mock\PDO(); $this->mockGenerator->orphanize('__construct'); $db = new \mock\Doctrine\DBAL\Connection(); $db->getMockController()->connect = function () { }; $db->getMockController()->getEventManager = function () { return new EventManager(); }; $db->getMockController()->getDatabasePlatform = function () { return new MySqlPlatform(); }; $this->mockGenerator->unshuntParentClassCalls(); $config = Setup::createYAMLMetadataConfiguration([TEST_DATA_DIR . '/doctrine-orm'], true); $this->connection = EntityManager::create($db, $config); }