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'));
 }
 public function testOneSuggestion()
 {
     $attempt = (new Correction('vtce'))->casePop(false);
     $result = [];
     $this->assertContains('voce', $attempt, 'Attempt failed');
     foreach ($attempt as $word) {
         $consult = Dictionary::queryWord($word);
         if ($consult !== null) {
             $result[] = $consult;
         }
     }
     $this->assertContains(Str::accents('você'), $result, 'Consult failed');
 }
 /**
  * Ação: Listar todas as palavras do dicionário
  *
  * @return void
  */
 private function listWords()
 {
     $wordList = Database::allWords();
     $this->writeLine();
     if (count($wordList) > 0) {
         $this->writeLine('Abaixo todas as palavras atualmente no dicionário.');
         foreach ($wordList as $word) {
             $this->writeLine('- ' . $word);
         }
     } else {
         $this->writeLine('Nenhuma palavra no dicionário');
     }
     $this->writeLine();
     $this->standBy();
 }
 public function testBuildSchema()
 {
     $this->assertTrue(Dictionary::testConnection());
 }
 /**
  * Gera sugestões alterando letras na palavra-chave.
  *
  * @param bool|true $dictionary
  * @return array
  */
 public function casePop($dictionary = true)
 {
     $suggestions = [];
     for ($i = 0; $i < $this->length; $i++) {
         foreach ($this->alphabet as $letter) {
             $word = trim(substr_replace($this->keyword, $letter, $i, 1));
             if ($dictionary === true) {
                 $search = trim(Dictionary::queryWord($word));
                 if (!empty($search)) {
                     $suggestions[] = $search;
                 }
             } elseif (!empty($word)) {
                 $suggestions[] = $word;
             }
         }
     }
     return array_filter($suggestions);
 }