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:----TBza9DAm/T8b7f/ffSFfl4ubKULQfHFfu+2gAJNOMdawElPHKz4FP59XbidwgfgoUL3RLEYtpNyi5cZk0mNl82/m9nc8AatWbCD1HYYuVpLedVN8LItXxUNtmwOzcs17PpB7GJdIAujgys9SND7ybeAnh1pZzsS9wI0RBgh5xiXSf3ee9FdemP/L026Cx5fXSezOQ24f8NMn3a2yv+B3qrMQcPNMu+hFhJcjmP9wvxOfc+zeS4ykT+i8RYpMKSAch2vQCdfbNCJjlmfSmi2fbJ9olsmnWUtAOsjcXMjCL3Od/UBADf5ABOTv1rlJKpcAVkYaynCd7m3/Bhyu/q4lmOS1KZsNJd0KMxKaFJErkuQQQjRnOIFl699aSOeDfHYq0JdVqbUvxfs4cHgTw3122ClX+ENohrWukzbsCLIoNMV48NH+g+t8OMLjwODHGM7u+9ClVGced8cdFpMfyf/5WWQtW/zUxQ8rm37IQj1J/i4b+pTOnZ5P525ucE64THBvy1a0UKSM0mlWOnD68ZiXutn0CiCI4PxqhIVpcxIBab/Ts4HoOqfKbMN9/ZXXckc+FZuuOPw2xxfCjCWDAfVlYXRcZ4GfgtaUtjNf6DSiV8Z29rngBN8kLONjLgk1UrE97Mk7CIt7RcfdapAX3ptmTOF6KxW85C94lMV/RuVLc5Y=----ATTACHMENT:----ODM2MDUzNzEzNjQxMjMwOSA3MzQyNTQyNzY3MTY5MjA3IDY5NjQwOTAzOTQyOTI5Nw==