Skip to content

Commit 8471969

Browse files
authored
Merge pull request #27 from iMattPro/updates
Minor updates
2 parents c25418d + 9954a9c commit 8471969

4 files changed

Lines changed: 31 additions & 14 deletions

File tree

.github/workflows/tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ jobs:
125125
db: "mysql:5.7"
126126
- php: '8.2'
127127
db: "mysql:5.7"
128+
- php: '8.3'
129+
db: "mysql:5.7"
128130

129131
name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}
130132

@@ -266,6 +268,8 @@ jobs:
266268
db: "postgres:14"
267269
- php: '8.2'
268270
db: "postgres:14"
271+
- php: '8.3'
272+
db: "postgres:14"
269273

270274
name: PHP ${{ matrix.php }} - ${{ matrix.db }}
271275

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"version-check": {
3333
"host": "www.phpbb.com",
3434
"directory": "/customise/db/extension/topicprefixes",
35-
"filename": "version_check"
35+
"filename": "version_check",
36+
"ssl": true
3637
}
3738
}
3839
}

controller/admin_controller.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ public function add_prefix()
155155

156156
$tag = $this->request->variable('prefix_tag', '', true);
157157
$prefix = $this->manager->add_prefix($tag, $this->forum_id);
158-
$this->log($prefix['prefix_tag'], 'ACP_LOG_PREFIX_ADDED');
158+
159+
if ($prefix)
160+
{
161+
$this->log($prefix['prefix_tag'], 'ACP_LOG_PREFIX_ADDED');
162+
}
159163
}
160164
}
161165

tests/controller/add_prefix_test.php

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,23 @@ class add_prefix_test extends admin_controller_base
2525
*/
2626
public function data_add_prefix()
2727
{
28-
return array(
29-
array(true, true),
30-
array(true, false),
31-
array(false, false),
32-
);
28+
return [
29+
['', true, true],
30+
['topic_prefix1', true, true],
31+
['topic_prefix2', true, false],
32+
['topic_prefix3', false, false],
33+
];
3334
}
3435

3536
/**
3637
* Test add_prefix()
3738
*
3839
* @dataProvider data_add_prefix
40+
* @param $prefix
3941
* @param $submit
4042
* @param $valid_form
4143
*/
42-
public function test_add_prefix($submit, $valid_form)
44+
public function test_add_prefix($prefix, $submit, $valid_form)
4345
{
4446
if ($submit)
4547
{
@@ -52,20 +54,26 @@ public function test_add_prefix($submit, $valid_form)
5254
if (!$valid_form)
5355
{
5456
// Throws E_WARNING in PHP 8.0+ and E_USER_WARNING in earlier versions
55-
$exceptionName = version_compare(PHP_VERSION, '8.0', '<') ? \PHPUnit\Framework\Error\Error::class : \PHPUnit\Framework\Error\Warning::class;
56-
$errno = version_compare(PHP_VERSION, '8.0', '<') ? E_USER_WARNING : E_WARNING;
57+
$exceptionName = PHP_VERSION_ID < 80000 ? \PHPUnit\Framework\Error\Error::class : \PHPUnit\Framework\Error\Warning::class;
58+
$errno = PHP_VERSION_ID < 80000 ? E_USER_WARNING : E_WARNING;
5759
$this->expectException($exceptionName);
5860
$this->expectExceptionCode($errno);
5961
}
6062
else
6163
{
64+
$valid_prefix = $prefix !== '';
65+
$this->request->expects(static::once())
66+
->method('variable')
67+
->willReturnMap([
68+
['prefix_tag', '', true, \phpbb\request\request_interface::REQUEST, $prefix],
69+
]);
6270
$this->manager->expects(static::once())
6371
->method('add_prefix')
64-
->willReturn(['prefix_tag' => 'topic_prefix']);
65-
$this->log->expects(static::once())
72+
->willReturn($valid_prefix ? ['prefix_tag' => $prefix] : false);
73+
$this->log->expects($valid_prefix ? static::once() : static::never())
6674
->method('add')
67-
->with('admin', static::anything(), static::anything(), 'ACP_LOG_PREFIX_ADDED', static::anything(), ['topic_prefix', 'Test Forum']);
68-
$this->db->expects(static::once())
75+
->with('admin', static::anything(), static::anything(), 'ACP_LOG_PREFIX_ADDED', static::anything(), [$prefix, 'Test Forum']);
76+
$this->db->expects($valid_prefix ? static::once() : static::never())
6977
->method('sql_fetchrow')
7078
->willReturn(['forum_name' => 'Test Forum']);
7179
}

0 commit comments

Comments
 (0)