assertFalse(NotificationPolicy::shouldNotify('off', false, true)); // Not even the owner of an unshared board — "off" is "off" in Deck too. $this->assertFalse(NotificationPolicy::shouldNotify('off', true, true)); } public function testAllAlwaysNotifies(): void { $this->assertTrue(NotificationPolicy::shouldNotify('all', false, false)); $this->assertTrue(NotificationPolicy::shouldNotify('all', true, false)); } public function testAssignedNotifiesOnlyAssignedUsers(): void { $this->assertTrue(NotificationPolicy::shouldNotify('assigned', false, true)); $this->assertFalse(NotificationPolicy::shouldNotify('assigned', false, false)); } public function testOwnerOfUnsharedBoardIsNotifiedWithAssigned(): void { $this->assertTrue(NotificationPolicy::shouldNotify('assigned', true, false)); } public function testUnknownSettingFallsBackToDeckDefault(): void { $this->assertTrue(NotificationPolicy::shouldNotify('', false, true)); $this->assertFalse(NotificationPolicy::shouldNotify('bogus', false, false)); $this->assertTrue(NotificationPolicy::shouldNotify('bogus', true, false)); } public function testAssignmentIsOnlyLookedUpWhenItMatters(): void { $lookup = function (): bool { $this->fail('assignment lookup must not run'); }; $this->assertFalse(NotificationPolicy::shouldNotify('off', false, $lookup)); $this->assertTrue(NotificationPolicy::shouldNotify('all', false, $lookup)); $this->assertTrue(NotificationPolicy::shouldNotify('assigned', true, $lookup)); $this->assertTrue(NotificationPolicy::shouldNotify('assigned', false, static fn (): bool => true)); $this->assertFalse(NotificationPolicy::shouldNotify('assigned', false, static fn (): bool => false)); } public function testModes(): void { foreach (['off', 'owner', 'board'] as $mode) { $this->assertTrue(NotificationPolicy::isValidMode($mode)); } $this->assertFalse(NotificationPolicy::isValidMode('')); $this->assertFalse(NotificationPolicy::isValidMode('all')); } }