PermissionManagerTest.php 905 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
<?php

namespace Modules\User\Tests\Permissions;

use Modules\Core\Tests\BaseTestCase;
use Modules\User\Permissions\PermissionManager;

class PermissionManagerTest extends BaseTestCase
{
    /**
     * @test
     */
    public function it_should_clean_permissions()
    {
        $input = [
            'permission1' => '1',
            'permission2' => '1',
            'permission3' => '-1',
            'permission4' => '-1',
            'permission5' => '0',
            'permission6' => '0',
        ];

        $expected = [
            'permission1' => true,
            'permission2' => true,
            'permission3' => false,
            'permission4' => false,
        ];

        $manager = new PermissionManager();

        $actual = $manager->clean($input);

        $this->assertSame($expected, $actual, 'The PermissionManager should clean the permissions and fix their states.');
    }
}