mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-30 19:50:12 +02:00
PHP7 NullObject
This commit is contained in:
@@ -6,17 +6,12 @@ use DesignPatterns\Behavioral\NullObject\NullLogger;
|
||||
use DesignPatterns\Behavioral\NullObject\PrintLogger;
|
||||
use DesignPatterns\Behavioral\NullObject\Service;
|
||||
|
||||
/**
|
||||
* LoggerTest tests for different loggers.
|
||||
*/
|
||||
class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testNullObject()
|
||||
{
|
||||
// one can use a singleton for NullObjet : I don't think it's a good idea
|
||||
// because the purpose behind null object is to "avoid special case".
|
||||
$service = new Service(new NullLogger());
|
||||
$this->expectOutputString(null); // no output
|
||||
$this->expectOutputString(null);
|
||||
$service->doSomething();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user