PHP, Zend Framework and Other Crazy Stuff
Archive for November 14, 2007
PHPSpec Reporting Gets A Needed Boost
Nov 14th
PHPSpec is closing in on its first stable release, so the time had finally come to spruce up its output! No more the simple reporting of failed specs – now you get a few more details in a readable format, exceptions and errors even come with traces. In addition, I’ve implemented specdoc output as an option (using “-s”) so you can get a list of specs in their plain text form.
I’ve pasted in a copy of the output from a real PHPSpec run and added a few issues to show how they are output. I’ve been writing some experimental source code for a possible Mock Object framework in PHP (see last blog entry), so I used PHPSpec to apply Behaviour-Driven Development in its development. You can read the actual spec files over at http://phpmock.googlecode.com/svn/branches/padraic/specs/.
PHPSpec development snapshots have been updated on http://dev.phpspec.org, which also hosts the manual being written (HTML).
$ phpspec -rs
EE..................................................P..
Finished in 0.334152936935 seconds
p h p mock method expectations
-should expect each method exactly once unless otherwise specified (ERROR)
-should throw default exception if method call count is unexpected (EXCEPTION)
-should expect number of methods in times term
-should return self from times term invocation
-should set return value in terms and default to returning value for all calls
-should return values in order of setting but return last value remaining on other calls
-should return self from return term invocation
-should set expected args using with term
-should return self from with term invocation
-should allow no calls for zeroormoretimes term
-should allow one call with once term
-should throw exception if less than once using once tern
-should throw exception if greater than once using once term
-should return self instance from once term
-should allow two calls with twice term
-should throw exception if less than twice using twice term
-should throw exception if greater than twice using twice term
-should return self instance from twice term
-should allow no calls with never term
-should throw exception if any call after never term
-should return self instance from never term
-should allow any calls for zeroormoretimes term
-should allow zero calls for zeroormoretimes term
-should return self instance from zeroormoretimes term
-should set times minimum with once using atleast term
-should set times minimum with times using atleast term
-should throw exception if less than minimum using atleast term
-should return self instance from atleast term
-should set times maximum with once using atmost term
-should set times maximum with times using atmost term
-should throw exception if more than twice using twice term
-should return self instance from atmost term
-should allow any args using withanyargs term
-should return self instance from withanyargs term
-should disallow args using withnoargs term
-should return self instance from withnoargs term
-should obey ordering via sequence of ordered term calls
-should disallow method calling if method has specified order
-should allow method calling of unordered expectations in any order
-should return self instance from ordered term
-should throw specified exception using andthrow term
-should throw specified exception with message using andthrow term
-should throw exception if class passed to andthrow term not an exception
-should return self instance from andthrow term
p h p mock
-should create mock inheriting class type from original
-should create mock inheriting type if original an interface
-should create mock with specified name
-should create stub from an array of methods and return values
-should throw exception if class is final
-should throw exception if class does not exist
-should not throw class not exists exception if an interface
-should mock all allowed public methods which do nothing since mocked
-should mock public static methods which do nothing since mocked (PENDING)
-should retain method parameter definitions in mocks
-should return true on validation by default if no expectations set
55 examples, 0 failures, 1 error, 1 exception, 1 pending
Errors:
1)
'p h p mock method expectations should expect each method exactly once unless otherwise specified' ERROR
exception 'PHPSpec_Runner_ErrorException' with message 'more bad stuff happenin'' in /user/opt/projects/phpmock/specs/PHPMockMethodExpectationsSpec.php:19
Stack trace:
#0 [internal function]: PHPSpec_ErrorHandler(1024, 'more bad stuff ...', '/user/opt/...', 19, Array)
#1 /user/opt/projects/phpmock/specs/PHPMockMethodExpectationsSpec.php(19): trigger_error('more bad stuff ...')
#2 /user/opt/projects/phpspec/trunk/src/PHPSpec/Runner/Example.php(81): DescribePHPMockMethodExpectations->itShouldExpectEachMethodExactlyOnceUnlessOtherwiseSpecified()
#3 /user/opt/projects/phpspec/trunk/src/PHPSpec/Runner/Collection.php(73): PHPSpec_Runner_Example->execute()
#4 /user/opt/projects/phpspec/trunk/src/PHPSpec/Runner/Base.php(51): PHPSpec_Runner_Collection->execute(Object(PHPSpec_Runner_Result))
#5 /user/opt/projects/phpspec/trunk/src/PHPSpec/Runner/Base.php(44): PHPSpec_Runner_Base->executeExamples()
#6 /user/opt/projects/phpspec/trunk/src/PHPSpec/Console/Command.php(82): PHPSpec_Runner_Base::execute(Object(PHPSpec_Runner_Collection), Object(PHPSpec_Ru
nner_Result))
#7 /user/opt/projects/phpspec/trunk/src/PHPSpec/Console/Command.php(125): PHPSpec_Console_Command::main()
#8 {main}
Exceptions:
1)
'p h p mock method expectations should throw default exception if method call count is unexpected' EXCEPTION
exception 'PHPSpec_Exception' with message 'no specification object created yet' in /user/opt/projects/phpspec/trunk/src/PHPSpec/Context.php:92
Stack trace:
#0 /user/opt/projects/phpspec/trunk/src/PHPSpec/Runner/Example.php(89): PHPSpec_Context->getCurrentSpecification()
#1 /user/opt/projects/phpspec/trunk/src/PHPSpec/Runner/Collection.php(73): PHPSpec_Runner_Example->execute()
#2 /user/opt/projects/phpspec/trunk/src/PHPSpec/Runner/Base.php(51): PHPSp
ec_Runner_Collection->execute(Object(PHPSpec_Runner_Result))
#3 /user/opt/projects/phpspec/trunk/src/PHPSpec/Runner/Base.php(44): PHPSpec_Runner_Base->executeExamples()
#4 /user/opt/projects/phpspec/trunk/src/PHPSpec/Console/Command.php(82): PHPSpec_Runner_Base::execute(Object(PHPSpec_Runner_Collection), Object(PHPSpec_Runner_Result))
#5 /user/opt/projects/phpspec/trunk/src/PHPSpec/Console/Command.php(125): PHPSpec_Console_Command::main()
#6 {main}
Pending:
1)
'p h p mock should mock public static methods which do nothing since mocked' PENDING
Static methods will need static handling
