Skip to content

Commit d378b51

Browse files
authored
Merge pull request #106 from iMattPro/updates
Remove clutter and deprecations add tests
2 parents 0893f8b + 66dde5a commit d378b51

6 files changed

Lines changed: 705 additions & 27 deletions

File tree

styles/all/template/event/overall_header_head_append.html

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
<!-- Ensure the app can be added to the home screen on iOS -->
21
<meta name="apple-mobile-web-app-capable" content="yes">
3-
4-
<!-- Ensure the app can be added to the home screen on Chrome -->
5-
<meta name="mobile-web-app-capable" content="yes">
6-
7-
<!-- Sets the status bar style when the app is launched from the home screen on iOS -->
8-
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
9-
10-
<!-- The name of your app when saved to the iOS home screen -->
112
<meta name="apple-mobile-web-app-title" content="{{ SHORT_SITE_NAME }}">
123

13-
<!-- The name of your app when saved to other browsers and platforms -->
14-
<meta name="application-name" content="{{ SHORT_SITE_NAME }}">
15-
16-
<!-- Link to app's configuration manifest -->
174
<link rel="manifest" href="{{ U_MANIFEST_URL }}" crossorigin="use-credentials">
185

19-
{% if U_TOUCH_ICON %}
20-
<!-- App icon for iOS, a fallback to icons defined in the manifest -->
21-
<link rel="apple-touch-icon" href="{{ ROOT_PATH ~ U_TOUCH_ICON }}">
22-
{% endif %}
6+
{% if U_TOUCH_ICON %}<link rel="apple-touch-icon" href="{{ ROOT_PATH ~ U_TOUCH_ICON }}">{% endif %}
237

248
{% if NOTIFICATIONS_WEBPUSH_ENABLE %}
259
{% include '@phpbb_webpushnotifications/ucp_notifications_webpush.html' %}
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
<?php
2+
/**
3+
*
4+
* phpBB Browser Push Notifications. An extension for the phpBB Forum Software package.
5+
*
6+
* @copyright (c) 2025, phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
namespace phpbb\webpushnotifications\tests\controller;
12+
13+
use Symfony\Component\HttpFoundation\JsonResponse;
14+
15+
class controller_manifest_test extends \phpbb_test_case
16+
{
17+
protected $config;
18+
protected $path_helper;
19+
protected $user;
20+
protected $manifest;
21+
22+
protected function setUp(): void
23+
{
24+
global $phpbb_root_path, $phpEx;
25+
global $config, $user, $request, $symfony_request;
26+
27+
parent::setUp();
28+
29+
$config = $this->config = new \phpbb\config\config([
30+
'force_server_vars' => false,
31+
'script_path' => '',
32+
'sitename' => '',
33+
'pwa_short_name' => '',
34+
'pwa_icon_small' => '',
35+
'pwa_icon_large' => '',
36+
]);
37+
38+
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
39+
$language = new \phpbb\language\language($lang_loader);
40+
$user = $this->user = new \phpbb\user($language, '\phpbb\datetime');
41+
$symfony_request = $this->createMock(\phpbb\symfony_request::class);
42+
$request = $this->request = $this->createMock(\phpbb\request\request_interface::class);
43+
$this->path_helper = new \phpbb\path_helper($symfony_request, new \phpbb\filesystem\filesystem(), $this->request, $phpbb_root_path, $phpEx);
44+
45+
$this->manifest = new \phpbb\webpushnotifications\controller\manifest(
46+
$this->config,
47+
$this->path_helper,
48+
$this->user
49+
);
50+
}
51+
52+
public function manifest_data()
53+
{
54+
return [
55+
'using web root path' => [
56+
[
57+
'force_server_vars' => false,
58+
'script_path' => '',
59+
'sitename' => 'yourdomain.com',
60+
'pwa_short_name' => 'yourdomain',
61+
],
62+
[
63+
'name' => 'yourdomain.com',
64+
'short_name' => 'yourdomain',
65+
'display' => 'standalone',
66+
'orientation' => 'portrait',
67+
'start_url' => './phpBB/',
68+
'scope' => './phpBB/',
69+
],
70+
],
71+
'using script path' => [
72+
[
73+
'force_server_vars' => true,
74+
'script_path' => '/',
75+
'sitename' => 'yourdomain.com',
76+
'pwa_short_name' => 'yourdomain',
77+
],
78+
[
79+
'name' => 'yourdomain.com',
80+
'short_name' => 'yourdomain',
81+
'display' => 'standalone',
82+
'orientation' => 'portrait',
83+
'start_url' => '/',
84+
'scope' => '/',
85+
],
86+
],
87+
'with shortname' => [
88+
[
89+
'sitename' => 'testdomain.com',
90+
'pwa_short_name' => 'testdomain',
91+
],
92+
[
93+
'name' => 'testdomain.com',
94+
'short_name' => 'testdomain',
95+
'display' => 'standalone',
96+
'orientation' => 'portrait',
97+
'start_url' => './phpBB/',
98+
'scope' => './phpBB/',
99+
],
100+
],
101+
'without shortname' => [
102+
[
103+
'sitename' => 'testdomain.com',
104+
'pwa_short_name' => '',
105+
],
106+
[
107+
'name' => 'testdomain.com',
108+
'short_name' => 'testdomain.c',
109+
'display' => 'standalone',
110+
'orientation' => 'portrait',
111+
'start_url' => './phpBB/',
112+
'scope' => './phpBB/',
113+
],
114+
],
115+
'with icons' => [
116+
[
117+
'sitename' => '',
118+
'pwa_short_name' => '',
119+
'pwa_icon_small' => 'foo_sm.png',
120+
'pwa_icon_large' => 'foo_lg.png',
121+
],
122+
[
123+
'name' => '',
124+
'short_name' => '',
125+
'display' => 'standalone',
126+
'orientation' => 'portrait',
127+
'start_url' => './phpBB/',
128+
'scope' => './phpBB/',
129+
'icons' => [
130+
[
131+
'src' => 'http://images/site_icons/foo_sm.png',
132+
'sizes' => '192x192',
133+
'type' => 'image/png',
134+
],
135+
[
136+
'src' => 'http://images/site_icons/foo_lg.png',
137+
'sizes' => '512x512',
138+
'type' => 'image/png',
139+
],
140+
],
141+
],
142+
],
143+
];
144+
}
145+
146+
/**
147+
* @dataProvider manifest_data
148+
*/
149+
public function test_manifest($configs, $expected)
150+
{
151+
foreach ($configs as $key => $value)
152+
{
153+
$this->config->set($key, $value);
154+
}
155+
156+
$response = $this->manifest->handle();
157+
158+
$this->assertInstanceOf(JsonResponse::class, $response);
159+
160+
$this->assertEquals($expected, json_decode($response->getContent(), true));
161+
}
162+
163+
public function manifest_with_bot_data()
164+
{
165+
return [
166+
'is a bot' => [true, 'yes'],
167+
'not a bot' => [false, null],
168+
];
169+
}
170+
171+
/**
172+
* @dataProvider manifest_with_bot_data
173+
*/
174+
public function test_manifest_with_bot($is_bot, $expected)
175+
{
176+
$this->user->data['is_bot'] = $is_bot;
177+
178+
$response = $this->manifest->handle();
179+
180+
$this->assertInstanceOf(JsonResponse::class, $response);
181+
182+
$this->assertEquals($expected, $response->headers->get('X-PHPBB-IS-BOT'));
183+
}
184+
}

0 commit comments

Comments
 (0)