/** * Tests the buildGlobalCode() method. * @covers \ManiaScript\Builder\Event\Handler\PseudoHandler::buildGlobalCode */ public function testBuildGlobalCode() { $event1 = new Event(); $event1->setCode('abc'); $event2 = new Event(); $event2->setCode('def')->setInline(true); $queue = new PriorityQueue(); $queue->add($event1)->add($event2); /* @var $handler \ManiaScript\Builder\Event\Handler\PseudoHandler|\PHPUnit_Framework_MockObject_MockObject */ $handler = $this->getMockBuilder('ManiaScript\\Builder\\Event\\Handler\\PseudoHandler')->setMethods(array('buildHandlerFunction'))->setConstructorArgs(array(new Builder()))->getMockForAbstractClass(); $handler->expects($this->once())->method('buildHandlerFunction')->with($event1)->will($this->returnValue('ghi')); $this->injectProperty($handler, 'events', $queue); $result = $this->invokeMethod($handler, 'buildGlobalCode'); $this->assertContains('ghi', $result); }
/** * Tests the buildHandlerFunction() method. * @covers \ManiaScript\Builder\Event\Handler\AbstractHandler::buildHandlerFunction */ public function testBuildHandlerFunction() { $event = new Event(); $event->setCode('abc'); /* @var $handler \ManiaScript\Builder\Event\Handler\ControlHandler|\PHPUnit_Framework_MockObject_MockObject */ $handler = $this->getMockBuilder('ManiaScript\\Builder\\Event\\Handler\\AbstractHandler')->setMethods(array('getHandlerFunctionName'))->setConstructorArgs(array($this->builder))->getMockForAbstractClass(); $handler->expects($this->once())->method('getHandlerFunctionName')->with($event)->will($this->returnValue('def')); $result = $this->invokeMethod($handler, 'buildHandlerFunction', array($event)); $this->assertContains('Void def()', $result); $this->assertContains('abc', $result); }