szuru/tests/PrivilegeTest.php

32 lines
911 B
PHP
Raw Permalink Normal View History

2014-09-06 10:00:26 +02:00
<?php
namespace Szurubooru\Tests;
use Szurubooru\Config;
use Szurubooru\Injector;
use Szurubooru\Privilege;
use Szurubooru\Tests\AbstractTestCase;
2014-09-06 10:00:26 +02:00
final class PrivilegeTest extends AbstractTestCase
2014-09-06 10:00:26 +02:00
{
2015-11-25 09:48:03 +01:00
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);
}
}
2014-09-06 10:00:26 +02:00
2015-11-25 09:48:03 +01:00
public function testConfigSectionNaming()
{
$refl = new \ReflectionClass(Privilege::class);
$constants = array_values($refl->getConstants());
2014-09-06 10:00:26 +02:00
2015-11-25 09:48:03 +01:00
$config = Injector::get(Config::class);
foreach ($config->security->privileges as $key => $value)
{
$this->assertTrue(in_array($key, $constants), "$key not in constants");
}
}
2014-09-06 10:00:26 +02:00
}