From 9eed5c8e9fe368accdd28cc5e94c0dac82cefea6 Mon Sep 17 00:00:00 2001 From: Guillaume DUBOST Date: Wed, 4 Mar 2020 17:17:57 +0100 Subject: [PATCH] Improvement de la suppression du vhost de test --- src/RabbitContext.php | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/RabbitContext.php b/src/RabbitContext.php index e27012d..b2c8634 100644 --- a/src/RabbitContext.php +++ b/src/RabbitContext.php @@ -36,6 +36,12 @@ public static function createVhosts() foreach (self::$vhosts as $vhost) { $vhost = str_replace('/', '%2f', $vhost); + try { + $client->delete("/api/vhosts/{$vhost}"); + } catch (\Exception $e) { + // On ignore l'exception car le vhost n'existe peut être pas mais dans le doute on le supprime + } + $client->put("/api/vhosts/{$vhost}"); $client->put( "/api/permissions/{$vhost}/guest", @@ -50,20 +56,6 @@ public static function createVhosts() } } - /** - * @AfterSuite - */ - public static function deleteVhosts() - { - $client = self::getRabbitMqClient(); - - foreach (self::$vhosts as $vhost) { - $vhost = str_replace('/', '%2f', $vhost); - $client->delete("/api/vhosts/{$vhost}"); - } - } - - /** * @Given /le producer "([^"]*)" devrait avoir publié un message dans la queue "([^"]*)"$/ */