From f7125a9eff4a9def3b2c0e9a77f535a0bf601e39 Mon Sep 17 00:00:00 2001 From: Sriram Venkatesh Date: Wed, 12 Feb 2014 15:09:19 +1300 Subject: [PATCH] Added a step for creating a breakpoint --- .../BehatExtension/Context/BasicContext.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index 9a2407c..6fc55b5 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -421,6 +421,20 @@ JS; } } + /** + * Pauses the scenario until the user presses a key. Useful when debugging a scenario. + * + * @Then /^(?:|I )put a breakpoint$/ + */ + public function iPutABreakpoint() + { + fwrite(STDOUT, "\033[s \033[93m[Breakpoint] Press \033[1;93m[RETURN]\033[0;93m to continue...\033[0m"); + while (fgets(STDIN, 1024) == '') {} + fwrite(STDOUT, "\033[u"); + + return; + } + /** * Transforms relative time statements compatible with strtotime(). * Example: "time of 1 hour ago" might return "22:00:00" if its currently "23:00:00".