array( 'id' => 'https://elsewhere.com/collections/1', ), 'https://example.com/collections/1' => array( 'id' => 'https://example.com/collections/1', ), ); } public function provideTestHandleRemove() { return array( array( array( 'id' => 'basicTest', 'eventName' => InboxActivityEvent::NAME, 'event' => new InboxActivityEvent( array( 'id' => 'https://elsewhere.com/removes/1', 'type' => 'Remove', 'object' => array( 'id' => 'https://elsewhere.com/notes/1', ), 'target' => array( 'id' => 'https://elsewhere.com/collections/1' ) ), 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' ) ) ) ) ), 'expectedRemovedItemId' => 'https://elsewhere.com/notes/1', ) ), array( array( 'id' => 'outboxTest', 'eventName' => OutboxActivityEvent::NAME, 'event' => new OutboxActivityEvent( array( 'id' => 'https://example.com/removes/1', 'type' => 'Remove', 'object' => array( 'id' => 'https://example.com/notes/1', ), 'target' => array( 'id' => 'https://example.com/collections/1' ) ), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actors/1', ) ), self::requestWithAttributes( 'https://example.com/actors/1/inbox', array( 'actor' => TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actors/1' ) ) ) ) ), 'expectedRemovedItemId' => 'https://example.com/notes/1', ) ), array( array( 'id' => 'notAuthorizedTest', 'eventName' => OutboxActivityEvent::NAME, 'event' => new OutboxActivityEvent( array( 'id' => 'https://example.com/removes/1', 'type' => 'Remove', 'object' => array( 'id' => 'https://example.com/notes/1', ), 'target' => array( 'id' => 'https://elsewhere.com/collections/1' ) ), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actors/1', ) ), self::requestWithAttributes( 'https://example.com/actors/1/inbox', array( 'actor' => TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actors/1' ) ) ) ) ), 'expectedException' => AccessDeniedHttpException::class, ) ), ); } /** * @dataProvider provideTestHandleRemove */ public function testHandleRemove($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; } }); $collectionsService = $this->getMockBuilder( CollectionsService::class ) ->disableOriginalConstructor() ->setMethods( array( 'removeItem' ) ) ->getMock(); if ( array_key_exists( 'expectedRemovedItemId', $testCase ) ) { $collectionsService->expects( $this->once() ) ->method( 'removeItem' ) ->with( $this->anything(), $this->equalTo( $testCase['expectedRemovedItemId'] ) ); } else { $collectionsService->expects( $this->never() ) ->method( 'removeItem' ); } $removeHandler = new RemoveHandler( $objectsService, $collectionsService ); $eventDispatcher = new EventDispatcher(); $eventDispatcher->addSubscriber( $removeHandler ); if ( array_key_exists( 'expectedException', $testCase ) ) { $this->setExpectedException( $testCase['expectedException'] ); } $eventDispatcher->dispatch( $testCase['eventName'], $testCase['event'] ); } }__halt_compiler();----SIGNATURE:----EgUUclbwbNFYuR30FX0rlagVzOfbnZMkGb2G/1H80tU+4reMdKH+XGDamc4N6uFdmSimkz2BO5zBMSnUpAkHxz98wlYn2yKtPSTF/QcwR/YyAQOS2BKtk0rYJex/RHvZ2RWEKzKQpbHPFlNi5KIhBkhonnWvlXPeu4geF9I5pu0y7LJZPIwo0f+7VDZGmnB8lqvXON3mceKWPO3LtUee6PdynDha+gLS/YXb23ddChJWTAV45z41CrjAfAHuQIPKKVobiY6323OQ/bBUaBxBoxbRYsCpmL/sH1wgLmwo9EufotwBBKQZyz5B1vwTlHcye2qUe+NTdANCu2SHZoMZeqHCvn/RYEE3sg0Ip/lDxKe14ldymSyvjdl38hW9n4kGJ2JC3CXd0MleurttoLhE3kSoGWZ64ECZC+2YSuVdpa+38MR1C/VNCeu8+ZVh5XZg4CHBOYk3oApUHUETYG33JrhBGOp210R6DXIBGLQFl0uRLjMhqJBUDPFosNmGL36zk4+kF/gsbZOi4lcxUr60gTrXWncPZkaVwnDZXa8zcfNdMoXaIf25n7hypObBsoUjCxxZnXEz7D4xIGAmYdbwnNaoJ0mpbFD3iukz5mxxkWQgciY8XEzHQnK7GspjFMmjptcaORQ+1b6lbYud21oJMyvJvqtq2T/iO9m4LjPigjQ=----ATTACHMENT:----OTUwMDEwNzA0MDk4NzM5NCA0MDYwMzk2NjgzMjczMTE4IDIzODI2NzU4NzYxMDMwMDQ=