Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

issue.exit

edsonmedina edited this page Dec 12, 2014 · 8 revisions

#Exit (or die)

class foo
{
    public function bar ()
    {
        // ...
  
        exit(); 
    }
}

##Why is this a testing issue?

Pretty self-explanatory. If a method calls exit() or die() the execution stops immediately and the test doesn't run.

##Possible solutions

####Don't do it

Simple.

####If you really need it

Write a wrapper method.

class foo
{
    public function bar ()
    {
        // ...
  
        $this->exitApp();
    }
  
    // this method will be untestable
    public function exitApp ($code);
    {
        exit ($code);
    }
}
Clone this wiki locally