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:----HUMuLcgXJG+KFpnM0zYkNi8JqdVs5A7pyWnfBgZNoSQifufXSpwYhdIQUpqBveMZui4GH+gmj0f6ceqlxAP1saA03c2JQV1jITfZsFgy5S2/VXMLNtsG9yZWbyXex+PJhwtCzC/XsGtTRf8XrmZh7RlH60/ErtwQqHHyjpjxdyPJjfEV3sPQE91gih5NwwMupVxhkLrNEYdWR54pn+misa3+JQlvk0Wdwsf2A8u4hfr728U96FQ/vt5jjazBC6EtsFVgWXLL9dPnboE1FucszcAj6BfF/RFh88PdC6LnFz/b893YCY9CY8kdu+ePtw+XmlhkH0YD6BS8rKXDXAgp9YAbbRyuz5nEOhlfYk8KV8e8wTGBe+DVyqUIRlL6LsQ9wp7a9gjOOjPY3Be3resPGMFS65l0Nb9fROvCVW2EtHXv8i0804ljxbuVFNr06PJ6l9HVlXdl8KOIviR6CadxBxYWdVXGcSv7qVo3BVcJ7wv/zJJQW/K38mCf5qf6MsCoAErkGpQFlvGDwtrs8UkUPgPZxokwvEq2eYhF9QabK6E74NT2F7hilSiihRDw5dQPgmGXoV/G/gn3t151jgaMKTOTDG91XFs/SNb9LUKbuJPjQwkh/f9hiCCkf5GkYWBqt2GGJz/Ap1BeZ408ydw9aCJ1FL27DXM8KLFN7lR/Cuc=----ATTACHMENT:----NTYwOTg5NzY1OTQ3NTMwMyA2ODYyMTQ1MDgzMjkzOTA2IDYzMjE2OTkwODU3MTY5NTg=