Beispiel #1
0
 /**
  * Set up the required user object and server variables for the suites
  */
 protected function setUp()
 {
     global $user, $phpbb_root_path, $phpEx, $request, $symfony_request, $phpbb_filesystem;
     // Put this into a global function being run by every test to init a proper user session
     $this->server['HTTP_HOST'] = 'localhost';
     $this->server['SERVER_NAME'] = 'localhost';
     $this->server['SERVER_ADDR'] = '127.0.0.1';
     $this->server['SERVER_PORT'] = 80;
     $this->server['REMOTE_ADDR'] = '127.0.0.1';
     $this->server['QUERY_STRING'] = '';
     $this->server['REQUEST_URI'] = '/tests/';
     $this->server['SCRIPT_NAME'] = '/tests/index.php';
     $this->server['SCRIPT_FILENAME'] = '/var/www/tests/index.php';
     $this->server['PHP_SELF'] = '/tests/index.php';
     $this->server['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14';
     $this->server['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
     /*
     		[HTTP_ACCEPT_ENCODING] => gzip,deflate
     		[HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
     		DOCUMENT_ROOT] => /var/www/
     		[SCRIPT_FILENAME] => /var/www/tests/index.php
     */
     $request = new phpbb_mock_request(array(), array(), array(), $this->server);
     $symfony_request = new \phpbb\symfony_request($request);
     $phpbb_filesystem = new \phpbb\filesystem();
     // Set no user and trick a bit to circumvent errors
     $user = new \phpbb\user('\\phpbb\\datetime');
     $user->lang = true;
     $user->browser = $this->server['HTTP_USER_AGENT'];
     $user->referer = '';
     $user->forwarded_for = '';
     $user->host = $this->server['HTTP_HOST'];
     $user->page = \phpbb\session::extract_current_page($phpbb_root_path);
 }
 /**
  * @dataProvider security_variables
  */
 public function test_query_string_request_uri($query_string, $expected)
 {
     global $symfony_request, $request;
     $this->server['QUERY_STRING'] = $query_string;
     $request = new phpbb_mock_request(array(), array(), array(), $this->server);
     $symfony_request = new \phpbb\symfony_request($request);
     $result = \phpbb\session::extract_current_page('./');
     $label = 'Running extract_current_page on ' . $query_string . ' with REQUEST_URI filled.';
     $this->assertEquals($expected, $result['query_string'], $label);
 }
Beispiel #3
0
 /** @dataProvider extract_current_page_data */
 function test_extract_current_page($root_path, $getScriptName, $getQueryString, $getBasePath, $getPathInfo, $expected)
 {
     global $symfony_request, $request, $phpbb_filesystem;
     $phpbb_filesystem = new \phpbb\filesystem\filesystem();
     $server['HTTP_HOST'] = 'localhost';
     $server['SERVER_NAME'] = 'localhost';
     $server['SERVER_ADDR'] = '127.0.0.1';
     $server['SERVER_PORT'] = 80;
     $server['REMOTE_ADDR'] = '127.0.0.1';
     $server['QUERY_STRING'] = $getQueryString;
     $server['REQUEST_URI'] = $getScriptName . $getPathInfo . ($getQueryString === '' ? '' : '?' . $getQueryString);
     $server['SCRIPT_NAME'] = $getScriptName;
     $server['SCRIPT_FILENAME'] = '/var/www/' . $getScriptName;
     $server['PHP_SELF'] = $getScriptName;
     $server['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14';
     $server['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
     $request = new phpbb_mock_request(array(), array(), array(), $server);
     $symfony_request = new \phpbb\symfony_request($request);
     $output = \phpbb\session::extract_current_page($root_path);
     // This compares the result of the output.
     // Any keys that are not in the expected array are overwritten by the output (aka not checked).
     $this->assert_array_content_equals(array_merge($output, $expected), $output);
 }