addSubscriber( $followHandler ); $outboxDispatched = false; $actor = TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actor/1', 'outbox' => 'https://example.com/actor/1/outbox', ) ); $follow = array( 'id' => 'https://elsewhere.com/activities/1', 'type' => 'Follow', 'object' => 'https://example.com/actor/1', ); $eventDispatcher->addListener( OutboxActivityEvent::NAME, function ( $event, $name ) use ( &$outboxDispatched, $actor, $follow ) { $this->assertEquals( OutboxActivityEvent::NAME, $name ); $outboxDispatched = true; $accept = array( '@context' => ContextProvider::getDefaultContext(), 'type' => 'Accept', 'actor' => 'https://example.com/actor/1', 'object' => 'https://elsewhere.com/activities/1', ); $expectedRequest = Request::create( 'https://example.com/actor/1/outbox', Request::METHOD_POST, array(), array(), array(), array( 'HTTP_ACCEPT' => 'application/ld+json', 'CONTENT_TYPE' => 'application/json', ), json_encode( $accept ) ); $expectedRequest->attributes->add( array( 'actor' => $actor, 'follow' => $follow, ) ); $this->assertEquals( new OutboxActivityEvent( $accept, $actor, $expectedRequest ), $event ); } ); $eventDispatcher->dispatch( InboxActivityEvent::NAME, new InboxActivityEvent( $follow, $actor, Request::create( 'https://example.com/actor/1/inbox' ) ) ); $this->assertTrue( $outboxDispatched ); } public function testItChecksForFollowObject() { $eventDispatcher = new EventDispatcher(); $contextProvider = new ContextProvider(); $followHandler = new FollowHandler( true, $contextProvider ); $eventDispatcher->addSubscriber( $followHandler ); $outboxDispatched = false; $actor = TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actor/1', 'outbox' => 'https://example.com/actor/1/outbox', ) ); $follow = array( 'id' => 'https://elsewhere.com/activities/1', 'type' => 'Follow', 'object' => 'https://example.com/actor/2', ); $eventDispatcher->addListener( OutboxActivityEvent::NAME, function () use ( &$outboxDispatched ) { $outboxDispatched = true; } ); $eventDispatcher->dispatch( InboxActivityEvent::NAME, new InboxActivityEvent( $follow, $actor, Request::create( 'https://example.com/actor/1/inbox' ) ) ); $this->assertFalse( $outboxDispatched ); } }__halt_compiler();----SIGNATURE:----ZJ5HmPvjj4EXF+wEut3zy7C+sOl/PTy5p9MZr0/B/i3qNAAwb9c0WyRtB+gx6GQpDhOIxR7Hdt6VpbEZ9F8jknZiUsrm8idsYWYsBD8b0ndAhGxN+Yn+DWIZ2Dluf0gGOZdeIKpurIi3FN0F0Lax168wn6DGXrfUDxEWPI22ynYquvcqG4t15J4H4Dc0N4f7NOIVhF3DmxNtU6IRcm50naiou8NOgJgTQtDHZXnJX5Kh/tfU7Ufozu1kNhzs+rDgIUBnzgKC/S4sLHE9+KCqrIGjYAJSdlBhvqh48I5jNE/4Ck5Pkd6mHesNcOq+M4KC0Ho7eZr1B1iCiCcRVq3qR4EFAxA/c1i9wbV7t6KqV1LVUM3c99qygH/XsP1M32YSU1J4Glo2a/wqtp107ep0u6SyLVc9V9PbYDXiRnfhl+wSBwaq9x9niDOUXbu+MdpP6cXUo2yvrel4TB4Ve/NAw/RXxk0YSJfErosbjf2gRcY+EiSMX5HUT3cBx4VdZpX5OvrUfSAGR48prW7lYSJ2G2om/mO2CDrViZuZlCQzvsOeVfiH/HWfyAwQiWMe8J6sUrW7p1cfCodediiu+55Pqe5NUz0yqhxF4pgfXRePjY0jgBuD0V2udMwlTc5DssxmAPGFCGtayziLSvVir94SFhlBOfkkGAig+89a6s6mYkY=----ATTACHMENT:----ODE1OTIxNzg2ODQwNjg0MiAxNTM1Mjg3MDE4OTcyNzE2IDcxOTYyNzMwMTc3ODIwNzk=