/** * Ação: Remover palavras do dicionário * * @return void */ private function removeWords() { $this->writeLine(); $this->writeLine('Escreva abaixo as palavras a serem removidas.'); $this->writeLine('Em seguida, digite o comando "--save" para salvar as alterações ou "--cancel" para cancelar.'); $wordList = []; while (true) { $line = $this->read(); if ($line == '--save') { if (count($wordList) > 0) { Database::deleteWords($wordList); $this->writeLine(); $this->writeLine('Removido ' . count($wordList) . ' palavra' . (count($wordList) > 1 ? 's' : '') . ' do dicionário.'); break; } } elseif ($line == '--cancel') { $this->writeLine(); $this->writeLine('Operação cancelada.'); break; } else { $wordList[] = $line; } } $this->writeLine(); $this->standBy(); }
public function testRemoveWords() { Dictionary::deleteWords('apagar1'); Dictionary::deleteWords(['apagar2', 'apagar3']); $this->assertNull(Dictionary::queryWord('apagar1')); $this->assertNull(Dictionary::queryWord('apagar2')); $this->assertNull(Dictionary::queryWord('apagar3')); }