Skip to content

Commit

Permalink
Add default attributes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Jan 12, 2022
1 parent d0623bf commit e31d836
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/PermissionTest.php
Expand Up @@ -3,6 +3,7 @@
namespace Yiisoft\Rbac\Tests;

use PHPUnit\Framework\TestCase;
use Yiisoft\Rbac\Item;
use Yiisoft\Rbac\Permission;

final class PermissionTest extends TestCase
Expand All @@ -22,4 +23,17 @@ public function testImmutability(): void
$this->assertNotSame($original, $new4);
$this->assertNotSame($original, $new5);
}

public function testDefaultAttributes(): void
{
$permission = new Permission('test');
$this->assertSame([
'name' => 'test',
'description' => '',
'ruleName' => null,
'type' => Item::TYPE_PERMISSION,
'updatedAt' => null,
'createdAt' => null,
], $permission->getAttributes());
}
}
14 changes: 14 additions & 0 deletions tests/RoleTest.php
Expand Up @@ -3,6 +3,7 @@
namespace Yiisoft\Rbac\Tests;

use PHPUnit\Framework\TestCase;
use Yiisoft\Rbac\Item;
use Yiisoft\Rbac\Role;

final class RoleTest extends TestCase
Expand All @@ -23,4 +24,17 @@ public function testImmutability(): void
$this->assertNotSame($original, $new4);
$this->assertNotSame($original, $new5);
}

public function testDefaultAttributes(): void
{
$permission = new Role('test');
$this->assertSame([
'name' => 'test',
'description' => '',
'ruleName' => null,
'type' => Item::TYPE_ROLE,
'updatedAt' => null,
'createdAt' => null,
], $permission->getAttributes());
}
}

0 comments on commit e31d836

Please sign in to comment.