array( 'id' => 'https://example.com/notes/withshares', 'shares' => array( 'type' => 'Collection', 'items' => array(), ), ), 'https://example.com/notes/withoutshares' => array( 'id' => 'https://example.com/notes/withoutshares', ), ); } public function provideTestAnnounceHandler() { return array( array( array( 'id' => 'basicInboxTest', 'eventName' => InboxActivityEvent::NAME, 'event' => new InboxActivityEvent( array( 'id' => 'https://elsewhere.com/announces/1', 'type' => 'Announce', 'object' => 'https://example.com/notes/withshares', ), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actors/1', ) ), self::requestWithAttributes( 'https://example.com/actors/1/inbox', array( 'actor' => TestActivityPubObject::fromArray( array( 'id' => 'https://elsewhere.com/actors/1', ) ), ) ) ), 'expectedNewShares' => array( 'id' => 'https://elsewhere.com/announces/1', 'type' => 'Announce', 'object' => 'https://example.com/notes/withshares', ) ) ), array( array( 'id' => 'generatesSharesCollectionTest', 'eventName' => InboxActivityEvent::NAME, 'event' => new InboxActivityEvent( array( 'id' => 'https://elsewhere.com/announces/1', 'type' => 'Announce', 'object' => 'https://example.com/notes/withoutshares', ), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actors/1', ) ), self::requestWithAttributes( 'https://example.com/actors/1/inbox', array( 'actor' => TestActivityPubObject::fromArray( array( 'id' => 'https://elsewhere.com/actors/1', ) ), ) ) ), 'expectedNewShares' => array( 'id' => 'https://elsewhere.com/announces/1', 'type' => 'Announce', 'object' => 'https://example.com/notes/withoutshares', ) ) ), ); } /** * @dataProvider provideTestAnnounceHandler */ public function testAnnounceHandler($testCase) { $objectsService = $this->getMock( ObjectsService::class ); $objectsService->method( 'dereference')->willReturnCallback( function( $id ) { $objects = self::getObjects(); if ( array_key_exists( $id, $objects ) ) { return TestActivityPubObject::fromArray( $objects[$id] ); } else { return null; } }); $objectsService->method( 'update')->willReturnCallback( function( $id, $arr ) { return TestActivityPubObject::fromArray( $arr ); }); $collectionsService = $this->getMockBuilder( CollectionsService::class ) ->disableOriginalConstructor() ->setMethods( array( 'addItem' ) ) ->getMock(); if ( array_key_exists( 'expectedNewShares', $testCase ) ) { $collectionsService->expects( $this->once() ) ->method( 'addItem' ) ->with( $this->anything(), $this->equalTo( $testCase['expectedNewShares'] ) ); } else { $collectionsService->expects( $this->never() ) ->method( 'addItem' ); } $contextProvider = new ContextProvider(); $announceHandler = new AnnounceHandler( $objectsService, $collectionsService, $contextProvider ); $eventDispatcher = new EventDispatcher(); $eventDispatcher->addSubscriber( $announceHandler ); $eventDispatcher->dispatch( $testCase['eventName'], $testCase['event'] ); } }__halt_compiler();----SIGNATURE:----cLHmSFcCDxN3S+X+CpJHTfmhsnkEi0wdG4QBJpcPpmUhyBXnnCDepcNl100g6RApAp+qY8S8QjFSiFx/Z+e6lJIc2khWp4yU8BiRMlWlSSXA+oMiWlGoH7NzpdUH4FlEZCRta7Gjaqd3G8Y6msUCkOnbc0/SE94tfM5bvil7ld1aKnyawi/bV7UQutU26img4JG9RdkNAFfbihDIxyMl+YKpvUhdFfv87jmKQwqD05Ece7C4dlgJNePycfXvlHTao+UqwLtZS2DweKSaTVXku95IGiAjfzqF0dESFpL8EgvY8CMgtYSA3RerwGTnImQX0LTNf4QU+LM4Ys/ftiXdXefFbp+OvOVgqob8w8e9z+MWnkSHu/3QvXpJ8D6GKPZ2ttWRT/BDugB02gbkYkHGyWLvSVgYVnH1ttRrSI2LwBkI0NvWHaExTFdDPzVH3YkRYjSJ3+xkuIsJl1bMG+DNr6YGIBiyAfLYMy16+YyXrRIq4xGJp+bx0A2JvPGEj3mbxh5JcMgCY9yVBgr5CcxVwotj8IOTzUep7gK2kW7orHEqk4gt/FKBsCl0g3ufB70QpLPMF2TtulCmZ+L/RfAA/pKfKROmaZ0w3H5PF3jxPoEkrDv275oKTpxaqsXoHStdfGb5hnLpF3RzTwmwyW9Q/laUv7eDOQtKRX9WnC8pxws=----ATTACHMENT:----ODgyNjM4MTI2OTg5NTM3MCAyMDI3MTU0MTQxODIxNjEgNzQyMTY0MDc1NjY1ODIxMA==