PHP Objects, Patterns and Practice (3rd edition)
C H A P T E R 18 ■ ■ ■ Testing with PHPUnit Every component in a system depends, for its continued smooth running, on the consis ...
■Chapter 18: Testing with PHPUnit ..................................................................... and fails as it should. ...
CHAPTER 18 ■ TESTING WITH PHPUNIT This class accepts user data with the addUser() method and retrieves it via getUser(). The use ...
CHAPTER 18 ■ TESTING WITH PHPUNIT Introducing PHPUnit PHPUnit is a member of the xUnit family of testing tools. The ancestor of ...
CHAPTER 18 ■ TESTING WITH PHPUNIT up a stable and suitably primed environment for the test. tearDown() is invoked after each tes ...
CHAPTER 18 ■ TESTING WITH PHPUNIT languages support them natively and inline and allow you to turn them off in a production cont ...
CHAPTER 18 ■ TESTING WITH PHPUNIT after an error if for example an operation is half complete before the problem occurs? It is y ...
CHAPTER 18 ■ TESTING WITH PHPUNIT public function setUp() { $store = new UserStore(); $store->addUser( "bob williams", "bob@e ...
CHAPTER 18 ■ TESTING WITH PHPUNIT self::fail( "Exception should have been thrown" ); } catch ( Exception $e ) { $const = $this-& ...
CHAPTER 18 ■ TESTING WITH PHPUNIT Table 18–2. Some Constraint Methods TestCase Method Constraint Fails Unless... greaterThan( $n ...
CHAPTER 18 ■ TESTING WITH PHPUNIT Another approach is to fake the context of the class you are testing. This involves creating o ...
CHAPTER 18 ■ TESTING WITH PHPUNIT use the convenience methods in TestCase to generate your matcher). The matcher defines the car ...
CHAPTER 18 ■ TESTING WITH PHPUNIT repeatedly) that the associated method should be primed to return. You can pass in this return ...
CHAPTER 18 ■ TESTING WITH PHPUNIT } return null; } } Here is the simple User class: class User { private $name; private $mail; p ...
CHAPTER 18 ■ TESTING WITH PHPUNIT $this->assertEquals( $user->getMail(), "
[email protected]
" ); // ... When I come to run my test su ...
CHAPTER 18 ■ TESTING WITH PHPUNIT The most insidious bugs don’t cause the interpreter to report that something is wrong. They hi ...
CHAPTER 18 ■ TESTING WITH PHPUNIT list( $key, $val )=explode( "=", $arg ); $this->setProperty( $key, $val ); } } } The init() ...
CHAPTER 18 ■ TESTING WITH PHPUNIT \woo\domain\ObjectWatcher::instance()->performOperations(); $this->invokeView( $app_c-&g ...
CHAPTER 18 ■ TESTING WITH PHPUNIT With those refactorings out the way, my system is more amenable to testing. It’s no accident t ...
CHAPTER 18 ■ TESTING WITH PHPUNIT woo\controller\Controller::run(); $ret = ob_get_contents(); ob_end_clean(); return $ret; } } B ...
«
16
17
18
19
20
21
22
23
24
25
»
Free download pdf