objectsService = $this->getMock( ObjectsService::class ); $this->objectsService->method( 'dereference' )->will( $this->returnValueMap( array( array( 'https://example.com/actor/1', TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actor/1', ) ) ), array( 'https://example.com/actor/2', TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actor/2', ) ) ), ) ) ); } public function provideTestAuthListener() { return array( array( array( 'id' => 'basicTest', 'authFunction' => function () { return 'https://example.com/actor/1'; }, 'expectedAttributes' => array( 'actor' => TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actor/1', ) ), ), ) ), array( array( 'id' => 'existingActorTest', 'authFunction' => function () { return 'https://example.com/actor/1'; }, 'requestAttributes' => array( 'actor' => TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actor/2', ) ), ), 'expectedAttributes' => array( 'actor' => TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actor/2', ) ), ), ) ), array( array( 'id' => 'defaultAuthTest', 'authFunction' => function () { return false; }, 'expectedAttributes' => array(), ) ), ); } /** * @dataProvider provideTestAuthListener */ public function testAuthListener($testCase) { $event = $this->getEvent(); if ( array_key_exists( 'requestAttributes', $testCase ) ) { foreach ( $testCase['requestAttributes'] as $attribute => $value ) { $event->getRequest()->attributes->set( $attribute, $value ); } } $authListener = new AuthListener( $testCase['authFunction'], $this->objectsService ); $authListener->checkAuth( $event ); foreach ( $testCase['expectedAttributes'] as $expectedKey => $expectedValue ) { $this->assertTrue( $event->getRequest()->attributes->has( $expectedKey ), "Error on test $testCase[id]" ); if ( $expectedValue instanceof ActivityPubObject ) { $this->assertTrue( $expectedValue->equals( $event->getRequest()->attributes->get( $expectedKey ) ), "Error on test $testCase[id]" ); } else { $this->assertEquals( $expectedValue, $event->getRequest()->attributes->get( $expectedKey ), "Error on test $testCase[id]" ); } } } public function getEvent() { $kernel = $this->getMock( HttpKernelInterface::class ); $request = Request::create( 'https://example.com/foo', Request::METHOD_GET ); return new GetResponseEvent( $kernel, $request, HttpKernelInterface::MASTER_REQUEST ); } }__halt_compiler();----SIGNATURE:----KLcrrB0dEb5p+lhxJovOmVJvziatuxU1fIf0WC3RnM4BrvAt3LQUbsbZ0OVUkDT3/e0UzQZgKLoD+ItSlLbBcQekuNyr+OZxmCgDQ2vSetoj3ABO9Njii52Q74XdtNk8SP8l/uFkXdo+IIhvmcGg3WCdVYFbuoJChZB43DtdLEYf0y/vxp3/jAePXqZCSe32vVkQ+MEGhNFv1w0d7Ly7p2zip2ybQeyD1dgrQs76/+bub81YQ5pM2DqZvhLbcpthGEYwUph9JGm5tCrX4WRW+QT2A+2QVqS8zU1buFLGsLdkLMEHC7lMMUpIfnnIwX633UOkGlNz0SbQbrJ3aH8r2DJl07AHWQlHI8gXoiOvFFTRvLdvLnaKdt1feYbgZFfBjHozcgJu+/UGGF35spS4HAPK+WNClI0uNGTQUCIAR7pXPvTQECeLTNpeqcFmRWlL8yCYXuF5yhW1z5LlnJ6Wi2b7NYq8wDozFKYdV76cY6AVCEUN8n392IEs4lfsNiK3QBa7Nv+QS5s/gzAf2YXXw8nXHwVknCuvsJ6BTLBm3y8QsrlFdPWo6d6A3d76K6Tt+e80Q57Loh9lMBj9yrxXICedr3FIXuJ/8RL88TT6FdcuzbC9B2iNEPGsPOiaywb96r6D0pC6rxlO4jMBtR7NwvQowDJ3IlWJ9wqJ8A05zww=----ATTACHMENT:----MzYxNTMwMDkyMzk5MjkwNCA4MjM2NjUzNTY4NTA0NTQyIDg0NjgzODc2MzM0NjExNTQ=