【发布时间】:2012-01-19 04:17:39
【问题描述】:
我正在尝试使用 Doctrine ORM 为 Zend 创建带有 phpunit 的单元测试。当我尝试创建一个扩展 Zend_Test_PHPUnit_DatabaseTestCase 的测试类时,我在执行 PHPUnit 时收到一条消息:“没有打开的连接”
这里是完整的来源:
<?php
class AclTest extends Zend_Test_PHPUnit_DatabaseTestCase
{
private $_userAdmin;
public function setUp()
{
$this->bootstrap = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$this->_userAdmin = Model_UserTable::getInstance()->findOneByUsername('admin');
parent::setUp();
}
protected function getConnection()
{
$pdo = new PDO('mysql:host=localhost;dbname=mydbname', 'root', 'pwd');
return $this->createDefaultDBConnection($pdo, 'testdb');
}
protected function getDataSet()
{
return null;
}
public function testHasProfilPermission()
{
//execute some tests
}
}
你怎么看?
谢谢
【问题讨论】:
-
你运行的是什么版本? Zend Framework 1.x 不适用于最新的 PHPUnit 3.6。
-
我正在使用 Zend Framework 1.11.11、Doctrine 1.2.4、PHPUnit 3.4.14 和桥 ZFDoctrine
标签: zend-framework doctrine phpunit