public function test_can_create_permissions()
 {
     $this->createRoles();
     $this->createPermissions();
     $this->assertCount(3, $this->app->make(PermissionRepositoryInterface::class)->all());
     $this->app->make(RoleRepositoryInterface::class)->addPermissions(1, [1, 2]);
     $this->app->make(RoleRepositoryInterface::class)->addPermissions(2, [1]);
     $this->app->make(RoleRepositoryInterface::class)->addPermissions(3, [1, 2, 3]);
     $this->assertCount(1, Role::find(2)->permissions);
     $this->assertCount(2, Role::find(1)->permissions);
     $this->assertCount(3, Role::find(3)->permissions);
     $this->assertCount(3, Permission::find(1)->roles);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $roleAdmin = Role::create(['name' => Role::ROLE_ADMIN]);
     $roleEditor = Role::create(['name' => Role::ROLE_EDITOR]);
     $roleRedactor = Role::create(['name' => Role::ROLE_REDACTOR]);
     $permissionAccessUsers = Permission::create(['name' => 'access_users', 'description' => 'Permission to access the area users.']);
     $permissionAccessRoles = Permission::create(['name' => 'access_roles', 'description' => 'Permission to access the area roles.']);
     $permissionAccessPermissions = Permission::create(['name' => 'access_permissions', 'description' => 'Permission to access the area permissions.']);
     $permissionAccessCategories = Permission::create(['name' => 'access_categories', 'description' => 'Permission to access the area categories.']);
     $permissionAccessTags = Permission::create(['name' => 'access_tags', 'description' => 'Permission to access the area tags.']);
     $permissionAccessPosts = Permission::create(['name' => 'access_posts', 'description' => 'Permission to access the area posts.']);
     $permissionPublishPost = Permission::create(['name' => 'publish_post', 'description' => 'Permission to publish posts that are in draft.']);
     $roleAdmin->permissions()->save($permissionAccessUsers);
     $roleAdmin->permissions()->save($permissionAccessRoles);
     $roleAdmin->permissions()->save($permissionAccessPermissions);
     $roleAdmin->permissions()->save($permissionAccessCategories);
     $roleAdmin->permissions()->save($permissionAccessTags);
     $roleAdmin->permissions()->save($permissionAccessPosts);
     $roleAdmin->permissions()->save($permissionPublishPost);
     $roleEditor->permissions()->save($permissionAccessPosts);
     $roleEditor->permissions()->save($permissionPublishPost);
     $roleRedactor->permissions()->save($permissionAccessPosts);
 }