/** * Assert a filter only match the given event types * @param Filter\EventTypeEventFilter $filter * @param array $matchedTypes An array of matched event types * @return void */ protected function assertFilterMatch(EventTypeEventFilter $filter, $matchedTypes) { foreach ($this->allEventTypes as $type) { $event = new Event(); $event->setType($type); $mustAccept = in_array($type, $matchedTypes); $message = sprintf("The filter with accepted types '%s' did not match the event type '%s'", $this->getAttributeValue($filter, 'acceptedEventTypes'), $type); $this->assertEquals($mustAccept, $filter->match($event), $message); } }
/** * Assert a filter only match the given event types * * @param EventFilter $filter * @param array $matchedTypes An array of matched event types */ protected function assertFilterMatch(EventFilter $filter, $matchedTypes) { foreach ($this->allEventTypes as $type) { $event = new Event($this->factory, $this->getNodeTypeManager()); $event->setType($type); $mustAccept = in_array($type, $matchedTypes); $message = sprintf("The filter with accepted types '%s' did not match the event type '%s'", $this->eventFilter->getEventTypes(), $type); $this->assertEquals($mustAccept, $filter->match($event), $message); } }
public function testIterator() { $filter = new EventFilter($this->factory, $this->session); $event1 = new Event($this->factory, $this->getNodeTypeManager()); $event1->setDate(2); $event2 = new Event($this->factory, $this->getNodeTypeManager()); $event2->setDate(3); $this->transport->expects($this->once())->method('getEvents')->with(2, $filter, $this->session)->will($this->returnValue(new \ArrayIterator(array($event1, $event2)))); $journal = new EventJournal($this->factory, $filter, $this->session, $this->transport); $journal->skipTo(2); $this->assertTrue($journal->valid()); $this->assertSame($event1, $journal->current()); $journal->next(); $this->assertTrue($journal->valid()); $this->assertSame($event2, $journal->current()); $journal->next(); $this->assertFalse($journal->valid()); $journal->rewind(); $this->assertTrue($journal->valid()); $this->assertSame($event1, $journal->current()); }
public function testEventInfo() { $events = $this->getAndCallMethod($this->buffer, 'extractEvents', array($this->getDomElement($this->eventWithInfoXml), 'system')); $this->assertCount(1, $events); $eventWithInfo = $events[0]; $this->assertInstanceOf('Jackalope\\Observation\\Event', $eventWithInfo); /** @var $eventWithInfo Event */ $eventInfo = $eventWithInfo->getInfo(); $this->assertEquals($this->expectedEventWithInfo->getInfo(), $eventInfo); $expectedInfo = array('destAbsPath' => '/my_other', 'srcAbsPath' => '/my_node'); $this->assertEquals(count($expectedInfo), count($eventInfo)); foreach ($expectedInfo as $key => $expectedValue) { $value = $eventInfo[$key]; $this->assertSame($expectedValue, $value); } $this->nodeTypeManager->expects($this->at(0))->method('getNodeType')->with('{internal}root')->will($this->returnValue(true)); $this->nodeTypeManager->expects($this->at(1))->method('getNodeType')->with('{internal}AccessControllable')->will($this->returnValue(true)); $this->assertTrue($eventWithInfo->getPrimaryNodeType()); $this->assertEquals(array('{internal}AccessControllable' => true), $eventWithInfo->getMixinNodeTypes()); }
protected function assertFilterMatch(PathEventFilter $filter, $isSupposedToMatch, $path) { $event = new Event(); $event->setPath($path); $this->assertEquals($isSupposedToMatch, $filter->match($event)); }
/** * Get an Event with the given path * @param string $path * @return Event */ protected function getEvent($path) { $event = new Event(); $event->setPath($path); return $event; }
protected function assertFilterMatch(EventFilter $filter, $expectedResult) { $event = new Event($this->factory, $this->getNodeTypeManager()); $event->setPath('/some/path'); $this->assertEquals($expectedResult, $filter->match($event)); }
/** * Parse the events in an <entry> section * @param \DOMElement $entry * @param string $currentUserId The current user ID as extracted from the <entry> part * @return array(Event) */ protected function extractEvents(\DOMElement $entry, $currentUserId) { $events = array(); $domEvents = $entry->getElementsByTagName('event'); foreach ($domEvents as $domEvent) { $event = new Event(); $event->setType($this->extractEventType($domEvent)); $date = $this->getDomElement($domEvent, 'eventdate', 'The event date was not found while building the event journal:\\n' . $this->getEventDom($domEvent)); $event->setUserId($currentUserId); // The timestamps in Java contain milliseconds, it's not the case in PHP // so we strip millis from the response $event->setDate(substr($date->nodeValue, 0, -3)); $id = $this->getDomElement($domEvent, 'eventidentifier'); if ($id) { $event->setIdentifier($id->nodeValue); } $href = $this->getDomElement($domEvent, 'href'); if ($href) { $path = str_replace($this->workspaceRootUri, '', $href->nodeValue); if (substr($path, -1) === '/') { // Jackrabbit might return paths with trailing slashes. Eliminate them if present. $path = substr($path, 0, -1); } $event->setPath($path); } $nodeType = $this->getDomElement($domEvent, 'eventprimarynodetype'); if ($nodeType) { $event->setNodeType($nodeType->nodeValue); } $userData = $this->getDomElement($domEvent, 'eventuserdata'); if ($userData) { $event->setUserData($userData->nodeValue); } $eventInfos = $this->getDomElement($domEvent, 'eventinfo'); if ($eventInfos) { foreach ($eventInfos->childNodes as $info) { if ($info->nodeType == XML_ELEMENT_NODE) { $event->addInfo($info->tagName, $info->nodeValue); } } } $events[] = $event; } return $events; }
protected function assertFilterMatch(NodeTypeEventFilter $filter, $expectedResult) { $event = new Event(); $event->setPath('/some/unexisting/path'); $this->assertEquals($expectedResult, $filter->match($event)); }
protected function assertFilterMatch(EventFilter $filter, $isSupposedToMatch, $path) { $event = new Event($this->factory, $this->getNodeTypeManager()); $event->setPath($path); $this->assertEquals($isSupposedToMatch, $filter->match($event)); }