Skip to content

Commit 17f9937

Browse files
committed
Modernized some things in tests.
Also did some code reformatting.
1 parent 41247e6 commit 17f9937

16 files changed

+123
-122
lines changed

tests/BatchTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testPartIds()
8888

8989
for ($i = 0; $i < 10; ++$i) {
9090
$part = $batch->getPart('doc' . $i);
91-
static::assertInstanceOf('\ArangoDBClient\BatchPart', $part);
91+
static::assertInstanceOf(BatchPart::class, $part);
9292

9393
static::assertEquals('doc' . $i, $part->getId());
9494
static::assertEquals(202, $part->getHttpCode());
@@ -123,7 +123,7 @@ public function testProcessProcess()
123123
$this->collectionHandler->create($collection);
124124

125125
$part = $batch->getPart(0);
126-
static::assertInstanceOf('\ArangoDBClient\BatchPart', $part);
126+
static::assertInstanceOf(BatchPart::class, $part);
127127
static::assertEquals(202, $part->getHttpCode());
128128

129129
// call process once (this does not clear the batch)
@@ -149,15 +149,15 @@ public function testCreateDocumentBatch()
149149
// not needed, but just here to test if anything goes wrong if it's called again...
150150
$batch->startCapture();
151151

152-
static::assertInstanceOf('\ArangoDBClient\Batch', $batch);
152+
static::assertInstanceOf(Batch::class, $batch);
153153
$documentHandler = $this->documentHandler;
154154

155155
$document = Document::createFromArray(
156156
['someAttribute' => 'someValue', 'someOtherAttribute' => 'someOtherValue']
157157
);
158158
$documentId = $documentHandler->save($this->collection->getId(), $document);
159159

160-
static::assertInstanceOf('\ArangoDBClient\BatchPart', $documentId, 'Did not return a BatchPart Object!');
160+
static::assertInstanceOf(BatchPart::class, $documentId, 'Did not return a BatchPart Object!');
161161

162162
$batchPartId = $documentId->getId();
163163

@@ -166,7 +166,7 @@ public function testCreateDocumentBatch()
166166
);
167167
$documentId = $documentHandler->save($this->collection->getId(), $document);
168168

169-
static::assertInstanceOf('\ArangoDBClient\BatchPart', $documentId, 'Did not return a BatchPart Object!');
169+
static::assertInstanceOf(BatchPart::class, $documentId, 'Did not return a BatchPart Object!');
170170

171171
$batch->process();
172172

@@ -186,22 +186,22 @@ public function testCreateDocumentBatchWithDefinedBatchSize()
186186
// not needed, but just here to test if anything goes wrong if it's called again...
187187
$batch->startCapture();
188188

189-
static::assertInstanceOf('\ArangoDBClient\Batch', $batch);
189+
static::assertInstanceOf(Batch::class, $batch);
190190
$documentHandler = $this->documentHandler;
191191

192192
$document = Document::createFromArray(
193193
['someAttribute' => 'someValue', 'someOtherAttribute' => 'someOtherValue']
194194
);
195195
$documentId = $documentHandler->save($this->collection->getId(), $document);
196196

197-
static::assertInstanceOf('\ArangoDBClient\BatchPart', $documentId, 'Did not return a BatchPart Object!');
197+
static::assertInstanceOf(BatchPart::class, $documentId, 'Did not return a BatchPart Object!');
198198

199199
$document = Document::createFromArray(
200200
['someAttribute' => 'someValue2', 'someOtherAttribute' => 'someOtherValue2']
201201
);
202202
$documentId = $documentHandler->save($this->collection->getId(), $document);
203203

204-
static::assertInstanceOf('\ArangoDBClient\BatchPart', $documentId, 'Did not return a BatchPart Object!');
204+
static::assertInstanceOf(BatchPart::class, $documentId, 'Did not return a BatchPart Object!');
205205

206206
static::assertEquals($batch->getConnectionCaptureMode($this->connection), true);
207207

