Skip to content

Commit

Permalink
test: Updating C* defaults, handling missing curl extension, and addi…
Browse files Browse the repository at this point in the history
…tional persistent session feature
  • Loading branch information
mikefero committed Jul 24, 2015
1 parent 13d5589 commit d66c312
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
4 changes: 2 additions & 2 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default:
contexts:
- FeatureContext:
cluster_name: php-driver-2.1-cluster
cassandra_version: 2.1.5
cassandra_version: 2.1.8

cassandra-version-2.0:
formatters:
Expand All @@ -17,7 +17,7 @@ cassandra-version-2.0:
contexts:
- FeatureContext:
cluster_name: php-driver-2.0-cluster
cassandra_version: 2.0.13
cassandra_version: 2.0.16

cassandra-version-1.2:
formatters:
Expand Down
24 changes: 14 additions & 10 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,20 @@ public function aFileNamedWith($name, PyStringNode $string)

private function fetchPath($url)
{
$request = curl_init();

curl_setopt($request, CURLOPT_URL, $url);
curl_setopt($request, CURLOPT_HEADER, 0);
curl_setopt($request, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($request, CURLOPT_USERAGENT, 'PHP Driver Tests');

$content = curl_exec($request);
curl_close($request);
if (in_array('curl', get_loaded_extensions())) {
$request = curl_init();

curl_setopt($request, CURLOPT_URL, $url);
curl_setopt($request, CURLOPT_HEADER, 0);
curl_setopt($request, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($request, CURLOPT_USERAGENT, 'PHP Driver Tests');

$content = curl_exec($request);
curl_close($request);
} else {
$content = file_get_contents($url);
}

return $content;
}
Expand Down
30 changes: 29 additions & 1 deletion features/sessions/persistent_sessions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Feature: Persistent Sessions
PHP Driver sessions can persist

Background:
Given a running Cassandra cluster
Given a running Cassandra cluster with 2 nodes
And a file named "status.php" with:
"""php
<?php
Expand Down Expand Up @@ -35,6 +35,34 @@ Feature: Persistent Sessions
| Persistent Clusters | 1 |
| Persistent Sessions | 1 |

Scenario: Multiple persistent sessions are used for requests
Given a file named "connect.php" with:
"""php
<?php
$cluster = Cassandra::cluster()
->withContactPoints('127.0.0.1')
->withPersistentSessions(true)
->build();
$session = $cluster->connect();
"""
And a file named "connect_system.php" with:
"""php
<?php
$cluster = Cassandra::cluster()
->withContactPoints('127.0.0.1')
->withPersistentSessions(true)
->build();
$session = $cluster->connect("system");
"""
When I go to "/connect.php"
When I go to "/connect_system.php"
When I go to "/status.php"
Then I should see:
| Persistent Clusters | 1 |
| Persistent Sessions | 2 |

Scenario: Non-persistent sessions are recreated for each request
Given a file named "connect.php" with:
"""php
Expand Down

0 comments on commit d66c312

Please sign in to comment.