Skip to content

Instantly share code, notes, and snippets.

@brice
Last active July 1, 2020 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brice/f93f4fee323b3e7d46b40f8dba08bebf to your computer and use it in GitHub Desktop.
Save brice/f93f4fee323b3e7d46b40f8dba08bebf to your computer and use it in GitHub Desktop.
Snippet permettant de vérifier les routes testées et celles non testées

Ce snippet, constitué d'un fichier test.php et d'un fichier shell permet d'identifier quels sont les requêtes API couverte par des tests behat. Cela génère une liste pouvant être copié dans un fichier markdown.

Pour génerer le fichier routes.json, executer la commande suivante

./app/console de:ro --format json > app/features/routes.json

for i in `php test.php`;
do
method=`echo $i |cut -d";" -f1`;
path=`echo $i|cut -d";" -f2`;
query=`echo $i |cut -d";" -f3`;
count=`find app/features -name "*.feature" -exec grep $path {} \;| grep -c $method`;
if [ $count == 0 ];
then
echo "* [ ]" $method $query;
fi;
done
<?php
$file = json_decode(file_get_contents('app/features/routes.json'));
foreach ($file as $line) {
if (strpos($line->path, '/_') === 0) {
continue;
}
$path = str_replace(['{id}'], "1", $line->path);
// echo $line->method.";".$path."\n";
echo $line->method.";".$path.";".$line->path."\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment