szurubooru/tests/PrivilegeTest.php
Marcin Kurczewski 632bac8661 Added "use ..." statements
This version ditches backwards compatibility with PHP earlier than 5.6.
2014-10-18 18:48:36 +02:00

31 lines
806 B
PHP

<?php
namespace Szurubooru\Tests;
use Szurubooru\Config;
use Szurubooru\Injector;
use Szurubooru\Privilege;
use Szurubooru\Tests\AbstractTestCase;
final class PrivilegeTest extends AbstractTestCase
{
public function testConstNaming()
{
$refl = new \ReflectionClass(Privilege::class);
foreach ($refl->getConstants() as $key => $value)
{
$value = strtoupper(ltrim(preg_replace('/[A-Z]/', '_\0', $value), '_'));
$this->assertEquals($key, $value);
}
}
public function testConfigSectionNaming()
{
$refl = new \ReflectionClass(Privilege::class);
$constants = array_values($refl->getConstants());
$config = Injector::get(Config::class);
foreach ($config->security->privileges as $key => $value)
{
$this->assertTrue(in_array($key, $constants), "$key not in constants");
}
}
}