mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-06-25 10:43:44 +02:00
22 lines
692 B
PHP
22 lines
692 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Structural\Bridge\Tests;
|
|
|
|
use DesignPatterns\Structural\Bridge\HelloWorldService;
|
|
use DesignPatterns\Structural\Bridge\HtmlFormatter;
|
|
use DesignPatterns\Structural\Bridge\PlainTextFormatter;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class BridgeTest extends TestCase
|
|
{
|
|
public function testCanPrintUsingThePlainTextPrinter()
|
|
{
|
|
$service = new HelloWorldService(new PlainTextFormatter());
|
|
$this->assertSame('Hello World', $service->get());
|
|
|
|
// now change the implementation and use the HtmlFormatter instead
|
|
$service->setImplementation(new HtmlFormatter());
|
|
$this->assertSame('<p>Hello World</p>', $service->get());
|
|
}
|
|
}
|