eventDispatcher = new EventDispatcher(); $validationHandler = new ValidationHandler(); $this->eventDispatcher->addSubscriber( $validationHandler ); } public function provideTestValidationHandler() { return array( array( array( 'id' => 'inboxRequiredFields', 'eventName' => InboxActivityEvent::NAME, 'event' => new InboxActivityEvent( array(), TestActivityPubObject::fromArray( array( 'id' => 'https://notexample.com/actor/1', 'type' => 'Person', ) ), Request::create( 'https://example.com' ) ), 'expectedException' => BadRequestHttpException::class, 'expectedExceptionMessage' => 'Missing activity fields: type,id,actor', ) ), array( array( 'id' => 'outboxRequiredFields', 'eventName' => OutboxActivityEvent::NAME, 'event' => new OutboxActivityEvent( array(), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actor/1', 'type' => 'Person', ) ), Request::create( 'https://example.com' ) ), 'expectedException' => BadRequestHttpException::class, 'expectedExceptionMessage' => 'Missing activity fields: type,actor', ) ), array( array( 'id' => 'inboxPassesValidActivity', 'eventName' => InboxActivityEvent::NAME, 'event' => new InboxActivityEvent( array( 'id' => 'https://notexample.com/activity/1', 'type' => 'Create', 'actor' => 'https://notexample.com/actor/1', 'object' => array( 'type' => 'Note', ), ), TestActivityPubObject::fromArray( array( 'id' => 'https://notexample.com/actor/1', 'type' => 'Person', ) ), Request::create( 'https://example.com' ) ), ) ), array( array( 'id' => 'outboxPassesValidActivity', 'eventName' => OutboxActivityEvent::NAME, 'event' => new OutboxActivityEvent( array( 'type' => 'Create', 'actor' => 'https://example.com/actor/1', 'object' => array( 'type' => 'Note', ), ), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actor/1', 'type' => 'Person', ) ), Request::create( 'https://example.com' ) ), ) ), array( array( 'id' => 'outboxRequiresObjectFields', 'eventName' => OutboxActivityEvent::NAME, 'event' => new OutboxActivityEvent( array( 'id' => 'https://example.com/creates/1', 'type' => 'Create', 'actor' => 'https://example.com/actor/1', ), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actor/1', 'type' => 'Person', ) ), Request::create( 'https://example.com' ) ), 'expectedException' => BadRequestHttpException::class, 'expectedExceptionMessage' => 'Missing activity fields: object', ) ), array( array( 'id' => 'inboxRequiresObjectFields', 'eventName' => InboxActivityEvent::NAME, 'event' => new InboxActivityEvent( array( 'id' => 'https://elsewhere.com/activities/1', 'type' => 'Create', 'actor' => 'https://elsewhere.com/actors/1' ), TestActivityPubObject::fromArray( array( 'id' => 'https://notexample.com/actor/1', 'type' => 'Person', ) ), Request::create( 'https://example.com' ) ), 'expectedException' => BadRequestHttpException::class, 'expectedExceptionMessage' => 'Missing activity fields: object', ) ), array( array( 'id' => 'inboxRequiresTargetFields', 'eventName' => InboxActivityEvent::NAME, 'event' => new InboxActivityEvent( array( 'id' => 'https://elsewhere.com/activities/1', 'actor' => 'https://elsewhere.com/actors/1', 'object' => 'https://elsewhere.com/collections/1', 'type' => 'Add', ), TestActivityPubObject::fromArray( array( 'id' => 'https://notexample.com/actor/1', 'type' => 'Person', ) ), Request::create( 'https://example.com' ) ), 'expectedException' => BadRequestHttpException::class, 'expectedExceptionMessage' => 'Missing activity fields: target', ) ), array( array( 'id' => 'outboxRequiresTargetFields', 'eventName' => OutboxActivityEvent::NAME, 'event' => new OutboxActivityEvent( array( 'id' => 'https://example.com/activities/1', 'object' => 'https://example.com/collections/1', 'type' => 'Remove', 'actor' => 'https://example.com/actor/1', ), TestActivityPubObject::fromArray( array( 'id' => 'https://example.com/actor/1', 'type' => 'Person', ) ), Request::create( 'https://example.com' ) ), 'expectedException' => BadRequestHttpException::class, 'expectedExceptionMessage' => 'Missing activity fields: target', ) ), ); } /** * @dataProvider provideTestValidationHandler */ public function testValidationHandler($testCase) { $event = $testCase['event']; if ( array_key_exists( 'expectedException', $testCase ) ) { $expectedExceptionMessage = ''; if ( array_key_exists( 'expectedExceptionMessage', $testCase ) ) { $expectedExceptionMessage = $testCase['expectedExceptionMessage']; } $this->setExpectedException( $testCase['expectedException'], $expectedExceptionMessage ); } $this->eventDispatcher->dispatch( $testCase['eventName'], $event ); } }__halt_compiler();----SIGNATURE:----fuTKiXz5F1pDIJ7xA0KBhudETB0ow/hakDGWuzJiZ03vVUlsKBWi7Be2JeqT6v1pnIzvJ1xt5XhaaWMJSMa03kpDpHo6Ah7DkamzR7ZGZeCwFYXfU+gS0IgqCjFmbJpYS/VhyehU1OTzIXW9WwAeIOEwzRnpnOCKDHqjO2VC+7LuN1g3m8faCM+/Elex1oMM3h7wWPbdpQBC1V0e5uBtg5Iculncdn14/VpCB4xca0P68TpXpgVAqi7ioZGsVfZddj1rjNQoXYDtMuW6B5v2DRGwBZzgsMEU0tQLIxw0+NxajY3++dCm+oNmLD0+p4w4hBA6IFMhXyZ/8CUIOD6Ns1qJVWBUCRl9SoceEnpg7TSyofmCr8E9ALOr64RIwHyWyj7zcRAkcFU13NW0rLYYc0w4ipay7EnUuyGnQo/CbWAcYpEEBgbWE+YszKQd9UbUacWbY6mDaYzQ4nHOyCcIU0LWBX2uXwLXIwG8w5v5xrxkKbcpafDDrN9uUklN6epTQewzIT92WDM6sNzoCamkTHrHh7F1pdlr2vTz6yr8Zt3LNI1EefOeAQRvpPbceJfywUeUI7biuaBa4wKgpjSnSFRqbFzj+So8PrG9oMJRCTB3OnnQX9X+y2twkyRtmo6U6gUL9vg6x1bL4NJYB+Xex/mlCZ4sKWni6ZoK8emRyME=----ATTACHMENT:----MjM0NDc4MjA5OTA4MTg0MyAyMTEyMTUzMjUyNTMwODkzIDUwMzc1ODI2MTQ0NDM0ODM=