Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 24
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
phpbb_functional_controllers_compatibility_test
0.00% covered (danger)
0.00%
0 / 24
0.00% covered (danger)
0.00%
0 / 4
30
0.00% covered (danger)
0.00%
0 / 1
 test_report_compatibility
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 test_feed_compatibility
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
 test_cron_compatibility
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 assert301
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14/**
15* @group functional
16*/
17
18class phpbb_functional_controllers_compatibility_test extends phpbb_functional_test_case
19{
20    public function test_report_compatibility()
21    {
22        $this->assert301('report.php?f=1&p=1', 'app.php/post/1/report');
23        $this->assert301('report.php?p=1', 'app.php/post/1/report');
24        $this->assert301('report.php?pm=1', 'app.php/pm/1/report');
25    }
26
27    public function test_feed_compatibility()
28    {
29        $this->assert301('feed.php', 'app.php/feed');
30        $this->assert301('feed.php?mode=foobar', 'app.php/feed/foobar');
31        $this->assert301('feed.php?mode=news', 'app.php/feed/news');
32        $this->assert301('feed.php?mode=topics', 'app.php/feed/topics');
33        $this->assert301('feed.php?mode=topics_news', 'app.php/feed/topics_news');
34        $this->assert301('feed.php?mode=topics_active', 'app.php/feed/topics_active');
35        $this->assert301('feed.php?mode=forums', 'app.php/feed/forums');
36        $this->assert301('feed.php?f=1', 'app.php/feed/forum/1');
37        $this->assert301('feed.php?t=1', 'app.php/feed/topic/1');
38    }
39
40    public function test_cron_compatibility()
41    {
42        $this->assert301('cron.php?cron_type=foo', 'app.php/cron/foo');
43        $this->assert301('cron.php?cron_type=foo&bar=foobar', 'app.php/cron/foo?bar=foobar');
44        $this->assert301('cron.php?cron_type=foo&bar=foobar&who=me', 'app.php/cron/foo?bar=foobar&who=me');
45    }
46
47    protected function assert301($from, $to)
48    {
49        self::$client->followRedirects(false);
50        self::request('GET', $from, array(), false);
51
52        // Fix sid issues
53        $location = self::$client->getResponse()->getHeader('Location');
54        $location = str_replace('&amp;', '&', $location);
55        $location = preg_replace('#sid=[^&]+(&(amp;)?)?#', '', $location);
56        if (substr($location, -1) === '?')
57        {
58            $location = substr($location, 0, -1);
59        }
60
61        $this->assertEquals(301, self::$client->getResponse()->getStatusCode());
62        $this->assertStringEndsWith($to, $location);
63    }
64}