*/ public static function guardrailCases(): array { // [actorId, targetId, wasAdmin, willBeAdmin, totalAdmins, expected, label] return [ [1, 1, true, false, 2, 'self_demote', 'self demote, 2 admins'], [1, 1, true, false, 1, 'self_demote', 'self demote, only admin — self wins priority'], [1, 2, true, false, 1, 'last_admin', 'demote the only admin (different user)'], [1, 2, true, false, 2, null, 'demote someone else when another admin remains'], [1, 2, false, true, 1, null, 'promote — never blocked'], [1, 2, true, true, 1, null, 'no-op — never blocked'], [1, 2, false, false, 1, null, 'no-op on non-admin — never blocked'], [1, 1, false, true, 1, null, 'actor promoting themselves? odd but not blocked'], ]; } #[DataProvider('guardrailCases')] public function testDemoteGuardrail( int $actor, int $target, bool $was, bool $will, int $total, ?string $expected, string $label, ): void { $this->assertSame( $expected, UserController::demoteGuardrail($actor, $target, $was, $will, $total), $label, ); } }