コード例 #1
0
ファイル: manager_test.php プロジェクト: phpbb/phpbb
 private function create_cron_manager($tasks)
 {
     global $phpbb_root_path, $phpEx;
     $mock_config = new \phpbb\config\config(array('force_server_vars' => false, 'enable_mod_rewrite' => ''));
     $mock_router = $this->getMockBuilder('\\phpbb\\routing\\router')->setMethods(array('setContext', 'generate'))->disableOriginalConstructor()->getMock();
     $mock_router->method('setContext')->willReturn(true);
     $mock_router->method('generate')->willReturn('foobar');
     $request = new \phpbb\request\request();
     $request->enable_super_globals();
     $routing_helper = new \phpbb\routing\helper($mock_config, $mock_router, new \phpbb\symfony_request($request), $request, new \phpbb\filesystem\filesystem(), $phpbb_root_path, $phpEx);
     return new \phpbb\cron\manager($tasks, $routing_helper, $phpbb_root_path, $phpEx);
 }
コード例 #2
0
/**
* Wrapper function of \phpbb\request\request::variable which exists for backwards compatability.
* See {@link \phpbb\request\request_interface::variable \phpbb\request\request_interface::variable} for
* documentation of this function's use.
*
* @deprecated
* @param	mixed			$var_name	The form variable's name from which data shall be retrieved.
* 										If the value is an array this may be an array of indizes which will give
* 										direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a")
* 										then specifying array("var", 1) as the name will return "a".
* 										If you pass an instance of {@link \phpbb\request\request_interface phpbb_request_interface}
* 										as this parameter it will overwrite the current request class instance. If you do
* 										not do so, it will create its own instance (but leave superglobals enabled).
* @param	mixed			$default	A default value that is returned if the variable was not set.
* 										This function will always return a value of the same type as the default.
* @param	bool			$multibyte	If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters
*										Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
* @param	bool			$cookie		This param is mapped to \phpbb\request\request_interface::COOKIE as the last param for
* 										\phpbb\request\request_interface::variable for backwards compatability reasons.
* @param	\phpbb\request\request_interface|null|false	If an instance of \phpbb\request\request_interface is given the instance is stored in
*										a static variable and used for all further calls where this parameters is null. Until
*										the function is called with an instance it automatically creates a new \phpbb\request\request
*										instance on every call. By passing false this per-call instantiation can be restored
*										after having passed in a \phpbb\request\request_interface instance.
*
* @return	mixed	The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
* 					the same as that of $default. If the variable is not set $default is returned.
*/
function request_var($var_name, $default, $multibyte = false, $cookie = false, $request = null)
{
    // This is all just an ugly hack to add "Dependency Injection" to a function
    // the only real code is the function call which maps this function to a method.
    static $static_request = null;
    if ($request instanceof \phpbb\request\request_interface) {
        $static_request = $request;
        if (empty($var_name)) {
            return;
        }
    } else {
        if ($request === false) {
            $static_request = null;
            if (empty($var_name)) {
                return;
            }
        }
    }
    $tmp_request = $static_request;
    // no request class set, create a temporary one ourselves to keep backwards compatability
    if ($tmp_request === null) {
        // false param: enable super globals, so the created request class does not
        // make super globals inaccessible everywhere outside this function.
        $tmp_request = new \phpbb\request\request(new \phpbb\request\type_cast_helper(), false);
    }
    return $tmp_request->variable($var_name, $default, $multibyte, $cookie ? \phpbb\request\request_interface::COOKIE : \phpbb\request\request_interface::REQUEST);
}
コード例 #3
0
ファイル: run_test.php プロジェクト: phpbb/phpbb
 public function test_no_task_verbose()
 {
     $tasks = array();
     $mock_config = new \phpbb\config\config(array('force_server_vars' => false, 'enable_mod_rewrite' => ''));
     $mock_router = $this->getMockBuilder('\\phpbb\\routing\\router')->setMethods(array('setContext', 'generate'))->disableOriginalConstructor()->getMock();
     $mock_router->method('setContext')->willReturn(true);
     $mock_router->method('generate')->willReturn('foobar');
     $request = new \phpbb\request\request();
     $request->enable_super_globals();
     $routing_helper = new \phpbb\routing\helper($mock_config, $mock_router, new \phpbb\symfony_request($request), $request, new \phpbb\filesystem\filesystem(), $phpbb_root_path, $phpEx);
     $this->cron_manager = new \phpbb\cron\manager($tasks, $routing_helper, $phpbb_root_path, $phpEx);
     $command_tester = $this->get_command_tester();
     $exit_status = $command_tester->execute(array('command' => $this->command_name, '--verbose' => true));
     $this->assertContains('CRON_NO_TASK', $command_tester->getDisplay());
     $this->assertSame(0, $exit_status);
     $this->assertSame(false, $this->lock->owns_lock());
 }