Skip to Content
Mastering PHP 7
book

Mastering PHP 7

by Branko Ajzele
June 2017
Intermediate to advanced
536 pages
9h 49m
English
Packt Publishing
Content preview from Mastering PHP 7

Writing test

Getting started with writing PHPUnit tests requires grasping a few basic concepts, such as the following:

  • The setUp() method: Analogous to the constructor, this is where we create the objects against which we will perform the test.
  • The tearDown() method: Analogous to the destructor, this is where we clean up objects against which we performed the test.
  • The test*() methods: Every public method whose name begins with test, for example, testSomething(), testItAgain(), and so on, is considered a single test. The same effect can be achieved by adding the @test annotation in a method's docblock; although, this seems to be a less used case.
  • The @depends annotation: This allows expressing dependencies between the test methods.
  • Assertions ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning PHP 7

Learning PHP 7

Antonio L Zapata (GBP)
Upgrading to PHP 5

Upgrading to PHP 5

Adam Trachtenberg

Publisher Resources

ISBN: 9781785882814Supplemental Content