/**
  * Setup test environment
  */
 public function setUp()
 {
     parent::setUp();
     global $phpbb_dispatcher;
     $this->db = $this->new_dbal();
     $this->phpbb_container = new \phpbb_mock_container_builder();
     $this->config = new \phpbb\config\config(array('notification_pull_time' => 60));
     // TBD
     $auth = $this->getMock('\\phpbb\\auth\\auth');
     $cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), $this->config, $this->db, $phpbb_root_path, $phpEx);
     $user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, USERS_TABLE);
     // Event dispatcher
     $phpbb_dispatcher = new \phpbb_mock_event_dispatcher();
     // Notification Types
     $notification_types = array('pm');
     $notification_types_array = array();
     foreach ($notification_types as $type) {
         $class_name = '\\phpbb\\notification\\type\\' . $type;
         $class = new $class_name($user_loader, $this->db, $cache->get_driver(), $user, $auth, $this->config, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
         $this->phpbb_container->set('notification.type.' . $type, $class);
         $notification_types_array['notification.type.' . $type] = $class;
     }
     // Notification Manager
     $this->phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(), $this->phpbb_container, $user_loader, $this->config, $phpbb_dispatcher, $this->db, $cache, $user, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
 }
Пример #2
0
 /**
  * Setup test environment
  */
 public function setUp()
 {
     parent::setUp();
     global $phpbb_dispatcher;
     $this->db = $this->new_dbal();
     $this->phpbb_container = new \phpbb_mock_container_builder();
     $this->config = new \phpbb\config\config(array('notification_pull_time' => 60));
     // TBD
     $auth = $this->getMock('\\phpbb\\auth\\auth');
     $cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), $this->config, $this->db, $phpbb_root_path, $phpEx);
     $user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, USERS_TABLE);
     // Event dispatcher
     $phpbb_dispatcher = new \phpbb_mock_event_dispatcher();
     // Notification Types
     $notification_types = array('pm');
     $notification_types_array = array();
     foreach ($notification_types as $type) {
         $class_name = '\\phpbb\\notification\\type\\' . $type;
         $class = new $class_name($user_loader, $this->db, $cache->get_driver(), $user, $auth, $this->config, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
         $this->phpbb_container->set('notification.type.' . $type, $class);
         $notification_types_array['notification.type.' . $type] = $class;
     }
     // Notification Manager
     $this->phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(), $this->phpbb_container, $user_loader, $this->config, $phpbb_dispatcher, $this->db, $cache, $user, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
     $user = new \phpbb_mock_user();
     $user->optionset('viewcensors', false);
     $user->style['style_path'] = 'prosilver';
     $this->user = $this->getMock('\\phpbb\\user', array(), array('\\phpbb\\datetime'));
     $this->template = $this->getMockBuilder('\\phpbb\\template\\template')->getMock();
     $phpbb_container = new \phpbb_mock_container_builder();
     $phpbb_container->set('path_helper', $phpbb_path_helper);
     $this->controller_helper = $this->getMockBuilder('\\phpbb\\controller\\helper')->disableOriginalConstructor()->getMock();
     $this->request = $this->getMock('\\phpbb\\request\\request');
 }
Пример #3
0
 public function setUp()
 {
     parent::setUp();
     global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path;
     // Database
     $this->db = $this->new_dbal();
     $db = $this->db;
     // Auth
     $auth = $this->getMock('\\phpbb\\auth\\auth');
     $auth->expects($this->any())->method('acl_get')->with($this->stringContains('_'), $this->anything())->will($this->returnValueMap(array(array('f_noapprove', 1, true), array('f_postcount', 1, true), array('m_edit', 1, false))));
     // Config
     $config = new \phpbb\config\config(array('num_topics' => 1, 'num_posts' => 1));
     $cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), $config, $db, $phpbb_root_path, $phpEx);
     // Event dispatcher
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
     // User
     $user = $this->getMock('\\phpbb\\user', array(), array(new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), '\\phpbb\\datetime'));
     $user->ip = '';
     $user->data = array('user_id' => 2, 'username' => 'user-name', 'is_registered' => true, 'user_colour' => '');
     // Request
     $type_cast_helper = $this->getMock('\\phpbb\\request\\type_cast_helper_interface');
     $request = $this->getMock('\\phpbb\\request\\request');
     // Container
     $phpbb_container = new phpbb_mock_container_builder();
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
     $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
     $user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
     // Notification Types
     $notification_types = array('quote', 'bookmark', 'post', 'post_in_queue', 'topic', 'topic_in_queue', 'approve_topic', 'approve_post');
     $notification_types_array = array();
     foreach ($notification_types as $type) {
         $class_name = '\\phpbb\\notification\\type\\' . $type;
         $class = new $class_name($user_loader, $db, $cache->get_driver(), $user, $auth, $config, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
         if ($type === 'quote') {
             $class->set_utils(new \phpbb\textformatter\s9e\utils());
         }
         $phpbb_container->set('notification.type.' . $type, $class);
         $notification_types_array['notification.type.' . $type] = $class;
     }
     // Notification Manager
     $phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(), $phpbb_container, $user_loader, $config, $phpbb_dispatcher, $db, $cache, $user, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
     $phpbb_container->set('notification_manager', $phpbb_notifications);
 }