Skip to content

Commit 3c65585

Browse files
committed
Further improve notification text layout
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent 9edb493 commit 3c65585

3 files changed

Lines changed: 46 additions & 32 deletions

File tree

language/en/common.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
'IDEA_DELETED' => 'Idea successfully deleted.',
3939
'IDEA_LIST' => 'Idea List',
4040
'IDEA_NOT_FOUND' => 'Idea not found',
41-
'IDEA_STATUS_CHANGE' => '<strong>Idea status changed</strong> by %1$s to <em>%2$s</em> for:',
41+
'IDEA_STATUS_CHANGE' => '<strong>Idea status changed</strong> by %s:',
4242
'IDEA_STORED_MOD' => 'Your idea has been submitted successfully, but it will need to be approved by a moderator before it is publicly viewable. You will be notified when your idea has been approved.<br /><br /><a href="%s">Return to Ideas</a>.',
4343
'IDEAS_TITLE' => 'phpBB Ideas',
4444
'IDEAS_NOT_AVAILABLE' => 'Ideas is not available at this time.',
@@ -67,6 +67,7 @@
6767
'NEW' => 'New',
6868
'NEW_IDEA' => 'New Idea',
6969
'NO_IDEAS_DISPLAY' => 'There are no ideas to display.',
70+
'NOTIFICATION_STATUS' => '<em>Status: <strong>%s</strong></em>',
7071

7172
'OPEN_IDEAS' => 'Open ideas',
7273

notification/type/status.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,9 @@ public function get_title()
134134
$this->language->add_lang('common', 'phpbb/ideas');
135135
}
136136

137-
$status = $this->language->lang(ext::status_name($this->get_data('status')));
138137
$username = $this->user_loader->get_username($this->get_data('updater_id'), 'no_profile');
139138

140-
return $this->language->lang($this->language_key, $username, $status);
139+
return $this->language->lang($this->language_key, $username);
141140
}
142141

143142
/**
@@ -151,6 +150,17 @@ public function get_reference()
151150
);
152151
}
153152

153+
/**
154+
* {@inheritDoc}
155+
*/
156+
public function get_reason()
157+
{
158+
return $this->language->lang(
159+
'NOTIFICATION_STATUS',
160+
$this->language->lang(ext::status_name($this->get_data('status')))
161+
);
162+
}
163+
154164
/**
155165
* {@inheritDoc}
156166
*/

tests/notification/status_test.php

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -169,43 +169,32 @@ public function test_users_to_query()
169169
public function test_get_title()
170170
{
171171
$this->setNotificationData([
172-
'updater_id' => 123,
173-
'status' => ext::$statuses['IN_PROGRESS']
172+
'updater_id' => 123
174173
]);
175174

176175
$this->language->expects($this->once())
177176
->method('is_set')
178177
->with('IDEA_STATUS_CHANGE')
179178
->willReturn(true);
180179

181-
$this->language->expects($this->exactly(2))
180+
$this->language->expects($this->once())
182181
->method('lang')
183-
->willReturnCallback(function($key, ...$args) {
184-
if ($key === 'IN_PROGRESS')
185-
{
186-
return 'In Progress';
187-
}
188-
if ($key === 'IDEA_STATUS_CHANGE' && $args[0] === 'TestUser' && $args[1] === 'In Progress')
189-
{
190-
return 'TestUser changed status to In Progress';
191-
}
192-
return '';
193-
});
182+
->with('IDEA_STATUS_CHANGE', 'TestUser')
183+
->willReturn('Idea status changed by TestUser');
194184

195185
$this->user_loader->expects($this->once())
196186
->method('get_username')
197187
->with(123, 'no_profile')
198188
->willReturn('TestUser');
199189

200190
$result = $this->notification_type->get_title();
201-
$this->assertEquals('TestUser changed status to In Progress', $result);
191+
$this->assertEquals('Idea status changed by TestUser', $result);
202192
}
203193

204194
public function test_get_title_loads_language()
205195
{
206196
$this->setNotificationData([
207197
'updater_id' => 456,
208-
'status' => ext::$statuses['IMPLEMENTED']
209198
]);
210199

211200
$this->language->expects($this->once())
@@ -217,27 +206,18 @@ public function test_get_title_loads_language()
217206
->method('add_lang')
218207
->with('common', 'phpbb/ideas');
219208

220-
$this->language->expects($this->exactly(2))
209+
$this->language->expects($this->once())
221210
->method('lang')
222-
->willReturnCallback(function($key, ...$args) {
223-
if ($key === 'IMPLEMENTED')
224-
{
225-
return 'Implemented';
226-
}
227-
if ($key === 'IDEA_STATUS_CHANGE' && $args[0] === 'AdminUser' && $args[1] === 'Implemented')
228-
{
229-
return 'AdminUser changed status to Implemented';
230-
}
231-
return '';
232-
});
211+
->with('IDEA_STATUS_CHANGE', 'AdminUser')
212+
->willReturn('Idea status changed by AdminUser');
233213

234214
$this->user_loader->expects($this->once())
235215
->method('get_username')
236216
->with(456, 'no_profile')
237217
->willReturn('AdminUser');
238218

239219
$result = $this->notification_type->get_title();
240-
$this->assertEquals('AdminUser changed status to Implemented', $result);
220+
$this->assertEquals('Idea status changed by AdminUser', $result);
241221
}
242222

243223
public function test_get_reference()
@@ -252,6 +232,29 @@ public function test_get_reference()
252232
$this->assertEquals('“Test Idea”', $this->notification_type->get_reference());
253233
}
254234

235+
public function test_get_reason()
236+
{
237+
$this->setNotificationData([
238+
'status' => ext::$statuses['IN_PROGRESS'],
239+
]);
240+
241+
$this->language->expects($this->exactly(2))
242+
->method('lang')
243+
->willReturnCallback(function($key, ...$args) {
244+
if ($key === 'IN_PROGRESS')
245+
{
246+
return 'In Progress';
247+
}
248+
if ($key === 'NOTIFICATION_STATUS' && $args[0] === 'In Progress')
249+
{
250+
return 'Status: In Progress';
251+
}
252+
return '';
253+
});
254+
255+
$this->assertEquals('Status: In Progress', $this->notification_type->get_reason());
256+
}
257+
255258
public function test_get_url()
256259
{
257260
$this->setNotificationData(['idea_id' => 42]);

0 commit comments

Comments
 (0)