feat: soft-delete for teamer accounts
addresses #869dv9br3
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Entity;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
use App\Entity\User;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||
@@ -118,6 +119,44 @@ class UserTest extends TestCase
|
||||
$this->assertNull($enabled->getDisabledAt());
|
||||
}
|
||||
|
||||
/**
|
||||
* A block and a deletion are independent states: setting one must never imply or
|
||||
* clear the other, so that a disciplinary block survives a deletion and the restore
|
||||
* that follows it.
|
||||
*/
|
||||
public function testDeletionAndBlockAreIndependentStates(): void
|
||||
{
|
||||
$user = new User();
|
||||
$this->assertFalse($user->isBlocked());
|
||||
|
||||
$user->setDeleted();
|
||||
$this->assertTrue($user->isBlocked());
|
||||
$this->assertFalse($user->isDisabled());
|
||||
|
||||
$user->setDisabled(true);
|
||||
$disabledAt = $user->getDisabledAt();
|
||||
|
||||
$user->setRestored();
|
||||
$this->assertFalse($user->isDeleted());
|
||||
$this->assertTrue($user->isBlocked());
|
||||
$this->assertSame($disabledAt, $user->getDisabledAt());
|
||||
|
||||
$user->setDisabled(false);
|
||||
$this->assertFalse($user->isBlocked());
|
||||
}
|
||||
|
||||
public function testSettingTheTeamerKeepsTheInverseSideInSync(): void
|
||||
{
|
||||
$teamer = new Teamer();
|
||||
$user = (new User())->setTeamer($teamer);
|
||||
|
||||
$this->assertSame($user, $teamer->getUser());
|
||||
|
||||
$user->setTeamer(null);
|
||||
|
||||
$this->assertNull($teamer->getUser());
|
||||
}
|
||||
|
||||
private function validate(User $user): ConstraintViolationListInterface
|
||||
{
|
||||
return Validation::createValidatorBuilder()
|
||||
|
||||
Reference in New Issue
Block a user