Source of file HandlerTest.php
Size: 2,489 Bytes - Last Modified: 2021-12-24T06:51:36+00:00
/var/www/docs.ssmods.com/process/src/tests/Output/HandlerTest.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 | <?php namespace Heystack\Core\Output; class HandlerTest extends \PHPUnit_Framework_TestCase { public $handler; protected function setUp() { $this->handler = new Handler; } protected function tearDown() { $this->handler = null; } public function testProcessorHandlerTrait() { $processor = $this->getProcessorStub('test_output_processor'); $processor2 = $this->getProcessorStub('test_output_processor2'); $processor3 = $this->getProcessorStub('test_output_processor3'); $this->handler->addProcessor($processor); $this->assertEquals($processor, $this->handler->getProcessor('test_output_processor')); $this->assertEquals(false, $this->handler->getProcessor('fake')); $this->assertTrue($this->handler->hasProcessor('test_output_processor')); $this->assertFalse($this->handler->hasProcessor('fake')); $this->assertEquals( [ 'test_output_processor' => $processor ], $this->handler->getProcessors() ); $this->handler->setProcessors( [ $processor2, $processor3 ] ); $this->assertEquals( [ 'test_output_processor2' => $processor2, 'test_output_processor3' => $processor3, ], $this->handler->getProcessors() ); } public function testProcess() { $this->handler->addProcessor($this->getProcessorStub('test', 'oh yeah!')); $controller = new \Controller(); $this->assertFalse($this->handler->process('fake', $controller)); $this->assertEquals('oh yeah!', $this->handler->process('test', $controller)); } protected function getProcessorStub($identifier, $process = null) { $identifierStub = $this->getMock('Heystack\Core\Identifier\IdentifierInterface'); $identifierStub->expects($this->any()) ->method('getFull') ->will($this->returnValue($identifier)); $processorStub = $this->getMock('Heystack\Core\Output\ProcessorInterface'); $processorStub->expects($this->any()) ->method('getIdentifier') ->will($this->returnValue($identifierStub)); $processorStub->expects($this->any()) ->method('process') ->will($this->returnValue($process)); return $processorStub; } } |