필자는 PHPUnit DataBase를 사용하여 MDB2를 사용하여 일부 클래스를 테스트합니다.PHPUnit 데이터베이스로 MDB2를 사용하여 여러 테스트를 수행하는 방법은 무엇입니까?
모두는 잘 나는 오류를 반환 두 번째 테스트, 발생 이후 : 내가 처음 한 자리에 두 번째 테스트를 배치 할 때
Caught exception: Object of class MDB2_Error could not be converted to string
, 새로운 첫 번째 테스트는 OK입니다 만, 두 번째 하나는 같은 오류를 반환합니다! 다음 것들도!
MDB2 연결이 첫 번째 테스트 후에 닫힙니까?
public function __construct()
{
$this->pdo = new PDO('connectionstring', 'user', 'passwd');
try {
$this->mdb2 = new MyDBA($this->dsn);
}
catch (Exception $e) {
error_log(' __construct Caught exception: '.$e->getMessage());
}
}
MyDBA이 싱글을 반환
여기 내 생성자입니다. 예외는 여기에
는이 개 첫 번째 시험이다 ... 생성자 내부에서 발생하지 않습니다 :public function testTranslationAdd()
{
try {
$id = $this->mdb2->addTranslation("This is the second english translation.","en");
}
catch (Exception $e) {
error_log(' testTranslationAdd Caught exception: '.$e->getMessage());
}
$xml_dataset = $this->createFlatXMLDataSet(dirname(__FILE__).'/state/twotranslations.xml');
$this->assertDataSetsEqual($xml_dataset,
$this->getConnection()->createDataSet(array("translation")));
}
public function testTranslationGet()
{
try {
$text = $this->mdb2->getTranslation(1,"en");
}
catch (Exception $e) {
error_log(' testTranslationGet Caught exception: '.$e->getMessage());
}
$this->assertEquals("This is the first english translation.",$text);
}
나는 예외가 어디에서 던져 질까요? – james