Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of git@github.com:olbrich/cuke4php into forking

  • Loading branch information...
commit b322b5a505431a4f74fa66a09e8e1e22d540c965 2 parents 6e6d7dd + b5afea7
Kevin Olbrich authored
View
2  VERSION
@@ -1 +1 @@
-0.9.6.c
+0.9.7
View
5 features/Cuke4Php.feature
@@ -54,4 +54,7 @@ Scenario Outline: Error Handling
@exception
Scenario: Exception Handling
When an "Exception" is thrown with message "generic exception"
- Then an "Exception" should be caught
+ Then an "Exception" should be caught
+
+Scenario: nested capture groups work fine
+ Given the losing code "one" has the prize "two"
View
2  features/step_definitions/Cuke4Php.wire
@@ -1,4 +1,2 @@
host: localhost
port: <%= ENV['CUKE4PHP_PORT'] || 16816 %>
-invoke:
- timeout: 0.1
View
7 features/step_definitions/WireSteps.php
@@ -231,6 +231,13 @@ public function stepParameterShouldBeAKindOfParameter($sKey,$sTypeName) {
self::assertInternalType($sTypeName, $this->$sKey);
}
+ /**
+ * Given /^the(?: losing)? code "([^"]*)"(?: has the prize "([^"]*)")?$/
+ **/
+ public function stepTheLosingCodeParameterHasThePrizeParameter($sCode, $sPrize) {
+ $this->$sCode = $sPrize;
+ }
+
}
?>
View
7 lib/CucumberScenario.php
@@ -66,6 +66,7 @@ function invokeBeforeHooks($aTags) {
if (array_key_exists('tags', $aBeforeHook)) {
if (count($aBeforeHook['tags']) == 0 || count(array_intersect($aTags, $aBeforeHook['tags'])) > 0) {
$oStep = CucumberSteps::getInstance($aBeforeHook['class'], $this->aGlobals);
+ syslog(LOG_DEBUG,"Invoking Before Hook \"{$aBeforeHook['method']}\"");
$oResult = $oStep->invoke($aBeforeHook['method']);
if ($oResult === false) {
return array('failure');
@@ -89,6 +90,7 @@ function invokeAfterHooks($aTags) {
if (array_key_exists('tags', $aAfterHook)) {
if (count($aAfterHook['tags']) == 0 || count(array_intersect($aTags, $aAfterHook['tags'])) > 0) {
$oStep = CucumberSteps::getInstance($aAfterHook['class'], $this->aGlobals);
+ syslog(LOG_DEBUG,"Invoking After Hook \"{$aAfterHook['method']}\"");
$oResult = $oStep->invoke($aAfterHook['method']);
if ($oResult === false) {
return array('failure');
@@ -132,14 +134,19 @@ function invoke($iStepId, $aArgs) {
}
try {
+ syslog(LOG_DEBUG,"Invoking Step \"{$aStep['method']}\"");
call_user_func_array(array($oStep, $aStep['method']),$aArgs);
} catch (PHPUnit_Framework_IncompleteTestError $e) {
+ syslog(LOG_DEBUG,"Step Pending");
return array('pending',$e->getMessage());
} catch (PHPUnit_Framework_SkippedTestError $e) {
+ syslog(LOG_DEBUG,"Step Pending");
return array('pending',$e->getMessage());
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
+ syslog(LOG_DEBUG,"Step Failed due to unmet expectation: " . $e->getMessage());
return array('fail', array('message' => $e->getMessage()));
} catch (Exception $e) {
+ syslog(LOG_DEBUG,"Step failed due to ". get_class($e) ." exception :" . $e->getMessage());
return array('fail', array('message' => $e->getMessage() . " " . $e->getFile() . ":" . $e->getLine(), 'exception' => get_class($e), 'backtrace' => $e->getTraceAsString()));
}
return array('success');
View
36 lib/Cuke4Php.php
@@ -26,6 +26,7 @@ class Cuke4Php {
);
function __construct($_sFeaturePath, $_iPort = 16816) {
+ openlog("cuke4php", LOG_PID, LOG_DAEMON);
if (is_file($_sFeaturePath)) {
$_sFeaturePath = dirname($_sFeaturePath);
}
@@ -119,21 +120,40 @@ function __destruct() {
}
function run() {
- print "Cuke4Php listening on port $this->iPort\n";
+ syslog(LOG_INFO,"Cuke4Php listening on port $this->iPort\n");
$this->oSocket = socket_create_listen($this->iPort);
$this->bRun = true;
while ($this->bRun && ($connection = socket_accept($this->oSocket))) {
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);
+ syslog(LOG_INFO,"Connection from $raddr");
+ try {
+ while ($this->bRun && ($input = socket_read($connection, 4096, PHP_NORMAL_READ))) {
+ $data = trim($input);
+ if ($data !== "") {
+ $output = json_encode($this->process($data)) . "\n";
+ if ($this->bRun) {
+ socket_write($connection, $output);
+ }
}
+ }
+ } catch (Exception $e) {
+ switch (socket_last_error($connection)) {
+ case 54:
+ // connection closed by peer
+ case 104:
+ // unable to read from socket
+ // these errors just mean we are done and the connection should be closed.
+ // it does not mean we should stop listening for new connections.
+ break;
+
+ default:
+ syslog(LOG_ERR,$e->getMessage());
+ throw $e;
+ break;
}
}
socket_close($connection);
+ syslog(LOG_INFO,"Connection closed");
sleep(1);
}
}
@@ -183,6 +203,7 @@ function process($sInput) {
* run any before hooks for a scenario
*/
function beginScenario($aTags) {
+ syslog(LOG_DEBUG,"Begin Scenario: Tags: " . implode(", ", $aTags));
$this->setScenario(CucumberScenario::getInstance($this->aWorld));
return $this->oScenario->invokeBeforeHooks($aTags);
}
@@ -216,6 +237,7 @@ function stepMatches($sStep) {
*/
function endScenario($aTags) {
$oResult = $this->oScenario->invokeAfterHooks($aTags);
+ syslog(LOG_DEBUG,"End Scenario");
$this->oScenario = null;
return $oResult;
}
Please sign in to comment.
Something went wrong with that request. Please try again.