Skip to content

Commit

Permalink
Ajout d'une nouvelle façon de comparer des csv
Browse files Browse the repository at this point in the history
* la fonction existante compare char par char
* la nouvelle compare les données après parsing, donc le contenu, ce qui s'affranchit des différences de formatage CSV (ex. quote, \r\n vs \n, etc...)
  • Loading branch information
Jouroumy authored Nov 17, 2022
1 parent 403e0a6 commit d1aec0d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/ApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,16 @@ public function jeTrieLeResultatPar($field)
return $a->$field <=> $b->$field;
});
}

/**
* @Then /^le csv devrait être équivalent au fichier csv "(.*)"$/
*/
public function leCsvDevraitEtreEquivalentAuFichierCsv($filename)
{
$filepath = realpath($this->results_path . "/" . $filename);
$csv_result = str_getcsv(preg_replace('/\r\n?/', "\n",$this->response['body']), ';');
$csv_expected = str_getcsv(preg_replace('/\r\n?/', "\n",file_get_contents($filepath)), ';');
$this->check($csv_result, $csv_expected, 'results', $errors);
$this->handleErrors($csv_expected, $errors);
}
}

0 comments on commit d1aec0d

Please sign in to comment.