mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-09-26 14:29:13 +02:00
37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace DesignPatterns\Structural\Facade\Tests;
|
|
|
|
use DesignPatterns\Structural\Facade\Facade;
|
|
use DesignPatterns\Structural\Facade\OsInterface;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class FacadeTest extends TestCase
|
|
{
|
|
public function testComputerOn()
|
|
{
|
|
/** @var OsInterface|\PHPUnit_Framework_MockObject_MockObject $os */
|
|
$os = $this->createMock('DesignPatterns\Structural\Facade\OsInterface');
|
|
|
|
$os->method('getName')
|
|
->will($this->returnValue('Linux'));
|
|
|
|
$bios = $this->getMockBuilder('DesignPatterns\Structural\Facade\BiosInterface')
|
|
->setMethods(['launch', 'execute', 'waitForKeyPress'])
|
|
->disableAutoload()
|
|
->getMock();
|
|
|
|
$bios->expects($this->once())
|
|
->method('launch')
|
|
->with($os);
|
|
|
|
$facade = new Facade($bios, $os);
|
|
|
|
// the facade interface is simple
|
|
$facade->turnOn();
|
|
|
|
// but you can also access the underlying components
|
|
$this->assertSame('Linux', $os->getName());
|
|
}
|
|
}
|