forked from phpbb-extensions/pages
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage_loader_core_test.php
More file actions
71 lines (61 loc) · 1.7 KB
/
Copy pathpage_loader_core_test.php
File metadata and controls
71 lines (61 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
*
* Pages extension for the phpBB Forum Software package.
*
* @copyright (c) 2025 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace phpbb\pages\tests\routing;
class page_loader_core_test extends \phpbb_database_test_case
{
protected static function setup_extensions()
{
return array('phpbb/pages');
}
/** @var \phpbb\db\driver\driver_interface */
protected $db;
/** @var \phpbb\pages\routing\page_loader_core */
protected $loader;
public function getDataSet()
{
return $this->createXMLDataSet(__DIR__ . '/../operators/fixtures/page.xml');
}
protected function setUp(): void
{
parent::setUp();
$this->db = $this->new_dbal();
$this->loader = new \phpbb\pages\routing\page_loader_core($this->db, 'phpbb_pages');
}
public function test_load_routes_returns_collection()
{
$collection = $this->loader->load_routes();
self::assertInstanceOf('Symfony\Component\Routing\RouteCollection', $collection);
}
public static function route_data()
{
return array(
array(1, '/page_1'),
array(2, '/page_2'),
array(3, '/page_3'),
array(4, '/page_4'),
);
}
/**
* @dataProvider route_data
*/
public function test_routes_have_correct_paths($id, $expected)
{
$collection = $this->loader->load_routes();
$route = $collection->get('phpbb_pages_dynamic_route_' . $id);
self::assertInstanceOf('Symfony\Component\Routing\Route', $route);
self::assertSame($expected, $route->getPath());
}
public function test_supports_type()
{
self::assertTrue($this->loader->supports_type('phpbb_pages_route'));
self::assertFalse($this->loader->supports_type('other_type'));
self::assertFalse($this->loader->supports_type(null));
}
}