mirror of
https://github.com/Icinga/icingaweb2.git
synced 2026-07-08 09:11:04 -04:00
Replace the outdated `array()` spelling with the more modern `[]`. This is applied throughout the whole project, also including phpdocs, tests, view scripts and core modules.
62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
|
|
// SPDX-FileCopyrightText: 2018 Icinga GmbH <https://icinga.com>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
namespace Tests\Icinga\Forms\Config;
|
|
|
|
use Icinga\Test\BaseTestCase;
|
|
use Icinga\Application\Config;
|
|
use Icinga\Forms\Config\UserBackendConfigForm;
|
|
use Icinga\Forms\Config\UserBackendReorderForm;
|
|
|
|
class UserBackendConfigFormWithoutSave extends UserBackendConfigForm
|
|
{
|
|
public static $newConfig;
|
|
|
|
public function save()
|
|
{
|
|
self::$newConfig = $this->config;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
class UserBackendReorderFormProvidingConfigFormWithoutSave extends UserBackendReorderForm
|
|
{
|
|
public function getConfigForm()
|
|
{
|
|
$form = new UserBackendConfigFormWithoutSave();
|
|
$form->setIniConfig($this->config);
|
|
return $form;
|
|
}
|
|
}
|
|
|
|
class UserBackendReorderFormTest extends BaseTestCase
|
|
{
|
|
public function testMoveBackend()
|
|
{
|
|
$config = Config::fromArray(
|
|
[
|
|
'test1' => '',
|
|
'test2' => '',
|
|
'test3' => ''
|
|
]
|
|
);
|
|
|
|
$this->getRequestMock()->shouldReceive('getMethod')->andReturn('POST')
|
|
->shouldReceive('isPost')->andReturn(true)
|
|
->shouldReceive('getPost')->andReturn(['backend_newpos' => 'test3|1']);
|
|
|
|
$form = new UserBackendReorderFormProvidingConfigFormWithoutSave();
|
|
$form->setIniConfig($config);
|
|
$form->setTokenDisabled();
|
|
$form->setUidDisabled();
|
|
$form->handleRequest();
|
|
|
|
$this->assertEquals(
|
|
['test1', 'test3', 'test2'],
|
|
UserBackendConfigFormWithoutSave::$newConfig->keys(),
|
|
'Moving elements with UserBackendReorderForm does not seem to properly work'
|
|
);
|
|
}
|
|
}
|