zend framework - PHPUnit + Doctrine + Versionable + ZF bug -
hi everyone,
i've setup versionable behavior 'address' table, when i'm trying run phpunit tests i've got following error:
sqlstate[hy000]: general error: 1205 lock wait timeout exceeded; try restarting transaction
i have 2 'test*' methods on testcase. if leave 1 works, if > 1 - gets error.
here code:
class usertest extends dbtestcase {
protected $object; protected function setup() { // zf bootstrap here , 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(); } // can 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(); }
}
when phpunit runs second method transactions ends , starts one:
// 1st method // thread id: 412 start transaction insert user (...) values (...) insert address (...) values ('...') insert address_version (...) values (...) insert supplier (...) values (...) insert user_right (...) values (..) commit // 2nd method // thread id: 413 start transaction insert user (...) values (...) insert address (..) values (...) // new thread created (server disconnects), id: 414 connect xxxxx@localhost on xxxx__tmp_testing start transaction insert address_version (...) values (...) rollback rollback
it drops connection, don't know why. if remove 'versionable' behavior - works!
can please me. i'm stack , don't know error reason :(
thanks attention!
update:
the reason in "versionable" plugin. have disable in phpunit tests: $account->distributor->address->getlistener()->setoption('disabled', true); versionable attached 'address' model fixes problem.
i had same problem lot's of replace/insert-queries.
i workaround problem initializing persistent connections in 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'); } // }}}
Comments
Post a Comment