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:----GiqLE1krkLY1enFnjonZPjTfmWFdOon1ch2uQF8FKQcTE+mYCjHW2eNEoAJq+gYJ1sB+GOtt68zvGosOu7UavcCLnJ+NmedK6vxWDfqBAE6TLzouAdho3u8sEZZ+EVO6xfaYRnixxi6IHSwODIN+mxNpt5CkGaH5NJvV20D7J2728dzUmmtgJpXNDPurfi5XhoA5cE+PH5/d92VYEwphXQR7hLzKM4PhGV65wFqqvPhr+fBahYYaKAyh/6Yom+t5KfRm+EvSnAn73vhOVmFzCxtgyOtdONPPCmyYTY5nIyQlPv2leCug8pXwgwEmZi1K9urmf1NCOjDF/l6EOXy7RY6nmas9LFyB10a2DGgBC6832/teEnyLWAS7z18d80LHhdPA8a+DM6Uh03cd/2J158nOjFvkssWbW1CGhsU4o60Ad7wOpwfR1edcpttYanGILG147ADtyGjbS3CIKpz/Txuf5yPgejAMljC5LAVIUu2mGjf3ujIUfVib1T1YjDAOofmmnZEQMfXwbG3+zgA1DMoODqDnZMI5fgM0Q+KaEjTvtUOURavSX+gUDHrndNwzqJ+Mfj8/YhgrwU/vZzSfpdxEzc2k/4+kNbw0slbPka2eYvx8DslP+viBDFnycKaIZl5vTFJZyiA3NhFeEXKD62Lhc4UMxqwZ4E2iOMrhEtI=----ATTACHMENT:----MTQ2MDI0OTg5MzU5NzQ5MiA4MDM5NDQ0ODUyMjI1OTY3IDg2NjU2NDYxODE1NTI4ODI=