array( 'id' => 'https://elsewhere.com/collections/1', ), 'https://example.com/collections/1' => array( 'id' => 'https://example.com/collections/1', ), ); } public function provideTestHandleAdd() { return array( array( array( 'id' => 'basicTest', 'eventName' => InboxActivityEvent::NAME, 'event' => new InboxActivityEvent( array( 'id' => 'https://elsewhere.com/adds/1', 'type' => 'Add', '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' ) ) ) ) ), 'expectedNewItem' => array( 'id' => 'https://elsewhere.com/notes/1', ) ) ), array( array( 'id' => 'outboxTest', 'eventName' => OutboxActivityEvent::NAME, 'event' => new OutboxActivityEvent( array( 'id' => 'https://example.com/adds/1', 'type' => 'Add', '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' ) ) ) ) ), 'expectedNewItem' => array( 'id' => 'https://example.com/notes/1', ) ) ), array( array( 'id' => 'notAuthorizedTest', 'eventName' => OutboxActivityEvent::NAME, 'event' => new OutboxActivityEvent( array( 'id' => 'https://example.com/adds/1', 'type' => 'Add', '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 provideTestHandleAdd */ public function testHandleAdd($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( 'addItem' ) ) ->getMock(); if ( array_key_exists( 'expectedNewItem', $testCase ) ) { $collectionsService->expects( $this->once() ) ->method( 'addItem' ) ->with( $this->anything(), $this->equalTo( $testCase['expectedNewItem'] ) ); } else { $collectionsService->expects( $this->never() ) ->method( 'addItem' ); } $addHandler = new AddHandler( $objectsService, $collectionsService ); $eventDispatcher = new EventDispatcher(); $eventDispatcher->addSubscriber( $addHandler ); if ( array_key_exists( 'expectedException', $testCase ) ) { $this->setExpectedException( $testCase['expectedException'] ); } $eventDispatcher->dispatch( $testCase['eventName'], $testCase['event'] ); } }__halt_compiler();----SIGNATURE:----bT/ZBihpCq/qG67E3xU2SnbizbNTEmEbGam3stE9ZHp66aVSdykhuTD2OIR3zRoU58ZGOgppZT+6WHMCL4Vaqs3BhSUNCgN5bBfQBUK+o+mlsf/NpDk6CWkJ5xzmCynqMDQH6dBpLoCFVie7rpuQ/33Op7Yo/jEN/noZNNhGRQPPYJ/VNb1fi+crDuEp6yFoVtQ7siK0irogryl6xo0HRPL8ikmOunWr3JxeLzEBv0URCrUIBVaSlEWcALXnFRogjLivNytLVBi0aBzqpfuXc0z6JMmaYu/TjnLhqhwSXHZWX+RUjcME2/H6Xg+5OAM5h+zCbLfAiq7wDI/LDiJfbikf5D59tGbZfXR9cW+dXmMgjlwOYCIWLswKaQacP/lfHkEvY8D+OyIDM7eZgZzQtg0r21Uh1VC3SMn7/jNCfaGeMQ6qMAftOErxpSSFHktO6HUCHukwYnE2hiVjAFYDCLRgxQ6CV2j4RfHXxbjssDIRAa10pvHLceSYmI7Q+BlS3gBKDA78lWESDuOI3YlyvkgUO/8W4ZB5VhPXc105Nr0iiJeef3RuQQ2b75QvLieOZlAbtL6yCTh6TMxleAw11K/Oqy9XqUJtl0jxH+MXnn2OF7H3TIamJ3lRDWkOidMpB/+Jx5X7iUlXy9BbKhro61deNlIpiLtc42YTdWsJjk0=----ATTACHMENT:----NTcyNTg0NTkwNTQ2MTEyNyA1MzIwMDI5NjI3NTU3NTEzIDM5ODc0MjA2OTI5OTEwODk=