1+ <?php
2+
3+ /**
4+ *
5+ * PhpBB Gallery extension for the phpBB Forum Software package.
6+ *
7+ * @copyright (c) 2025 Your Name
8+ * @license GNU General Public License, version 2 (GPL-2.0)
9+ *
10+ */
11+
12+ namespace phpbbgallery \tests \core ;
13+ /**
14+ * @group core
15+ */
16+ require_once dirname (__FILE__ ) . '/../../../../includes/functions.php ' ;
17+
18+ class core_url_test extends core_base
19+ {
20+ protected $ gallery_url ;
21+
22+ public function setUp () : void
23+ {
24+ parent ::setUp ();
25+ $ this ->gallery_url = new \phpbbgallery \core \url (
26+ $ this ->config ,
27+ $ this ->user ,
28+ $ this ->root_path ,
29+ $ this ->php_ext
30+ );
31+ }
32+
33+ public function data_build_url ()
34+ {
35+ return array (
36+ 'album ' => array (
37+ 'album ' ,
38+ array ('album_id ' => 5 ),
39+ '/gallery/album/5 '
40+ ),
41+ 'image ' => array (
42+ 'image ' ,
43+ array ('image_id ' => 42 ),
44+ '/gallery/image/42 '
45+ ),
46+ // Add more cases as needed
47+ );
48+ }
49+
50+ /**
51+ * @dataProvider data_build_url
52+ */
53+ public function test_build_url ($ type , $ params , $ expected )
54+ {
55+ $ result = $ this ->gallery_url ->build_url ($ type , $ params );
56+ $ this ->assertEquals ($ expected , $ result );
57+ }
58+
59+ public function data_parse_url ()
60+ {
61+ return array (
62+ 'album ' => array (
63+ '/gallery/album/5 ' ,
64+ array ('type ' => 'album ' , 'album_id ' => 5 )
65+ ),
66+ 'image ' => array (
67+ '/gallery/image/42 ' ,
68+ array ('type ' => 'image ' , 'image_id ' => 42 )
69+ ),
70+ // Add more cases as needed
71+ );
72+ }
73+
74+ /**
75+ * @dataProvider data_parse_url
76+ */
77+ public function test_parse_url ($ url , $ expected )
78+ {
79+ $ result = $ this ->gallery_url ->parse_url ($ url );
80+ $ this ->assertEquals ($ expected , $ result );
81+ }
82+
83+ public function test_append_sid ()
84+ {
85+ $ url = '/gallery/album/5 ' ;
86+ $ sid = '123abc ' ;
87+ $ this ->user ->session_id = $ sid ;
88+ $ result = $ this ->gallery_url ->append_sid ($ url );
89+ $ this ->assertStringContainsString ('sid=123abc ' , $ result );
90+ }
91+
92+ public function test_get_root_path ()
93+ {
94+ $ this ->assertEquals ($ this ->root_path , $ this ->gallery_url ->get_root_path ());
95+ }
96+
97+ // Add more tests for other public methods in core\url.php as needed
98+ }
0 commit comments