Exemplo n.º 1
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');
 }
Exemplo n.º 2
0
	public function censor_text_data()
	{
		global $cache, $user;
		$cache = new phpbb_mock_cache;
		$user = new phpbb_mock_user;
		
		$user->optionset('viewcensors', false);

		return array(
			array('', ''),

			array('badword1', 'replacement1'),
			array(' badword1', ' replacement1'),
			array('badword1 ', 'replacement1 '),
			array(' badword1 ', ' replacement1 '),
			array('abadword1', 'replacement1'),
			array('badword1w', 'replacement1'),
			array('abadword1w', 'replacement1'),
			array('anotherbadword1test', 'replacement1'),
			array('this badword1', 'this replacement1'),
			array('this badword1 word', 'this replacement1 word'),

			array('badword2', 'replacement2'),
			array('bbadword2', 'replacement2'),
			array('bbbadword2', 'replacement2'),
			array('badword2d', 'badword2d'),
			array('bbadword2d', 'bbadword2d'),
			array('test badword2', 'test replacement2'),
			array('test badword2 word', 'test replacement2 word'),

			array('badword3', 'replacement3'),
			array('bbadword3', 'bbadword3'),
			array('badword3d', 'replacement3'),
			array('badword3ddd', 'replacement3'),
			array('bbadword3d', 'bbadword3d'),
			array(' badword3 ', ' replacement3 '),
			array(' badword3', ' replacement3'),

			array('badword4', 'replacement4'),
			array('this badword4 word', 'this replacement4 word'),
			array('abadword4', 'abadword4'),
			array('badword4d', 'badword4d'),
			array('abadword4d', 'abadword4d'),

			array('badword1 badword2 badword3 badword4', 'replacement1 replacement2 replacement3 replacement4'),
			array('badword1 badword2 badword3 badword4d', 'replacement1 replacement2 replacement3 badword4d'),
			array('abadword1 badword2 badword3 badword4', 'replacement1 replacement2 replacement3 replacement4'),
			
			array("new\nline\ntest", "new\nline\ntest"),
			array("tab\ttest\t", "tab\ttest\t"),
			array('öäü', 'öäü'),
			array('badw' . chr(1) . 'ord1', 'badw' . chr(1) . 'ord1'),
			array('badw' . chr(2) . 'ord1', 'badw' . chr(2) . 'ord1'),
			array('badw' . chr(3) . 'ord1', 'badw' . chr(3) . 'ord1'),
			array('badw' . chr(4) . 'ord1', 'badw' . chr(4) . 'ord1'),
			array('badw' . chr(5) . 'ord1', 'badw' . chr(5) . 'ord1'),
			array('badw' . chr(6) . 'ord1', 'badw' . chr(6) . 'ord1'),
		);
	}
 public function setUp()
 {
     global $cache, $user, $phpbb_dispatcher;
     parent::setUp();
     $cache = new phpbb_mock_cache();
     $user = new phpbb_mock_user();
     $user->optionset('viewcensors', false);
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
 }
Exemplo n.º 4
0
 /**
  * @dataProvider get_legacy_tests
  */
 public function test_legacy($original, $expected, $uid = '', $flags = 0)
 {
     global $cache, $user, $phpbb_dispatcher;
     $cache = new phpbb_mock_cache();
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
     $user = new phpbb_mock_user();
     $user->optionset('viewcensors', false);
     $return = generate_text_for_edit($original, $uid, $flags);
     $this->assertSame($expected, $return['text']);
 }
Exemplo n.º 5
0
 /**
  * @dataProvider view_log_function_data
  */
 public function test_view_log_function($expected, $expected_returned, $mode, $log_count, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '')
 {
     global $cache, $db, $user, $auth, $phpbb_log, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
     $db = $this->new_dbal();
     $cache = new phpbb_mock_cache();
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
     // Create auth mock
     $auth = $this->getMock('\\phpbb\\auth\\auth');
     $acl_get_map = array(array('f_read', 23, true), array('m_', 23, true));
     $acl_gets_map = array(array('a_', 'm_', 23, true));
     $auth->expects($this->any())->method('acl_get')->with($this->stringContains('_'), $this->anything())->will($this->returnValueMap($acl_get_map));
     $auth->expects($this->any())->method('acl_gets')->with($this->stringContains('_'), $this->anything())->will($this->returnValueMap($acl_gets_map));
     $user = new phpbb_mock_user();
     $user->optionset('viewcensors', false);
     // Test sprintf() of the data into the action
     $user->lang = array('LOG_INSTALL_INSTALLED' => 'installed: %s', 'LOG_USER' => 'User<br /> %s', 'LOG_MOD2' => 'Mod2', 'LOG_MOD3' => 'Mod3: %1$s, %2$s', 'LOG_SINGULAR_PLURAL' => array(1 => 'singular', 2 => 'plural (%d)'));
     $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
     $log = array();
     $this->assertEquals($expected_returned, view_log($mode, $log, $log_count, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords));
     $this->assertEquals($expected, $log);
 }