@@ -238,15 +238,15 @@ public function testFailureWhenCreatingMoreDocumentsInBatchThanDefinedBatchSize(
238238
// not needed, but just here to test if anything goes wrong if it's called again...
239239
$batch->startCapture();
240240

241-
static::assertInstanceOf('\ArangoDBClient\Batch', $batch);
241+
static::assertInstanceOf(Batch::class, $batch);
242242
$documentHandler = $this->documentHandler;
243243

244244
$document = Document::createFromArray(
245245
['someAttribute' => 'someValue', 'someOtherAttribute' => 'someOtherValue']
246246
);
247247
$documentId = $documentHandler->save($this->collection->getId(), $document);
248248

249-
static::assertInstanceOf('\ArangoDBClient\BatchPart', $documentId, 'Did not return a BatchPart Object!');
249+
static::assertInstanceOf(BatchPart::class, $documentId, 'Did not return a BatchPart Object!');
250250

251251
$document = Document::createFromArray(
252252
['someAttribute' => 'someValue2', 'someOtherAttribute' => 'someOtherValue2']
@@ -257,7 +257,7 @@ public function testFailureWhenCreatingMoreDocumentsInBatchThanDefinedBatchSize(
257257
// don't bother us, just give us the $e
258258
}
259259
static::assertInstanceOf(
260-
'RuntimeException',
260+
\RuntimeException::class,
261261
$e,
262262
'Exception thrown was not a RuntimeException!'
263263
);
@@ -270,7 +270,7 @@ public function testCreateMixedBatchWithPartIds()
270270
$edgeCollection = $this->edgeCollection;
271271

272272
$batch = new Batch($this->connection);
273-
static::assertInstanceOf('\ArangoDBClient\Batch', $batch);
273+
static::assertInstanceOf(Batch::class, $batch);
274274

275275
// Create collection
276276
$connection = $this->connection;
@@ -311,7 +311,7 @@ public function testCreateMixedBatchWithPartIds()
311311

312312
static::assertEquals($documentBatchPart->getType(), 'document');
313313

314-
static::assertInstanceOf('\ArangoDBClient\BatchPart', $documentBatchPart, 'Did not return a BatchPart Object!');
314+
static::assertInstanceOf(BatchPart::class, $documentBatchPart, 'Did not return a BatchPart Object!');
315315

316316
for ($i = 0; $i <= 10; ++$i) {
317317
$document = Document::createFromArray(
@@ -322,7 +322,7 @@ public function testCreateMixedBatchWithPartIds()
322322
);
323323
$documentBatchPart = $documentHandler->save($resultingCollectionId, $document);
324324
}
325-
static::assertInstanceOf('\ArangoDBClient\BatchPart', $documentBatchPart, 'Did not return a BatchPart Object!');
325+
static::assertInstanceOf(BatchPart::class, $documentBatchPart, 'Did not return a BatchPart Object!');
326326

327327
$batch->process();
328328

@@ -363,7 +363,7 @@ public function testCreateMixedBatchWithPartIds()
363363

364364

365365
static::assertFalse(
366-
is_a($edge, 'ArangoDBClient\HttpResponse'),
366+
is_a($edge, HttpResponse::class),
367367
'Edge batch creation did return an error: ' . print_r($edge, true)
368368
);
369369
static::assertNotSame($edge, '', 'Edge batch creation did return empty string: ' . print_r($edge, true));

tests/CollectionBasicTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function setUp()
3232
$this->collectionHandler->create('ArangoDB_PHP_TestSuite_IndexTestCollection');
3333

3434
$adminHandler = new AdminHandler($this->connection);
35-
$version = preg_replace("/-[a-z0-9]+$/", '', $adminHandler->getServerVersion());
35+
$version = preg_replace('/-[a-z0-9]+$/', '', $adminHandler->getServerVersion());
3636

3737
$this->hasSparseIndexes = (version_compare($version, '2.5.0') >= 0);
3838
$this->hasSelectivityEstimates = (version_compare($version, '2.5.0') >= 0);
@@ -55,9 +55,9 @@ public function testInitializeCollection()
5555
{
5656
$connection = $this->connection;
5757
$collection = new Collection();
58-
static::assertInstanceOf('ArangoDBClient\Collection', $collection);
58+
static::assertInstanceOf(Collection::class, $collection);
5959
new CollectionHandler($connection);
60-
static::assertInstanceOf('ArangoDBClient\Collection', $collection);
60+
static::assertInstanceOf(Collection::class, $collection);
6161
}
6262

6363

tests/CollectionExtendedTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,7 +2480,7 @@ public function testAnyDocumentInNonExistentCollection()
24802480
$collectionHandler->any('collection_that_does_not_exist');
24812481
} catch (ServerException $e) {
24822482
static::assertInstanceOf(
2483-
'\ArangoDBClient\ServerException',
2483+
ServerException::class,
24842484
$e,
24852485
'Exception thrown was not a ServerException!'
24862486
);
@@ -2626,7 +2626,7 @@ public function testLookupByKeys()
26262626

26272627
$document = $result[0];
26282628
static::assertInstanceOf(
2629-
'\ArangoDBClient\Document',
2629+
Document::class,
26302630
$document,
26312631
'Object was not a Document!'
26322632
);
@@ -2638,7 +2638,7 @@ public function testLookupByKeys()
26382638

26392639
$document = $result[1];
26402640
static::assertInstanceOf(
2641-
'\ArangoDBClient\Document',
2641+
Document::class,
26422642
$document,
26432643
'Object was not a Document!'
26442644
);
@@ -2650,7 +2650,7 @@ public function testLookupByKeys()
26502650

26512651
$document = $result[2];
26522652
static::assertInstanceOf(
2653-
'\ArangoDBClient\Document',
2653+
Document::class,
26542654
$document,
26552655
'Object was not a Document!'
26562656
);

tests/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function setUp()
4242
public function testInitializeConnection()
4343
{
4444
$connection = getConnection();
45-
static::assertInstanceOf('ArangoDBClient\Connection', $connection);
45+
static::assertInstanceOf(Connection::class, $connection);
4646
}
4747

4848

tests/DatabaseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function testDeleteNonExistentDatabase()
150150
} catch (\Exception $e) {
151151
// don't bother us... just give us the $e
152152
}
153-
static::assertInstanceOf('ArangoDBClient\ServerException', $e);
153+
static::assertInstanceOf(ServerException::class, $e);
154154
static::assertEquals($e->getCode(), 404, 'Should be 404, instead got: ' . $e->getCode());
155155
}
156156

