News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Benjamin Eberlei's Blog:
Testing Database Locks with PHPUnit and Gearman
May 04, 2010 @ 09:10:51

Benjamin Eberlei has a new post today about how you can use PHPUnit tests to ensure that database locking is working like it should. With the help of Gearman he shows you how to use some locking tests for Doctrine setups to ensure rows locked for a specific amount of time are staying that way.

Since PHP does not support process forking or threads naturally you run into a serious problem. How do you execute two database queries in parallel and verify that indeed one query is locking read access for the second one? [...] Solving this problem with Gearman provides a pretty nice "real-world" example for the Job-Server that I wanted to share.

He includes the code to make a sample "agent" to run a transaction and lock a certain set of information. On the other side, there's the worker method that loops to find the locked items until they disappear. The PHPUnit tests case combines these in a "testLockIsAcquired" with a handler for the completed test.

1 comment voice your opinion now!
phpunit unittest database lock tutorial gearman


blog comments powered by Disqus

Similar Posts

DevShed: Cleaning up Array Elements, POST and GET Requests with Filters in PHP 5

NetTuts.com: Relational Databases for Dummies

WeberDev.com: User Authentication with patUser (Part 3)

Sebastian Bergmann\'s Blog: PHPUnit Talk at PHP Usergroup Dortmund

SitePoint.com: Advanced PHPUnit Testing: Annotations and Mocking


Community Events





Don't see your event here?
Let us know!


symfony interview unittest introduction conference release community composer series list api threedevsandamaybe podcast opinion language laravel framework configure version voicesoftheelephpant

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework