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:----0ZEA2rXh/6P2AWtK9/chaZ+CDo259JQ1e74AaN5ylLg5CSK7/IQ/qfFeBjcOqessw1KFAUxPBsW97PVSMjZQNsXgYzwaTCMCncVAbVMkKAJQY1okUn1fq1zYILsA/22Q+Y/vMqvskTgJh0k5ls18z3r4QPrlWKHSjM/+a1G9EnQNiMTR0Ji5kNGYujnuuhuB3l9mHbBfhfp5zxWHFO+u0Hd+98upbn52PNH7UVGzbbuZB/cWIBWe0zLQhTCILLoAwo+ynZX80D1viF1D/PmVD8jwH6/XxFRb5jK6952yIE5CbW1hVJD8JmZVFYZuZFu+pjbNYMIhIVuEfBHfmZ4R+vnhrD/Us/oqWTYGwu16Tky2q3UQEq9yASECBsu4Nc4T3DypMHVCZu5IgQ58WQhb6lxN16Ld+7MZoV1aPZ5Zr1zaD4sx6LAyUAO+nRq94sTMClcCh5dqy/OtpwGQM3nztXdihn22XiHBttTaN7A6E78wjos22zApZJVYcJdKM9fBSsicKj5kIYKPCO8HZf+ZvXuz6SkCuEQrbEiwnosw9e5DmXx65rc8HhsCphnwRoXpmgDiIAyxMQ7AAOo8A5MCu1ghWSraTSAeuFWd53k4KN/t9S5Odyxn4d0+HUeNGtek/raF/+pEeDQ1KdilIAO4tbHEXKUbaQaq5rMkMYxI0dY=----ATTACHMENT:----OTQ5NDE5MDQwOTIwODI2IDk4MjExMjMxMjc1MzAwODQgNjYwMTU3OTM2OTQyMzI1Nw==