Пример #1
0
 /**
  *
  */
 private function ping()
 {
     try {
         $response = $this->dispatcher->dispatch('utility.ping', new Expressly\Event\ResponseEvent());
     } catch (Exception $e) {
     }
 }
Пример #2
0
 /**
  * Visits & tests StepNode.
  *
  * @param   Behat\Gherkin\Node\AbstractNode $step
  *
  * @return  integer
  */
 public function visit(AbstractNode $step)
 {
     $step->setTokens($this->tokens);
     $this->dispatcher->dispatch('beforeStep', new StepEvent($step, $this->context));
     $afterEvent = $this->executeStep($step);
     $this->dispatcher->dispatch('afterStep', $afterEvent);
     return $afterEvent->getResult();
 }
Пример #3
0
 /**
  * Test default_configs
  *
  * @dataProvider default_configs_data
  */
 public function test_default_configs($allow, $require, $registered, $is_bot, $expected)
 {
     $this->config['allow_birthdays'] = $allow;
     $this->config['birthday_require'] = $require;
     $this->set_listener();
     $this->template->expects($this->exactly($expected))->method('assign_vars');
     $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
     $dispatcher->addListener('core.user_setup', array($this->listener, 'default_configs'));
     $event_data = array('user_data' => array('is_bot' => $is_bot, 'is_registered' => $registered));
     $event = new \phpbb\event\data(compact($event_data));
     $dispatcher->dispatch('core.user_setup', $event);
 }
 /**
  * @dataProvider post_auth_data
  */
 public function test_post_auth($auth_data, $event_data, $expected_result_data)
 {
     // Modify auth
     $this->auth->expects($this->any())->method('acl_get')->with($this->stringContains('_'), $this->anything())->will($this->returnValueMap($auth_data));
     // fetch listener
     $listener = $this->get_listener();
     // Create Events
     $event = new \Symfony\Component\EventDispatcher\GenericEvent(null, $event_data);
     $expected_result = new \Symfony\Component\EventDispatcher\GenericEvent(null, $expected_result_data);
     // Dispatch
     $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
     $dispatcher->addListener('gn36.def_listen', array($listener, 'post_auth'));
     $dispatcher->dispatch('gn36.def_listen', $event);
     // Modify expected result event to mimic correct dispatch data
     $expected_result->setDispatcher($dispatcher);
     $expected_result->setName('gn36.def_listen');
     // Check
     $this->assertEquals($expected_result, $event);
 }
Пример #5
0
 /**
  * Test the setup
  *
  * @dataProvider setup_data
  */
 public function test_setup($user_id, $is_reg, $is_bot, $pull_time, $expected, $last_n, $time_n)
 {
     $this->user->data['user_id'] = $user_id;
     $this->user->data['is_registered'] = $is_reg;
     $this->user->data['is_bot'] = $is_bot;
     $this->config['notification_pull_time'] = $pull_time;
     $this->config['enable_mod_rewrite'] = false;
     $this->config['cookie_domain'] = 'localhost';
     $this->config['cookie_name'] = 'phpbb3_asd_obj';
     $this->config['cookie_path'] = '/';
     $this->set_listener();
     if ($expected > 0) {
         $this->template->expects($this->exactly($expected))->method('assign_vars')->with(array('ACTIVE_NOTIFICATION_LAST' => $last_n, 'ACTIVE_NOTIFICATION_TIME' => $time_n, 'ACTIVE_NOTIFICATION_URL' => false, 'ACTIVE_NOTIFICATIONS_COOKIE_DOMAIN' => 'localhost', 'ACTIVE_NOTIFICATIONS_COOKIE_NAME' => 'phpbb3_asd_obj_an', 'ACTIVE_NOTIFICATIONS_COOKIE_PATH' => '/'));
     } else {
         $this->template->expects($this->exactly(0))->method('assign_vars');
     }
     $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
     $dispatcher->addListener('core.page_header', array($this->listener, 'setup'));
     $dispatcher->dispatch('core.page_header');
 }
