News Feed
Sections




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

Sebastian Bergmann's Blog:
Sharing Fixtures and Stubbing/Mocking Static Methods
February 15, 2010 @ 12:55:49

Sebastian Bergmann has two recent posts dealing with some of the more difficult topics in unit testing. One looks at sharing fixtures between tests and the other talks about stubbing and mocking static methods in your tests.

From the first of the two tutorials:

A good example of a fixture that makes sense to share across several tests is a database connection: you log into the database once and reuse the database connection instead of creating a new connection for each test. This makes your tests run faster.

This fixture sharing example uses the setUpBeforeClass and tearDownAfterClass methods to create and destroy the connection.

In the second article Sebastian shows how to mock up a sample static function and mock it with the "staticExpects" helper.

0 comments voice your opinion now!
phpunit unittest stub mock static share fixture


blog comments powered by Disqus

Similar Posts

Ralph Schinlder's Blog: PHPundamentals Series: A Background on Statics (Part 1 on Statics)

Padraic Brady's Blog: Mocks, Stubs, And SimpleTest Wins

Chris Hartjes: Testing Smells - Try/catch

Zend Developer Zone: An Introduction to the Art of Unit Testing in PHP

NetTuts.com: Better Workflow in PHP With Composer, Namespacing, and PHPUnit


Community Events





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


series library install framework security update version community composer opinion release language package podcast interview introduction application symfony laravel voicesoftheelephpant

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