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')); } public function testChannels(): void { foreach (['mail', 'notification', 'both'] as $channel) { $this->assertTrue(NotificationPolicy::isValidChannel($channel)); } $this->assertFalse(NotificationPolicy::isValidChannel('')); $this->assertFalse(NotificationPolicy::isValidChannel('push')); } public function testChannelDecidesMailAndNotification(): void { $this->assertTrue(NotificationPolicy::sendsMail('mail')); $this->assertFalse(NotificationPolicy::sendsNotification('mail')); $this->assertFalse(NotificationPolicy::sendsMail('notification')); $this->assertTrue(NotificationPolicy::sendsNotification('notification')); $this->assertTrue(NotificationPolicy::sendsMail('both')); $this->assertTrue(NotificationPolicy::sendsNotification('both')); } public function testUnknownChannelFallsBackToMail(): void { $this->assertTrue(NotificationPolicy::sendsMail('')); $this->assertFalse(NotificationPolicy::sendsNotification('')); $this->assertTrue(NotificationPolicy::sendsMail('bogus')); $this->assertFalse(NotificationPolicy::sendsNotification('bogus')); } }