Skip to content

Commit 6740cc8

Browse files
committed
fix tests for new phpunit version and php8
1 parent 1c1b23f commit 6740cc8

29 files changed

+111
-486
lines changed

lib/ArangoDBClient/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function setOption($name, $value)
145145
$name === ConnectionOptions::OPTION_CIPHERS ||
146146
$name === ConnectionOptions::OPTION_ALLOW_SELF_SIGNED
147147
) {
148-
throw new ClientException('Must not set option ' . $value . ' after connection is created.');
148+
throw new ClientException('Must not set option ' . $name . ' after connection is created.');
149149
}
150150

151151
$this->_options[$name] = $value;

tests/AdminTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class AdminTest extends
1717
\PHPUnit_Framework_TestCase
1818
{
19-
public function setUp()
19+
public function setUp(): void
2020
{
2121
$this->connection = getConnection();
2222
$this->adminHandler = new AdminHandler($this->connection);
@@ -71,10 +71,10 @@ public function testGetServerVersion()
7171
public function testGetServerVersionWithDetails()
7272
{
7373
$result = $this->adminHandler->getServerVersion(true);
74-
static::assertInternalType('array', $result, 'The server version details must be an array!');
75-
static::assertInternalType(
74+
static::assertEquals('array', gettype($result), 'The server version details must be an array!');
75+
static::assertEquals(
7676
'array',
77-
$result['details'],
77+
gettype($result['details']),
7878
'The server version details must have a `details` array!'
7979
);
8080

@@ -262,7 +262,7 @@ public function testGetServerStatisticsDescription()
262262
}
263263

264264

265-
public function tearDown()
265+
public function tearDown(): void
266266
{
267267
unset($this->adminHandler, $this->connection);
268268
}

tests/AnalyzerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct($name = null, array $data = [], $dataName = '')
2929
}
3030

3131

32-
public function setUp()
32+
public function setUp(): void
3333
{
3434
$this->connection = getConnection();
3535
$this->analyzerHandler = new AnalyzerHandler($this->connection);
@@ -285,7 +285,7 @@ public function testDropNonExistingAnalyzer()
285285
static::assertEquals(404, $exception->getCode());
286286
}
287287

288-
public function tearDown()
288+
public function tearDown(): void
289289
{
290290
$this->analyzerHandler = new AnalyzerHandler($this->connection);
291291
try {

tests/AqlUserFunctionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct($name = null, array $data = [], $dataName = '')
3030
static::$testsTimestamp = str_replace('.', '', (string) microtime(true));
3131
}
3232

33-
public function setUp()
33+
public function setUp(): void
3434
{
3535
$this->connection = getConnection();
3636

@@ -378,7 +378,7 @@ public function testUnRegisterAQLFunctionsOnNamespace()
378378
static::assertEmpty($functions, 'phpTestFunctions namespace should only contain no functions.');
379379
}
380380

381-
public function tearDown()
381+
public function tearDown(): void
382382
{
383383
$this->cleanup();
384384
unset($this->connection);

tests/BatchTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct($name = null, array $data = [], $dataName = '')
2828
}
2929

3030

31-
public function setUp()
31+
public function setUp(): void
3232
{
3333
$this->connection = getConnection();
3434

@@ -614,7 +614,7 @@ public function testByExampleBatch()
614614
static::assertSame($document1->getHandle(), reset($all2)->getHandle());
615615
}
616616

617-
public function tearDown()
617+
public function tearDown(): void
618618
{
619619
try {
620620
$this->collectionHandler->drop('ArangoDB_PHP_TestSuite_TestCollection_01' . '_' . static::$testsTimestamp);

tests/CollectionBasicTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct($name = null, array $data = [], $dataName = '')
2727
}
2828

2929

30-
public function setUp()
30+
public function setUp(): void
3131
{
3232
$this->connection = getConnection();
3333
$this->collectionHandler = new CollectionHandler($this->connection);
@@ -1425,7 +1425,7 @@ public function testGetResponsibleShard()
14251425
}
14261426
}
14271427

1428-
public function tearDown()
1428+
public function tearDown(): void
14291429
{
14301430
try {
14311431
$this->collectionHandler->drop('ArangoDB_PHP_TestSuite_IndexTestCollection' . '_' . static::$testsTimestamp);

tests/CollectionExtendedTest.php

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct($name = null, array $data = [], $dataName = '')
3434
/**
3535
* Test set-up
3636
*/
37-
public function setUp()
37+
public function setUp(): void
3838
{
3939
$this->connection = getConnection();
4040
$this->collection = new Collection();
@@ -374,40 +374,6 @@ public function testCreateRenameAndDeleteCollection()
374374
}
375375

376376

377-
/**
378-
* test for creation, rename, and delete of a collection with wrong encoding
379-
*
380-
* We expect an exception here:
381-
*
382-
* @expectedException \ArangoDBClient\ClientException
383-
*
384-
*/
385-
public function testCreateRenameAndDeleteCollectionWithWrongEncoding()
386-
{
387-
$collection = $this->collection;
388-
$collectionHandler = $this->collectionHandler;
389-
390-
391-
$name = 'ArangoDB_PHP_TestSuite_TestCollection_01' . '_' . static::$testsTimestamp;
392-
$collection->setName($name);
393-
394-
$response = $collectionHandler->create($collection);
395-
396-
static::assertTrue(is_numeric($response), 'Adding collection did not return an id!');
397-
398-
$resultingCollection = $collectionHandler->get($name);
399-
400-
// inject wrong encoding
401-
$isoValue = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', 'ArangoDB_PHP_TestSuite_TestCollection_01_renamedü');
402-
403-
static::assertTrue($collectionHandler->rename($resultingCollection, $isoValue));
404-
405-
406-
$response = $collectionHandler->drop($resultingCollection);
407-
static::assertTrue($response, 'Delete should return true!');
408-
}
409-
410-
411377
/**
412378
* test for creation, get, and delete of a collection with waitForSync set to true
413379
*/
@@ -543,11 +509,10 @@ public function testRemoveByKeys()
543509

544510
/**
545511
* test for removal by keys with unknown collection
546-
*
547-
* @expectedException \ArangoDBClient\ServerException
548512
*/
549513
public function testRemoveByKeysCollectionNotFound()
550514
{
515+
$this->expectException(\ArangoDBClient\ServerException::class);
551516
$collectionHandler = $this->collectionHandler;
552517

553518
$keys = ['foo'];
@@ -2990,11 +2955,10 @@ public function testLookupByKeys()
29902955

29912956
/**
29922957
* test for lookup by keys with unknown collection
2993-
*
2994-
* @expectedException \ArangoDBClient\ServerException
29952958
*/
29962959
public function testLookupByCollectionNotFound()
29972960
{
2961+
$this->expectException(\ArangoDBClient\ServerException::class);
29982962
$collectionHandler = $this->collectionHandler;
29992963

30002964
$keys = ['foo'];
@@ -3004,7 +2968,7 @@ public function testLookupByCollectionNotFound()
30042968
/**
30052969
* Test tear-down
30062970
*/
3007-
public function tearDown()
2971+
public function tearDown(): void
30082972
{
30092973
try {
30102974
$this->collectionHandler->drop('ArangoDB_PHP_TestSuite_TestCollection_01' . '_' . static::$testsTimestamp);

tests/ConnectionTest.php

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct($name = null, array $data = [], $dataName = '')
3333
}
3434

3535

36-
public function setUp()
36+
public function setUp(): void
3737
{
3838
$this->connection = getConnection();
3939
$this->collectionHandler = new CollectionHandler($this->connection);
@@ -283,11 +283,10 @@ public function testTimeoutOptions()
283283

284284
/**
285285
* Test set invalid options
286-
*
287-
* @expectedException \ArangoDBClient\ClientException
288286
*/
289287
public function testSetEndpointOption()
290288
{
289+
$this->expectException(\ArangoDBClient\ClientException::class);
291290
$connection = getConnection();
292291

293292
// will fail!
@@ -296,11 +295,10 @@ public function testSetEndpointOption()
296295

297296
/**
298297
* Test set invalid options
299-
*
300-
* @expectedException \ArangoDBClient\ClientException
301298
*/
302299
public function testSetAllowSelfSignedOption()
303300
{
301+
$this->expectException(\ArangoDBClient\ClientException::class);
304302
$connection = getConnection();
305303

306304
// will fail!
@@ -309,11 +307,10 @@ public function testSetAllowSelfSignedOption()
309307

310308
/**
311309
* Test set invalid options
312-
*
313-
* @expectedException \ArangoDBClient\ClientException
314310
*/
315311
public function testSetVerifyCert()
316312
{
313+
$this->expectException(\ArangoDBClient\ClientException::class);
317314
$connection = getConnection();
318315

319316
// will fail!
@@ -322,11 +319,10 @@ public function testSetVerifyCert()
322319

323320
/**
324321
* Test set invalid options
325-
*
326-
* @expectedException \ArangoDBClient\ClientException
327322
*/
328323
public function testSetCiphers()
329324
{
325+
$this->expectException(\ArangoDBClient\ClientException::class);
330326
$connection = getConnection();
331327

332328
// will fail!
@@ -335,11 +331,10 @@ public function testSetCiphers()
335331

336332
/**
337333
* Test set invalid options
338-
*
339-
* @expectedException \ArangoDBClient\ClientException
340334
*/
341335
public function testSetHostOption()
342336
{
337+
$this->expectException(\ArangoDBClient\ClientException::class);
343338
$connection = getConnection();
344339

345340
// will fail!
@@ -348,11 +343,10 @@ public function testSetHostOption()
348343

349344
/**
350345
* Test set invalid options
351-
*
352-
* @expectedException \ArangoDBClient\ClientException
353346
*/
354347
public function testSetPortOption()
355348
{
349+
$this->expectException(\ArangoDBClient\ClientException::class);
356350
$connection = getConnection();
357351

358352
// will fail!
@@ -393,11 +387,10 @@ public function testGetSetDatabase()
393387

394388
/**
395389
* Test timeout exception
396-
*
397-
* @expectedException \ArangoDBClient\ClientException
398390
*/
399391
public function testSetTimeoutException()
400392
{
393+
$this->expectException(\ArangoDBClient\ClientException::class);
401394
$connection = getConnection();
402395
$connection->setOption(ConnectionOptions::OPTION_TIMEOUT, 3);
403396
$query = 'RETURN SLEEP(6)';
@@ -447,11 +440,10 @@ public function testSetConnectTimeout()
447440

448441
/**
449442
* Test request timeout exception
450-
*
451-
* @expectedException \ArangoDBClient\ClientException
452443
*/
453444
public function testSetRequestTimeoutException()
454445
{
446+
$this->expectException(\ArangoDBClient\ClientException::class);
455447
$connection = getConnection();
456448
$connection->setOption(ConnectionOptions::OPTION_CONNECT_TIMEOUT, 3);
457449
$connection->setOption(ConnectionOptions::OPTION_REQUEST_TIMEOUT, 2);
@@ -583,7 +575,7 @@ public function testBasicTracer()
583575
['send', 'receive'],
584576
'Basic tracer\'s type should only be \'send\' or \'receive\''
585577
);
586-
static::assertInternalType('string', $data, 'Basic tracer data is not a string!.');
578+
static::assertEquals('string', gettype($data), 'Basic tracer data is not a string!.');
587579
};
588580

589581
$options = getConnectionOptions();
@@ -614,9 +606,9 @@ public function testEnhancedTracer()
614606
'$data must be instance of TraceRequest or TraceResponse.'
615607
);
616608

617-
static::assertInternalType('array', $data->getHeaders(), 'Headers should be an array!');
609+
static::assertEquals('array', gettype($data->getHeaders()), 'Headers should be an array!');
618610
static::assertNotEmpty($data->getHeaders(), 'Headers should not be an empty array!');
619-
static::assertInternalType('string', $data->getBody(), 'Body must be a string!');
611+
static::assertEquals('string', gettype($data->getBody()), 'Body must be a string!');
620612

621613
if ($data instanceof TraceRequest) {
622614
static::assertContains(
@@ -632,22 +624,22 @@ public function testEnhancedTracer()
632624
'Invalid http method!'
633625
);
634626

635-
static::assertInternalType('string', $data->getRequestUrl(), 'Request url must be a string!');
627+
static::assertEquals('string', gettype($data->getRequestUrl()), 'Request url must be a string!');
636628
static::assertEquals('request', $data->getType());
637629

638630
foreach ($data->getHeaders() as $header => $value) {
639-
static::assertInternalType('string', $value, 'The header value should be a string');
640-
static::assertInternalType('string', $header, 'The header should be a string');
631+
static::assertEquals('string', gettype($value), 'The header value should be a string');
632+
static::assertEquals('string', gettype($header), 'The header should be a string');
641633
}
642634
} else {
643-
static::assertInternalType('integer', $data->getHttpCode(), 'Http code must be an integer!');
644-
static::assertInternalType(
635+
static::assertEquals('integer', gettype($data->getHttpCode()), 'Http code must be an integer!');
636+
static::assertEquals(
645637
'string',
646-
$data->getHttpCodeDefinition(),
638+
gettype($data->getHttpCodeDefinition()),
647639
'Http code definition must be a string!'
648640
);
649641
static::assertEquals('response', $data->getType());
650-
static::assertInternalType('float', $data->getTimeTaken());
642+
static::assertIsFloat($data->getTimeTaken());
651643
}
652644
};
653645

@@ -668,7 +660,7 @@ public function testEnhancedTracer()
668660
}
669661
}
670662

671-
public function tearDown()
663+
public function tearDown(): void
672664
{
673665
unset($this->connection);
674666

tests/CustomDocumentClassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct($name = null, array $data = [], $dataName = '')
3333
}
3434

3535

36-
public function setUp()
36+
public function setUp(): void
3737
{
3838
$this->connection = getConnection();
3939
$this->collectionHandler = new CollectionHandler($this->connection);
@@ -163,7 +163,7 @@ public function testGetCustomDocumentWithBatch()
163163
}
164164

165165

166-
public function tearDown()
166+
public function tearDown(): void
167167
{
168168
try {
169169
$this->collectionHandler->drop('ArangoDB_PHP_TestSuite_TestCollection_01' . '_' . static::$testsTimestamp);

0 commit comments

Comments
 (0)