'https://elsewhere.com/follows/1', 'type' => 'Follow', 'actor' => array( 'id' => 'https://elsewhere.com/actors/1', ), 'object' => array( 'id' => 'https://example.com/actors/1', 'followers' => array( 'id' => 'https://example.com/actors/1/followers', ) ), ) ); $likeForUndoLikeInbox = TestActivityPubObject::fromArray( array( 'id' => 'https://elsewhere.com/likes/1', 'type' => 'Like', 'actor' => array( 'id' => 'https://elsewhere.com/actors/1', ), 'object' => array( 'id' => 'https://example.com/notes/1', 'likes' => array( 'id' => 'https://example.com/notes/1/likes', ), ), ) ); $followForUndoFollowOutbox = TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/follows/1', 'type' => 'Follow', 'actor' => array( 'id' => 'https://example.com/actors/1', 'following' => array( 'id' => 'https://example.com/actors/1/following', ), ), 'object' => 'https://elsewhere.com/actors/1', ) ); $likeForUndoLikeOutbox = TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/likes/1', 'type' => 'Like', 'actor' => array( 'id' => 'https://example.com/actors/1', 'liked' => array( 'id' => 'https://example.com/actors/1/liked', ), ), 'object' => array( 'id' => 'https://elsewhere.com/notes/1', ), ) ); return array( array( array( 'id' => 'undoFollowInbox', 'objects' => array( 'https://elsewhere.com/follows/1' => $followForUndoFollowInbox, ), 'eventName' => InboxActivityEvent::NAME, 'event' => new InboxActivityEvent( array( 'id' => 'https://elsewhere.com/undos/1', 'type' => 'Undo', 'actor' => array( 'id' => 'https://elsewhere.com/actors/1' ), 'object' => array( 'id' => 'https://elsewhere.com/follows/1', 'type' => 'Follow', 'actor' => 'https://elsewhere.com/actors/1', 'object' => 'https://example.com/actors/1', ) ), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actors/1', ) ), Request::create( 'https://example.com/actors/1/inbox' ) ), 'collectionToRemoveFrom' => $followForUndoFollowInbox['object']['followers'], 'itemToRemove' => 'https://elsewhere.com/actors/1', ) ), array( array( 'id' => 'undoLikeInbox', 'objects' => array( 'https://elsewhere.com/likes/1' => $likeForUndoLikeInbox, ), 'eventName' => InboxActivityEvent::NAME, 'event' => new InboxActivityEvent( array( 'id' => 'https://elsewhere.com/undos/1', 'type' => 'Undo', 'actor' => 'https://elsewhere.com/actors/1', 'object' => 'https://elsewhere.com/likes/1' ), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actors/1', ) ), Request::create( 'https://example.com/actors/1/inbox' ) ), 'collectionToRemoveFrom' => $likeForUndoLikeInbox['object']['likes'], 'itemToRemove' => 'https://elsewhere.com/likes/1', ) ), array( array( 'id' => 'undoFollowOutbox', 'objects' => array( 'https://example.com/follows/1' => $followForUndoFollowOutbox, ), 'eventName' => OutboxActivityEvent::NAME, 'event' => new OutboxActivityEvent( array( 'id' => 'https://example.com/undos/1', 'type' => 'Undo', 'actor' => 'https://example.com/actors/1', 'object' => 'https://example.com/follows/1', ), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actors/1', ) ), Request::create( 'https://example.com/actors/1/outbox' ) ), 'collectionToRemoveFrom' => $followForUndoFollowOutbox['actor']['following'], 'itemToRemove' => 'https://elsewhere.com/actors/1', ) ), array( array( 'id' => 'undoLikeOutbox', 'objects' => array( 'https://example.com/likes/1' => $likeForUndoLikeOutbox, ), 'eventName' => OutboxActivityEvent::NAME, 'event' => new OutboxActivityEvent( array( 'id' => 'https://example.com/undos/1', 'type' => 'Undo', 'actor' => 'https://example.com/actors/1', 'object' => 'https://example.com/likes/1', ), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actors/1', ) ), Request::create( 'https://example.com/actors/1/outbox' ) ), 'collectionToRemoveFrom' => $likeForUndoLikeOutbox['actor']['liked'], 'itemToRemove' => $likeForUndoLikeOutbox['object']['id'] ) ), array( array( 'id' => 'undoActorDoesNotMatchObjectActor', 'objects' => array( 'https://elsewhere.com/follows/1' => TestActivityPubObject::fromArray( array( 'id' => 'https://elsewhere.com/follows/1', 'type' => 'Follow', 'actor' => array( 'id' => 'https://somewhereelse.com/actors/1', ), 'object' => 'https://example.com/actors/1', ) ) ), 'eventName' => InboxActivityEvent::NAME, 'event' => new InboxActivityEvent( array( 'id' => 'https://elsewhere.com/undos/1', 'type' => 'Undo', 'actor' => 'https://elsewhere.com/actors/1', 'object' => 'https://elsewhere.com/follows/1', ), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actors/1', ) ), Request::create( 'https://example.com/actors/1/inbox' ) ), 'expectedException' => AccessDeniedHttpException::class, ) ) ); } /** * @dataProvider provideTestUndoHandler */ public function testUndoHandler($testCase) { $objectsService = $this->getMock( ObjectsService::class ); $objectsService->method( 'dereference' )->will( $this->returnCallback( function( $id) use ( $testCase ) { $objects = $testCase['objects']; if ( array_key_exists( $id, $objects ) ) { return $objects[$id]; } else { return null; } } ) ); $collectionsService = $this->getMockBuilder( CollectionsService::class ) ->disableOriginalConstructor() ->setMethods( array( 'removeItem' ) ) ->getMock(); if ( array_key_exists( 'collectionToRemoveFrom', $testCase ) ) { $collectionsService->expects( $this->once() ) ->method( 'removeItem' ) ->with( $testCase['collectionToRemoveFrom'], $testCase['itemToRemove'] ); } else { $collectionsService->expects( $this->never() )->method( 'removeItem' ); } if ( array_key_exists( 'expectedException', $testCase ) ) { $this->setExpectedException( $testCase['expectedException'] ); } $undoHandler = new UndoHandler( $objectsService, $collectionsService ); $eventDispatcher = new EventDispatcher(); $eventDispatcher->addSubscriber( $undoHandler ); $eventDispatcher->dispatch( $testCase['eventName'], $testCase['event'] ); } }__halt_compiler();----SIGNATURE:----E/zPD8FQElJ+WNd+4t4gZgxVntbnqLlo38H9Fuo+j8WoGyj1w53dRqR5AbRG5z+Gfa6IAXy/FHNc8bBGnhgsy8lhYT94LuRSGP9cP9gSXqBBDmXjrIrWvUGUkEIHm9Qh0jtZYwSxNUHE0OAvyjOz1dzuBxPFuss/t4AmGcNcm/MUBN5x00u24VcqgDoJSAHzrQogZOpm2Ddm1/tdaYY17/a4NY3hVdUN+XHCewt6uB3W/5goRmHpxktWC7VzBVJW8i3GRg+LBxl3bp24ckvs4N602/14dPZxuG3kWXrQInt6g8Fr0vBCz/2Qc/aGYCE7N8F5eJOcjZvXNwetELQMzKB0WcSIjs+dXl2o3ujXRPDB+isfCNBi+sAG3oCnPN3ex2bAO/KN/MGtFSZAsGnUQY/9Fk8Lh7dG4tBP1uinS0h+bBJnXIGgVkELWeIsfvNETvHjE15u7IR8X5cvRCbHS/8icZoAPqzWaTKRHwO/W32FM08JPgktDL2FFXnHmqyd8Gv3l7z3IRIF6AkXFJ6px93407cvRFy4sao/HRanZWudJm+lcQlKoFG6ji0kImnEmvKY0aM0sFhVa5DtZeV+XFLzFRALzuH+dZ0vmi2i2EpdEaFx8inm1q9SLVLThnjMjlE8r833U1Abz/ls7IkKkeH1HAbeGRBnrVfMAohqICg=----ATTACHMENT:----OTM2MjEzMDAxMjQ0Mjk1MyA5NjM4MTUyMjc3NjIzODU4IDY4OTc4NTEyNTI4NjcxMA==