@@ -191,7 +191,7 @@ public function testCreateDatabaseSwitchToItAndCreateAnotherOne()
191191
} catch (\Exception $e) {
192192
// don't bother us... just give us the $e
193193
}
194-
static::assertInstanceOf('ArangoDBClient\ServerException', $e);
194+
static::assertInstanceOf(ServerException::class, $e);
195195
static::assertEquals($e->getCode(), 403, 'Should be 403, instead got: ' . $e->getCode());
196196

197197

tests/DocumentBasicTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public function testInitializeDocument()
4141
$this->collection = new Collection();
4242
$this->collectionHandler = new CollectionHandler($this->connection);
4343
$document = new Document();
44-
static::assertInstanceOf('ArangoDBClient\Document', $document);
45-
static::assertInstanceOf('ArangoDBClient\Document', $document);
44+
static::assertInstanceOf(Document::class, $document);
45+
static::assertInstanceOf(Document::class, $document);
4646
unset ($document);
4747
}
4848

@@ -181,10 +181,10 @@ public function testCreateAndDeleteDocumentWithSeveralKeys()
181181
'@foobar',
182182
'(valid)',
183183
'%valid',
184-
"\$valid",
184+
'$valid',
185185
"$\$bill,y'all",
186-
"'valid",
187-
"'a-key-is-a-key-is-a-key'",
186+
'\'valid',
187+
'\'a-key-is-a-key-is-a-key\'',
188188
'm+ller',
189189
';valid',
190190
',valid',
@@ -202,8 +202,8 @@ public function testCreateAndDeleteDocumentWithSeveralKeys()
202202
':-)',
203203
'!',
204204
'!!!!',
205-
"'",
206-
"''''",
205+
'\'',
206+
'\'\'\'\'',
207207
"this-key's-valid.",
208208
'=',
209209
'==================================================',
@@ -220,7 +220,7 @@ public function testCreateAndDeleteDocumentWithSeveralKeys()
220220
];
221221

222222
$adminHandler = new AdminHandler($this->connection);
223-
$version = preg_replace("/-[a-z0-9]+$/", '', $adminHandler->getServerVersion());
223+
$version = preg_replace('/-[a-z0-9]+$/', '', $adminHandler->getServerVersion());
224224

225225
if (version_compare($version, '2.6.0') >= 0) {
226226
// 2.6 will also allow the following document keys, while 2.5 will not
@@ -467,12 +467,12 @@ public function testCreateAndDeleteDocumentUsingDefinedKeyWithArrayAndSaveOnly()
467467
$documentHandler->removeById($collection->getName(), $documentId);
468468
}
469469

470-
/**
470+
/**
471471
* Try to create a document and get valid JSON when cast to string.
472472
*/
473473
public function testCreateAndVerifyValidJsonIsReturnedWhenCastToString()
474474
{
475-
$document = Document::createFromArray(
475+
$document = Document::createFromArray(
476476
['someAttribute' => 'someValue', 'someOtherAttribute' => 'someOtherValue']
477477
);
478478

0 commit comments

Comments
 (0)