/** * @dataProvider getComputer */ public function testComputerOn(Computer $facade, OsInterface $os) { // interface is simpler : $facade->turnOn(); // but I can access to lower component $this->assertEquals('Linux', $os->getName()); }
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->assertEquals('Linux', $os->getName()); }