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:----dL50byeXmg78nOvp7T0AHBZWBE1CuYCscRNYC4/tKX85ZqZiNFCLaZoClIQHbuKlHwG6d1xnuWqlzRorYtBBqZx4amYp6xfYMC8yS5F7F+LBPcsaXGfpD+JsHqUbBYGgKh/Ly57ozlu3On+PT4zck46gO00QuvTPVPLQZtx0vvnxe4CjQyU77oDFPUAirVUE0FxjqyLxay5DrovjsL0EcNiVzNqnBLr5HEZLz4c7NRKPybvWVVz2hVLSxaMVOmr3FTXy61dyAjse3wNCQhOizbjKSYA9gY6iLBLwM82/rS6/t+US3GK7Iv5wKR8xGJxfUHwdALf9HhfYq57tfqXG3iEVPLOUODF2RrRqPl/7J6p5rHuq9n+7hgucUxGYOTKcOago2W0ALOdv9C34zsVfjAtAt1gL87Mro4MnCnTr5Uwd8zYlJihDZse6lSjwOlePj21mR9dQyJv+jC4uoa5WMzIe/3MVlAyHMYhD88XWqfXdMehbRofSFl1FFjd2BX1YXVrpiN598N+k2eI8vd/V8qimTBCy7zIxKw90zlAFb/8b/2aJO4LdhcjbpeDS7Jfka0EeHsPxE8Eh0cHusLJeB2q6hCUfdNiTXOPrSkkVzNwGD70EYl2R8h7XN0ZcWnldinVVWr+qrpNrhaA+T9+rX0l3nHgJjxU4FSuN4M3w2tY=----ATTACHMENT:----MTEyOTk2MTk4MzI5Nzk1NyA3MDkxODUxNjY2MTc4Mzk2IDkwMzM5MjkyMjkwNDYwMTc=