Skip to content

Commit 5a903db

Browse files
committed
Update tests and JSON
1 parent 88bc96d commit 5a903db

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

controller/admin_controller.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,14 @@ public function delete_autogroup_rule($autogroups_id)
188188
// If AJAX was used, show user a result message
189189
if ($this->request->is_ajax())
190190
{
191-
$json_response = new \phpbb\json_response;
192-
$json_response->send(array(
191+
return new \Symfony\Component\HttpFoundation\JsonResponse(array(
193192
'MESSAGE_TITLE' => $this->language->lang('INFORMATION'),
194193
'MESSAGE_TEXT' => $this->language->lang('ACP_AUTOGROUPS_DELETE_SUCCESS'),
195-
'REFRESH_DATA' => array(
196-
'time' => 3
197-
)
194+
'REFRESH_DATA' => ['time' => 3],
198195
));
199196
}
197+
198+
return null;
200199
}
201200

202201
/**

controller/admin_interface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function save_autogroup_rule($autogroups_id);
3838
* Delete the auto group rule
3939
*
4040
* @param int $autogroups_id The auto groups identifier to delete
41-
* @return void
41+
* @return \Symfony\Component\HttpFoundation\JsonResponse|null
4242
* @access public
4343
*/
4444
public function delete_autogroup_rule($autogroups_id);

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
44
backupGlobals="true"
55
backupStaticAttributes="false"
66
colors="true"

tests/conditions/base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class base extends \phpbb_database_test_case
2222
*
2323
* @return array vendor/name of extension(s) to test
2424
*/
25-
protected static function setup_extensions()
25+
protected static function setup_extensions(): array
2626
{
2727
return array('phpbb/autogroups');
2828
}

tests/controller/delete_autogroup_rule_test.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
namespace phpbb\autogroups\tests\controller;
1212

13+
use Symfony\Component\HttpFoundation\JsonResponse;
14+
1315
class delete_autogroup_rule_test extends admin_controller_base
1416
{
1517
/**
@@ -69,11 +71,9 @@ public function test_delete_autogroup_rule_ajax()
6971
->method('is_ajax')
7072
->willReturn(true);
7173

72-
// Handle trigger_error() output called from json_response
73-
$this->setExpectedTriggerError(E_WARNING);
74-
7574
// Call the delete_autogroup_rule() method
76-
$this->admin_controller->delete_autogroup_rule(1);
75+
$response = $this->admin_controller->delete_autogroup_rule(1);
76+
self::assertInstanceOf(JsonResponse::class, $response);
7777

7878
// Verify the autogroup rule has been removed
7979
self::assertEquals(0, $this->get_autogroup_rule_count(1));

0 commit comments

Comments
 (0)