Пример #6
0
$listener['whisnet_irc_bot.bot_command_info'] = array(new \Whisnet\IrcBotBundle\EventListener\Plugins\Commands\InfoCommandListener($ircConnection), 'onCommand');
$listener['whisnet_irc_bot.bot_command_datetime'] = array(new \Whisnet\IrcBotBundle\EventListener\Plugins\Commands\DateTimeCommandListener($ircConnection), 'onCommand');
$seenCommandListener = new \Whisnet\IrcBotBundle\EventListener\Plugins\Commands\SeenCommandListener($ircConnection);
$seenCommandListener->setCacheDir(__DIR__ . '/cache');
$listener['whisnet_irc_bot.bot_command_seen'] = array($seenCommandListener, 'onCommand');
$listener['whisnet_irc_bot.irc_command_PRIVMSG'] = array($seenCommandListener, 'onUpdateInformation');
$helpCommandListener = new \Whisnet\IrcBotBundle\EventListener\Plugins\Commands\HelpCommandListener($ircConnection);
$helpList = new SplDoublyLinkedList();
$helpList[] = array('command' => 'seen', 'arguments' => '$nick');
$helpList[] = array('command' => 'karma', 'arguments' => '$topic');
$helpList[] = array('command' => 'info');
$helpCommandListener->setConfig($commandPrefix, $helpList);
$listener['whisnet_irc_bot.bot_command_help'] = array($helpCommandListener, 'onCommand');
foreach ($listener as $eventName => $eventHandler) {
    $eventDispatcher->addListener($eventName, $eventHandler, 20);
}
$karmaCommandListener = new \KarmaCommandListener($ircConnection);
$karmaCommandListener->setCacheDir(__DIR__ . '/cache');
$eventDispatcher->addListener('whisnet_irc_bot.bot_command_karma', array($karmaCommandListener, 'onCommand'), 30);
$eventDispatcher->addListener('whisnet_irc_bot.irc_command_PRIVMSG', array($karmaCommandListener, 'onUpdateInformation'), 30);
$ircConnection->connect();
do {
    try {
        $eventDispatcher->dispatch('whisnet_irc_bot.data_from_server', new \Whisnet\IrcBotBundle\Event\DataFromServerEvent(\Whisnet\IrcBotBundle\Utils\Utils::cleanUpServerRequest($ircConnection->getData())));
    } catch (ErrorException $e) {
        echo $e->getSeverity() . ': ' . $e->getMessage();
        sleep(5);
        $ircConnection->connect();
    }
    /**/
} while (true);
Пример #7
0
 /**
  * Test events
  *
  * @dataProvider gallery_link_in_profile_data
  * profile_fileds
  * get_user_ids
  */
 public function test_gallery_link_events($option, $user_id, $expect)
 {
     $this->config['phpbb_gallery_profile_pega'] = $option;
     $user_ids = array($user_id);
     $event_data = array('user_ids');
     $event_one = new \phpbb\event\data(compact($event_data));
     $profile_row = array();
     $event_two_data = array('profile_row');
     $event_two = new \phpbb\event\data(compact($event_two_data));
     $this->set_listener();
     $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
     $dispatcher->addListener('core.grab_profile_fields_data', array($this->listener, 'get_user_ids'));
     $dispatcher->addListener('core.generate_profile_fields_template_data_before', array($this->listener, 'profile_fileds'));
     $dispatcher->dispatch('core.grab_profile_fields_data', $event_one);
     $dispatcher->dispatch('core.generate_profile_fields_template_data_before', $event_two);
     $ouput = $event_two->get_data_filtered($event_two_data);
     $expacted = array('phpbb_gallery' => array('value' => array('album_id' => 1), 'data' => array('field_id' => '', 'lang_id' => '', 'lang_name' => 'GALLERY', 'lang_explain' => '', 'lang_default_value' => '', 'field_name' => 'phpbb_gallery', 'field_type' => 'profilefields.type.url', 'field_ident' => 'phpbb_gallery', 'field_length' => '40', 'field_minlen' => '12', 'field_maxlen' => '255', 'field_novalue' => '', 'field_default_value' => '', 'field_validation' => '', 'field_required' => '0', 'field_show_on_reg' => '0', 'field_hide' => '0', 'field_no_view' => '0', 'field_active' => '1', 'field_order' => '', 'field_show_profile' => '1', 'field_show_on_vt' => '1', 'field_show_novalue' => '0', 'field_show_on_pm' => '1', 'field_show_on_ml' => '1', 'field_is_contact' => '1', 'field_contact_desc' => 'VISIT_GALLERY', 'field_contact_url' => '%s')));
     if ($expect) {
         $this->assertEquals($expacted, $ouput['profile_row']);
     } else {
         $this->assertEmpty($ouput['profile_row']);
     }
 }
Пример #8
0
 /**
  * @see EventDispatcherInterface::dispatch()
  *
  * @api
  */
 public static function dispatch($eventName, Symfony\Component\EventDispatcher\Event $event = null)
 {
     return static::$instance->dispatch($eventName, $event);
 }