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:----HFOy7U8G1MDv19i1vNwMIt8n7OYn/4NDWG26xv2Uo4E4Y4YjrbnOG8wqp++WlMDWU1FqqknXnZ02loqlmVkms+NXXJxiYlalJRxJ0G1RHxQF5Q17kACsg0CUPGvNNdWfp6HcLrlTNpiLb14wLQSAOz/Om4bC1ri3E98pC5xtPVMUH3KKPBkS0qA3mxzdZx+9Y2fg+lNOy0bQ4SXwLywRhArghDzk2v2UiHRwokWv2OJkJHpitw72n7xGfae4thXL2awbUpV6H1abLaD++4RXSHedrkY8rw9Iy+cBtMzKZQgGmW627MSkAVl2k/GypWlJ16lslH9jlD/vTJWVS0Qw+iuciqpBv/DTVA+eEPyGPEF02EYxyanf4vnGTeMLAJj8KHHIriHd8ExoMQnDMEiznBra3dKo7J2zKQr+Brtcj2jBSNc0zmDn2XUwTEQ+xuU4OCZ+ZQjk1AyikCBhRt+cafe+l9ZHK3Q3DYmM4HRlbMCLpE9ecWst3I39AeGdv3sSGzLuZu9WJnIKR8R80GJoSm60Ns2Acj4I24cuvV6wi6crw+W88Tf4JjhpnTZ4qBcofhLU/LdogjLq+gWdjNQyIydmAEyHOo1VbZlF5FZPrqbBd1yxH8u/jej6ttKBbZcrWRJzfNZ/JLcJVSKt4cWTjFXMOm+BCEm7JvB4bmU6LlQ=----ATTACHMENT:----OTY3NjM4NjU3Mzg4Mzg4MCA2Njg1NzM2NjYyODgyNDYxIDU0NjQ0OTI1MTQxODgwNTM=