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