lib/Cuke4Php.php in cuke4php-0.9.2 vs lib/Cuke4Php.php in cuke4php-0.9.3
- old
+ new
@@ -19,11 +19,12 @@
private $oScenario;
private $aStepClasses;
public $aWorld = array(
'steps' => array(),
'before' => array(),
- 'after' => array()
+ 'after' => array(),
+ 'transform' => array()
);
function __construct($_sFeaturePath, $_iPort = 16816) {
if (is_file($_sFeaturePath)) {
$_sFeaturePath = dirname($_sFeaturePath);
@@ -31,14 +32,19 @@
if ($_iPort > 0) {
$this->iPort = $_iPort;
} else {
$this->iPort = 16816;
}
-
+
foreach (self::rglob("*.php", 0, $_sFeaturePath . "/support") as $sFilename) {
require_once $sFilename;
}
+ set_error_handler(
+ array('PHPUnit_Util_ErrorHandler', 'handleError'),
+ E_ALL | E_STRICT
+ );
+
require_once "Cucumber.php";
foreach (self::rglob("*.php", 0, $_sFeaturePath . "/step_definitions") as $sFilename) {
require_once $sFilename;
}
$this->aStepClasses = CucumberSteps::getSubclasses();
@@ -69,10 +75,16 @@
}
if (substr($oMethod->name, 0, 5) === "after") {
$this->aWorld['after'][] = $aMethod;
continue;
}
+ if (substr($oMethod->name, 0, 9) == "transform") {
+ preg_match("/(?:Transform) (.+)$/im", $sComment, $aMatches);
+ $aMethod['regexp'] = $aMatches[1];
+ $this->aWorld['transform'][] = $aMethod;
+ continue;
+ }
}
}
}
/**
@@ -112,13 +124,13 @@
socket_getpeername($connection, $raddr, $rport);
while ($this->bRun && ($input = socket_read($connection, 1024 * 4))) {
$data = trim($input);
if ($data !== "") {
$output = json_encode($this->process($data)) . "\n";
- if ($this->bRun) {
- socket_write($connection, $output);
- }
+ if ($this->bRun) {
+ socket_write($connection, $output);
+ }
}
}
socket_close($connection);
sleep(1);
}
@@ -132,10 +144,11 @@
return "Complete";
break;
default:
$aCommand = json_decode($sInput);
$sAction = $aCommand[0];
- $sData = NULL;
+ $sData = new stdClass;
+ $sData->tags = array();
if (array_key_exists(1, $aCommand)) {
$sData = $aCommand[1];
}
switch ($sAction) {
case 'begin_scenario':
\ No newline at end of file