2011-02-24 6 views
1

안녕 모두,phpunit을 + 교리 + 버전 관리 + ZF 버그

내가 설정을 '주소'테이블에 대한 버전 관리 행동을했습니다,하지만 난 phpunit을 테스트를 실행하기 위해 노력하고있어 때 오류 다음 가지고 :

SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction

내 testcase에는 2 가지 'test *'메소드가 있습니다. 1을 남겨두면 1보다 크면 오류가 발생합니다. DbTestCase {

protected $object; 

protected function setUp() 
{ 
    // zf bootstrap here and doctrine connect 
    parent::setUp(); 

    // clean/create tmp tables 
    $this->_prepareDB(); 
    $this->object = new User; 
} 

public function testGetFullUsername() 
{ 
    $model = new User; 
    $model->email  = $email . time(); 
    ... 

    $model->Supplier->Address->firstname = $first_name; 
    $model->Supplier->Address->lastname = $last_name; 
    ... 
    $model->UserRight[0]->role  = 'Supplier'; 
    $model->UserRight[0]->resource = '*'; 
    $model->UserRight[0]->privilege = ''; 
    $model->save(); 
} 
// it can be even the same 
public function testRoles() 
{ 
    $model = new User; 
    $model->email  = $email . time(); 
    ... 

    $model->Supplier->Address->firstname = $first_name; 
    $model->Supplier->Address->lastname = $last_name; 
    ... 
    $model->UserRight[0]->role  = 'Supplier'; 
    $model->UserRight[0]->resource = '*'; 
    $model->UserRight[0]->privilege = ''; 
    $model->save(); 
} 

}

phpunit을 종료 번째 방법 거래를 실행하고 시작 다른

클래스 UserTest 연장 :

// 1st method 
// thread id: 412 
START TRANSACTION 
INSERT INTO user (...) VALUES (...) 
INSERT INTO address (...) VALUES ('...') 
INSERT INTO address_version (...) VALUES (...) 
INSERT INTO supplier (...) VALUES (...) 
INSERT INTO user_right (...) VALUES (..) 
commit 

// 2nd method 
// thread id: 413 
START TRANSACTION 
INSERT INTO user (...) VALUES (...) 
INSERT INTO address (..) VALUES (...) 
// then new thread created (server disconnects), id: 414 

CONNECT [email protected] on xxxx__tmp_testing 
START TRANSACTION 
INSERT INTO address_version (...) VALUES (...) 
rollback 
rollback 
여기

는 코드

연결을 끊지 만 그 이유는 모르겠습니다. 'Versionable'동작을 제거하면 작동합니다!

도와 주시겠습니까? 난 정말 그것으로 스택하고있어 오류 이유 :(귀하의 관심을 끌기 위해

감사를 모르는

UPDATE :!.

이유는 "버전 지정"플러그인에 있던 우리는해야 phpunit을 테스트에 사용하지 않도록 : $ account-> Distributor-> 어드레싱> getListener() ->에서 SetOption ('장애인'TRUE); 버전 관리가이 문제를 해결 '주소'모델에 부착

답변

0

내가했다. 많은 REPLACE/INSERT-queries 문제.

phpunit에서 지속적인 연결을 초기화 할 때 문제를 해결할 수 있습니다.

// {{{ getConnection() 
/** 
* gets database connection 
*/ 
protected function getConnection() { 
    $pdo = new pdo("mysql:dbname=depage_phpunit;host=localhost", "root", "", array(
     \PDO::ATTR_PERSISTENT => true, 
    )); 

    return $this->createDefaultDBConnection($pdo, 'testdb'); 
} 
// }}} 
+0

이유는 - "versionable"플러그인입니다. $ account-> Distributor-> Address-> getListener() -> setOption ('disabled', true); 문제가 해결됩니다. – iexx