/** * @covers ::getEntityType */ public function testGetEntityTypeForFieldWithRelationship() { $handler = new TestHandler([], 'test_handler', []); $options = ['relationship' => 'test_relationship']; $handler->init($this->executable, $this->display, $options); $this->display->expects($this->atLeastOnce())->method('getOption')->with('relationships')->willReturn(['test_relationship' => ['table' => 'test_entity_type_table', 'id' => 'test_relationship', 'field' => 'test_relationship']]); $this->view->expects($this->any())->method('get')->with('base_table')->willReturn('test_entity_type_table'); $this->viewsData->expects($this->any())->method('get')->willReturnMap([['test_entity_type_table', ['table' => ['entity type' => 'test_entity_type'], 'test_relationship' => ['relationship' => ['base' => 'test_other_entity_type_table', 'base field' => 'id']]]], ['test_other_entity_type_table', ['table' => ['entity type' => 'test_other_entity_type']]]]); $handler->setViewsData($this->viewsData); $this->assertEquals('test_other_entity_type', $handler->getEntityType()); }
/** * @covers Microsite\Handler::handle */ public function testHandle() { $one = TestHandler::handle('\\Microsite\\TestHandler', 'handler_one'); $this->assertEquals('test', $one(new App())); $store = TestHandler::handle('\\Microsite\\TestHandler', 'store_value'); $two = TestHandler::handle('\\Microsite\\TestHandler', 'handler_two'); $store(new App()); $this->assertEquals('test', $two(new App())); }
public function testCallEvent() { $that = $this; $useHandler = false; $eventTestParams = array('eventTestParam' => 1); $handlerTestParam = array('handlerTestParam' => 1); TestHandler::setProcessCallback(function (Event $event, $params) use($that, $eventTestParams, $handlerTestParam, &$useHandler) { $that->assertInstanceOf(TestEvent::className(), $event); $that->assertEquals($eventTestParams, $event->getParams()); $that->assertEquals($handlerTestParam, $params); $useHandler = true; }); $dispatcher = new EventDispatcher(); $dispatcher->attachHandler(TestEvent::className(), TestHandler::className(), $handlerTestParam); $this->assertFalse($useHandler); /** @var TestEvent $event */ $event = $dispatcher->createEvent(TestEvent::className(), $eventTestParams); $dispatcher->fire($event); $this->assertTrue($useHandler); }
public static function setupQuery($definition) { $h = new TestHandler(); $d = new ezcSearchDocumentDefinition($definition); $d->fields['fieldOne'] = new ezcSearchDefinitionDocumentField('fieldOne'); if ($definition == 'DefinitionTwoFields') { $d->fields['fieldTwo'] = new ezcSearchDefinitionDocumentField('fieldTwo'); } $d->fields['ezcsearch_type'] = new ezcSearchDefinitionDocumentField('type'); $q = $h->createFindQuery('DefinitionOneField', $d); $q->whereClauses = array(); return $q; }
function __construct() { parent::__construct(); }
public function testHandlerFormat() { $handler = new TestHandler("%name% - %level% > %message%", "TESTLOG"); $message = $handler->write("debug", "test message", ["c" => "t"]); $this->assertSame("TESTLOG - debug > test message", $message); }