Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 55 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| controller | |
0.00% |
0 / 55 |
|
0.00% |
0 / 7 |
110 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| handle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| baz | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| template | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| exception | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| login_redirect | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| redirect | |
0.00% |
0 / 39 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace foo\bar\controller; |
| 4 | |
| 5 | use Symfony\Component\HttpFoundation\Response; |
| 6 | |
| 7 | class controller |
| 8 | { |
| 9 | protected $template; |
| 10 | protected $helper; |
| 11 | protected $path_helper; |
| 12 | protected $config; |
| 13 | protected $user; |
| 14 | |
| 15 | public function __construct(\phpbb\controller\helper $helper, \phpbb\path_helper $path_helper, \phpbb\template\template $template, \phpbb\config\config $config, \phpbb\user $user, $root_path, $php_ext) |
| 16 | { |
| 17 | $this->template = $template; |
| 18 | $this->helper = $helper; |
| 19 | $this->path_helper = $path_helper; |
| 20 | $this->config = $config; |
| 21 | $this->user = $user; |
| 22 | $this->root_path = $root_path; |
| 23 | $this->php_ext = $php_ext; |
| 24 | } |
| 25 | |
| 26 | public function handle() |
| 27 | { |
| 28 | return new Response('foo/bar controller handle() method', 200); |
| 29 | } |
| 30 | |
| 31 | public function baz($test) |
| 32 | { |
| 33 | return new Response('Value of "test" URL argument is: ' . $test); |
| 34 | } |
| 35 | |
| 36 | public function template() |
| 37 | { |
| 38 | $this->template->assign_var('A_VARIABLE', 'I am a variable'); |
| 39 | |
| 40 | return $this->helper->render('foo_bar_body.html'); |
| 41 | } |
| 42 | |
| 43 | public function exception() |
| 44 | { |
| 45 | throw new \phpbb\controller\exception('Exception thrown from foo/exception route'); |
| 46 | } |
| 47 | |
| 48 | public function login_redirect() |
| 49 | { |
| 50 | if (!$this->user->data['is_registered']) |
| 51 | { |
| 52 | login_box(); |
| 53 | } |
| 54 | |
| 55 | $this->template->assign_var('A_VARIABLE', 'I am a variable'); |
| 56 | |
| 57 | return $this->helper->render('foo_bar_body.html'); |
| 58 | } |
| 59 | |
| 60 | public function redirect() |
| 61 | { |
| 62 | $url_root = generate_board_url(); |
| 63 | |
| 64 | $rewrite_prefix = (!empty($this->config['enable_mod_rewrite'])) ? '' : 'app.php/'; |
| 65 | |
| 66 | $redirects = array( |
| 67 | array( |
| 68 | append_sid($this->root_path . 'index.' . $this->php_ext), |
| 69 | 'index.php', |
| 70 | ), |
| 71 | array( |
| 72 | append_sid($this->root_path . 'foo/bar/index.' . $this->php_ext), |
| 73 | 'foo/bar/index.php', |
| 74 | ), |
| 75 | array( |
| 76 | append_sid($this->root_path . 'tests/index.' . $this->php_ext), |
| 77 | 'tests/index.php', |
| 78 | ), |
| 79 | array( |
| 80 | $this->helper->route('foo_index_controller'), |
| 81 | $rewrite_prefix . 'index', |
| 82 | ), |
| 83 | array( |
| 84 | $this->helper->route('foo_tests_index_controller'), |
| 85 | $rewrite_prefix . 'tests/index', |
| 86 | ), |
| 87 | /** |
| 88 | * Symfony does not allow /../ in routes |
| 89 | array( |
| 90 | $this->helper->route('foo_tests_dotdot_index_controller'), |
| 91 | $rewrite_prefix . 'index', |
| 92 | ), |
| 93 | */ |
| 94 | ); |
| 95 | |
| 96 | foreach ($redirects as $redirect) |
| 97 | { |
| 98 | $this->template->assign_block_vars('redirects', array( |
| 99 | 'URL' => redirect($redirect[0], true), |
| 100 | )); |
| 101 | |
| 102 | $this->template->assign_block_vars('redirects_expected', array( |
| 103 | 'URL' => $this->path_helper->clean_url($url_root . '/' . $redirect[1]), |
| 104 | )); |
| 105 | } |
| 106 | |
| 107 | return $this->helper->render('redirect_body.html'); |
| 108 | } |
| 109 | } |