/** * @param PermissionInterface $permission */ protected function savePermission(PermissionInterface $permission) { if (0 === $permission->getMask()) { if ($permission->isPersistent()) { $this->databaseProvider->deletePermission($permission); $permission->setPersistent(false); } $this->permissionBuffer->add($permission); return; } if ($permission->isPersistent()) { $this->databaseProvider->updatePermission($permission); } else { $this->databaseProvider->insertPermission($permission); $permission->setPersistent(true); } $this->permissionBuffer->add($permission); }
public function testUpdatePermission() { $this->insertFixture($this->aliceRequester, $this->fooResource, 1); $this->databaseProvider->updatePermission(new Permission($this->aliceRequester, $this->fooResource, new BasicMaskBuilder(3))); $this->assertEquals(3, $this->findFixture($this->aliceRequester, $this->fooResource)['mask']); }