2014-09-06 10:00:26 +02:00
|
|
|
<?php
|
|
|
|
namespace Szurubooru\Tests;
|
|
|
|
|
|
|
|
class PrivilegeTest extends \Szurubooru\Tests\AbstractTestCase
|
|
|
|
{
|
|
|
|
public function testConstNaming()
|
|
|
|
{
|
|
|
|
$refl = new \ReflectionClass(\Szurubooru\Privilege::class);
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
$refl = new \ReflectionClass(\Szurubooru\Privilege::class);
|
|
|
|
$constants = array_values($refl->getConstants());
|
|
|
|
|
2014-09-10 17:41:47 +02:00
|
|
|
$dataPath = __DIR__
|
2014-09-06 10:00:26 +02:00
|
|
|
. DIRECTORY_SEPARATOR . '..'
|
2014-09-10 17:41:47 +02:00
|
|
|
. DIRECTORY_SEPARATOR . 'data';
|
2014-09-06 10:00:26 +02:00
|
|
|
|
2014-09-10 17:41:47 +02:00
|
|
|
$config = new \Szurubooru\Config($dataPath);
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|