DataSift\Storyplayer\Output::logCliErrorWithException PHP Méthode

logCliErrorWithException() public méthode

called when the outer CLI shell encounters a fatal error
public logCliErrorWithException ( string $msg, Exception $e ) : void
$msg string the error message to show the user
$e Exception the exception that caused the error
Résultat void
    public function logCliErrorWithException($msg, $e)
    {
        // enforce our inputs
        Contract::RequiresValue($msg, is_string($msg));
        Contract::RequiresValue($e, $e instanceof Exception);
        // pass this on to our plugins
        foreach ($this->plugins as $plugin) {
            $plugin->logCliErrorWithException($msg, $e);
        }
    }

Usage Example

Exemple #1
0
 /**
  * @covers DataSift\Storyplayer\Output::logCliErrorWithException()
  */
 public function testCanLogCliErrorWithException()
 {
     // ----------------------------------------------------------------
     // setup the test
     $msg = "this is an emergency, damnit!";
     $e = new Exception();
     $plugin1 = Mockery::mock("DataSift\\Storyplayer\\OutputLib\\OutputPlugin");
     $plugin1->shouldReceive('logCliErrorWithException')->once()->with($msg, $e);
     $plugin2 = Mockery::mock("DataSift\\Storyplayer\\OutputLib\\OutputPlugin");
     $plugin2->shouldReceive('logCliErrorWithException')->once()->with($msg, $e);
     $obj = new Output();
     $obj->usePluginInSlot($plugin1, "console");
     $obj->usePluginInSlot($plugin2, "slot1");
     // ----------------------------------------------------------------
     // perform the change
     $obj->logCliErrorWithException($msg, $e);
     // ----------------------------------------------------------------
     // test the results
     Mockery::close();
 }