Skip to content

Commit a9b5ba7

Browse files
committed
PHPUnit tests updated
1 parent 2ad6884 commit a9b5ba7

35 files changed

+858
-663
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
}
2525
],
2626
"require": {
27-
"php": ">=5.6.0"
27+
"php": ">=8.0"
2828
},
2929
"require-dev": {
30-
"behat/behat": "~3.0.6",
31-
"phpunit/php-code-coverage": "~2.0",
32-
"phpunit/php-token-stream": "~1.3",
33-
"phpunit/phpunit": "~4.8",
30+
"behat/behat": "~3.7",
31+
"phpunit/php-code-coverage": "~7.0",
32+
"phpunit/php-token-stream": "~3.1",
33+
"phpunit/phpunit": "~8.5",
3434
"symfony/process": "~2.1"
3535
},
3636
"config": {

support/ccm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function setupSchema($schema, $dropExistingKeyspaces = true)
9393

9494
public function start()
9595
{
96-
$this->run('start', '--wait-other-notice', '--wait-for-binary-proto');
96+
$this->run('start', '--root', '--skip-wait-other-notice', '--wait-for-binary-proto');
9797
$builder = Cassandra::cluster()
9898
->withPersistentSessions(false)
9999
->withContactPoints('127.0.0.1');
@@ -181,7 +181,7 @@ private function internalSetup($dataCenterOneNodes, $dataCenterTwoNodes)
181181
if (in_array($clusterName, $clusters['list'])) {
182182
$this->run('switch', $clusterName);
183183
} else {
184-
$this->run('create', '-v', 'binary:' . $this->version, '-b', $clusterName);
184+
$this->run('create', '-v', $this->version, '-b', $clusterName);
185185

186186
$params = array(
187187
'updateconf', '--rt', '1000', 'read_request_timeout_in_ms: 1000',

tests/integration/Cassandra/BasicIntegrationTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818

1919
namespace Cassandra;
2020

21+
use CCM;
22+
use PHPUnit\Framework\TestCase;
23+
2124
/**
2225
* Basic/Simple integration test class to provide common integration test
2326
* functionality when a simple setup and teardown is required. This class
2427
* should be used for the majority of tests.
2528
*/
26-
abstract class BasicIntegrationTest extends \PHPUnit_Framework_TestCase {
29+
abstract class BasicIntegrationTest extends TestCase {
2730
/**
2831
* Conversion value for seconds to milliseconds.
2932
*/
@@ -115,7 +118,7 @@ abstract class BasicIntegrationTest extends \PHPUnit_Framework_TestCase {
115118
/**
116119
* Setup the database for the integration tests.
117120
*/
118-
protected function setUp() {
121+
protected function setUp(): void {
119122
// Initialize the database and establish a connection
120123
$this->integration = new Integration(get_class(), $this->getName(false),
121124
$this->numberDC1Nodes, $this->numberDC2Nodes,
@@ -134,7 +137,7 @@ protected function setUp() {
134137
/**
135138
* Teardown the database for the integration tests.
136139
*/
137-
protected function tearDown() {
140+
protected function tearDown(): void {
138141
unset($this->integration);
139142
unset($this->ccm);
140143
unset($this->session);

tests/integration/Cassandra/CollectionsIntegrationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ abstract class CollectionsIntegrationTest extends DatatypeIntegrationTests {
2525
/**
2626
* Create user types after initializing cluster and session
2727
*/
28-
protected function setUp() {
28+
protected function setUp(): void {
2929
parent::setUp();
3030

3131
foreach ($this->compositeCassandraTypes() as $cassandraType) {

tests/integration/Cassandra/DatatypeIntegrationTests.php

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
namespace Cassandra;
2020

21+
use Cassandra;
22+
2123
/**
2224
* A base class for data type integration tests
2325
*/
@@ -62,23 +64,23 @@ public function scalarCassandraTypes() {
6264
*/
6365
public function constantScalarCassandraTypes() {
6466
$constants = array(
65-
\Cassandra::TYPE_TEXT,
66-
\Cassandra::TYPE_ASCII,
67-
\Cassandra::TYPE_VARCHAR,
68-
\Cassandra::TYPE_BIGINT,
69-
\Cassandra::TYPE_SMALLINT,
70-
\Cassandra::TYPE_TINYINT,
71-
\Cassandra::TYPE_BLOB,
72-
\Cassandra::TYPE_BOOLEAN,
73-
\Cassandra::TYPE_DECIMAL,
74-
\Cassandra::TYPE_DOUBLE,
75-
\Cassandra::TYPE_FLOAT,
76-
\Cassandra::TYPE_INT,
77-
\Cassandra::TYPE_TIMESTAMP,
78-
\Cassandra::TYPE_UUID,
79-
\Cassandra::TYPE_VARINT,
80-
\Cassandra::TYPE_TIMEUUID,
81-
\Cassandra::TYPE_INET
67+
Cassandra::TYPE_TEXT,
68+
Cassandra::TYPE_ASCII,
69+
Cassandra::TYPE_VARCHAR,
70+
Cassandra::TYPE_BIGINT,
71+
Cassandra::TYPE_SMALLINT,
72+
Cassandra::TYPE_TINYINT,
73+
Cassandra::TYPE_BLOB,
74+
Cassandra::TYPE_BOOLEAN,
75+
Cassandra::TYPE_DECIMAL,
76+
Cassandra::TYPE_DOUBLE,
77+
Cassandra::TYPE_FLOAT,
78+
Cassandra::TYPE_INT,
79+
Cassandra::TYPE_TIMESTAMP,
80+
Cassandra::TYPE_UUID,
81+
Cassandra::TYPE_VARINT,
82+
Cassandra::TYPE_TIMEUUID,
83+
Cassandra::TYPE_INET
8284
);
8385
$scalarCassandraTypes = $this->scalarCassandraTypes();
8486

@@ -193,14 +195,21 @@ protected function verifyValue($tableName, $type, $key, $value) {
193195
array('arguments' => array($key))
194196
);
195197

196-
$this->assertEquals(count($result), 1);
198+
if (PHP_MAJOR_VERSION >= 8) {
199+
$this->assertEquals(1, $result->count());
200+
}
201+
else {
202+
$this->assertEquals(count($result), 1);
203+
}
197204

198205
$row = $result->first();
199206

200207
$this->assertEquals($row['value'], $value);
201208
$this->assertTrue($row['value'] == $value);
202209
if (isset($row['value'])) {
203-
$this->assertEquals(count($row['value']), count($value));
210+
if (PHP_MAJOR_VERSION < 8) {
211+
$this->assertEquals(count($row['value']), count($value));
212+
}
204213
if (is_object($row['value'])) {
205214
$this->assertEquals($row['value']->type(), $type);
206215
}

tests/integration/Cassandra/Integration.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
namespace Cassandra;
2020

21+
use Cassandra;
22+
use CCM;
23+
use ReflectionClass;
24+
2125
/**
2226
* Base class to provide common integration test functionality.
2327
*/
@@ -27,7 +31,7 @@ class Integration {
2731
/**
2832
* Default Cassandra server version
2933
*/
30-
const DEFAULT_CASSANDRA_VERSION = "3.10";
34+
const DEFAULT_CASSANDRA_VERSION = "3.11.9";
3135
/**
3236
* Default verbosity for CCM output
3337
*/
@@ -62,13 +66,13 @@ class Integration {
6266
/**
6367
* Cluster instance.
6468
*
65-
* @var \Cassandra\Cluster
69+
* @var Cluster
6670
*/
6771
private $cluster;
6872
/**
6973
* Connected database session.
7074
*
71-
* @var \Cassandra\Session
75+
* @var Session
7276
*/
7377
private $session;
7478
/**
@@ -129,7 +133,7 @@ public function __construct($className,
129133

130134
// Create the Cassandra cluster for the test
131135
//TODO: Need to add the ability to switch the Cassandra version (command line)
132-
$this->ccm = new \CCM(self::DEFAULT_CASSANDRA_VERSION, self::DEFAULT_IS_CCM_SILENT);
136+
$this->ccm = new CCM(self::DEFAULT_CASSANDRA_VERSION, self::DEFAULT_IS_CCM_SILENT);
133137
$this->ccm->setup($numberDC1Nodes, $numberDC2Nodes);
134138
if ($isClientAuthentication) {
135139
$this->ccm->setupClientVerification();
@@ -159,7 +163,7 @@ public function __construct($className,
159163
}
160164

161165
// Create the session and keyspace for the integration test
162-
$this->cluster = \Cassandra::cluster()
166+
$this->cluster = Cassandra::cluster()
163167
->withContactPoints($this->getContactPoints(Integration::IP_ADDRESS, ($numberDC1Nodes + $numberDC2Nodes)))
164168
->withPersistentSessions(false)
165169
->build();
@@ -192,7 +196,7 @@ public function __destruct() {
192196
* @return string Short name for the class name
193197
*/
194198
private function getShortName($className) {
195-
$function = new \ReflectionClass($className);
199+
$function = new ReflectionClass($className);
196200
return $function->getShortName();
197201
}
198202

@@ -249,7 +253,7 @@ class IntegrationTestFixture {
249253
/**
250254
* Handle for communicating with CCM.
251255
*
252-
* @var \CCM
256+
* @var CCM
253257
*/
254258
private $ccm;
255259
/**
@@ -260,7 +264,7 @@ class IntegrationTestFixture {
260264
private static $instance;
261265

262266
function __construct() {
263-
$this->ccm = new \CCM(\CCM::DEFAULT_CASSANDRA_VERSION, true);
267+
$this->ccm = new CCM(CCM::DEFAULT_CASSANDRA_VERSION, true);
264268
$this->ccm->removeAllClusters();
265269
}
266270

0 commit comments

Comments
 (0)