Book Image

PhpStorm Cookbook

By : Mukund Chaudhary
Book Image

PhpStorm Cookbook

By: Mukund Chaudhary

Overview of this book

Table of Contents (16 chapters)
PhpStorm Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Testing an application with PHPUnit


There must be a question hovering in your mind about the role of PhpStorm in this testing. It's time for action. Having sufficient knowledge of the conventions to write tests, you can proceed to face the real world of testing. The more you test, the purer your code will become. Testing is good. Testing is healthy. Testing is recommended.

How to do it...

Good question. This question is best answered with some diving back into time to get back the same pizza cooking use case. You have grown up listening to grandma's advice to reuse objects. Now is the time for you to reuse. Perform the following steps:

  1. Reuse the PizzaDish class. You will create a test class somewhat like the following:

    require_once "PizzaDish.php";
    class PizzaDishTest extends PHPUnit_Framework_TestCase {
    
      function setUp(){
        $this->pizzaDish = new PizzaDish("Pizza Dish", "Dish");
      }
    
      function tearDown(){
        unset($this->pizzaDish);
      }
    
      public function testGetInstance(){
       ...