createMock(ClockInterface::class); $cache = $this->createMock(CacheItemPoolInterface::class); $utilities = new Utilities($clock, $cache); $totp = TOTP::generate($clock); $totp->setLabel('Test'); $config = new ConfigBag( $utilities, $clock, 3600, $totp->getProvisioningUri(), 1800, false, 'Error', 'Teapot', 'Too Many' ); $pool = new ArrayAdapter(); $manager = new BackupCodeManager($pool); $manager->setConfig($config); $manager->setLogger($this->createMock(LoggerInterface::class)); return $manager; } private function createPersistCache(): PersistCache { $sessionCache = new ArrayAdapter(); $sessionStorage = new ArrayAdapter(); return new PersistCache($sessionCache, $sessionStorage); } public function testExecuteWithDefaultCount(): void { $backupManager = $this->createBackupManager(); $persistCache = $this->createPersistCache(); $command = new GenerateBackupCodesCommand($backupManager, $persistCache); $tester = new CommandTester($command); $tester->execute([]); self::assertSame(0, $tester->getStatusCode()); $output = $tester->getDisplay(); self::assertNotEmpty($output); } public function testExecuteWithCustomCount(): void { $backupManager = $this->createBackupManager(); $persistCache = $this->createPersistCache(); $command = new GenerateBackupCodesCommand($backupManager, $persistCache); $tester = new CommandTester($command); $tester->execute(['count' => 5]); self::assertSame(0, $tester->getStatusCode()); } public function testExecuteWithZeroCount(): void { $backupManager = $this->createBackupManager(); $persistCache = $this->createPersistCache(); $command = new GenerateBackupCodesCommand($backupManager, $persistCache); $tester = new CommandTester($command); $tester->execute(['count' => 0]); self::assertSame(0, $tester->getStatusCode()); } }