Note that there are some explanatory texts on larger screens.

plurals
  1. POPHPUnit + Doctrine + Versionable + ZF bug
    primarykey
    data
    text
    <p><strong>Hi everyone</strong>,</p> <p>I've setup the versionable behavior for 'Address' table, but when I'm trying to run PHPUnit tests i've got following error: </p> <blockquote> <p>SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction</p> </blockquote> <p>I have 2 'test*' methods on my testCase. If I leave only 1 then it works, if > 1 - then i gets that error.</p> <p>Here is the code:</p> <p>class UserTest extends DbTestCase {</p> <pre><code>protected $object; protected function setUp() { // zf bootstrap here and doctrine connect parent::setUp(); // clean/create tmp tables $this-&gt;_prepareDB(); $this-&gt;object = new User; } public function testGetFullUsername() { $model = new User; $model-&gt;email = $email . time(); ... $model-&gt;Supplier-&gt;Address-&gt;firstname = $first_name; $model-&gt;Supplier-&gt;Address-&gt;lastname = $last_name; ... $model-&gt;UserRight[0]-&gt;role = 'Supplier'; $model-&gt;UserRight[0]-&gt;resource = '*'; $model-&gt;UserRight[0]-&gt;privilege = ''; $model-&gt;save(); } // it can be even the same public function testRoles() { $model = new User; $model-&gt;email = $email . time(); ... $model-&gt;Supplier-&gt;Address-&gt;firstname = $first_name; $model-&gt;Supplier-&gt;Address-&gt;lastname = $last_name; ... $model-&gt;UserRight[0]-&gt;role = 'Supplier'; $model-&gt;UserRight[0]-&gt;resource = '*'; $model-&gt;UserRight[0]-&gt;privilege = ''; $model-&gt;save(); } </code></pre> <p>}</p> <p>When PHPunit runs the second method transactions ends and starts another one:</p> <pre><code>// 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 xxxxx@localhost on xxxx__tmp_testing START TRANSACTION INSERT INTO address_version (...) VALUES (...) rollback rollback </code></pre> <p>It drops the connection, but I don't know why. If I remove 'Versionable' behavior - then it works!</p> <p>Can You please help me. I'm really stack with it and don't know the error reason :(</p> <p>Thanks for Your attention!</p> <p><strong>UPDATE:</strong></p> <p>The reason was in "versionable" plugin. We have to disable it in phpunit tests: $account->Distributor->Address->getListener()->setOption('disabled', true); Versionable attached to 'Address' model It fixes the problem.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload