Skip to content

Commit cd9e926

Browse files
committed
Merge branch 'connection_tests_close_and_keep-alive' into issue207
# Conflicts: # tests/CollectionExtendedTest.php # tests/GraphBasicTest.php # tests/GraphExtendedTest.php
2 parents ac427b2 + b2c34c1 commit cd9e926

22 files changed

+504
-375
lines changed

.idea/php.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ before_script:
1212
- ./tests/travis/setup_arangodb.sh
1313

1414
script:
15-
- phpunit --configuration ./tests/phpunit.xml
15+
- phpunit --configuration ./tests/phpunit-connection-close.xml
16+
- phpunit --configuration ./tests/phpunit-connection-keep-alive.xml
1617

1718
after_script:
1819
- ./tests/travis/teardown_arangodb.sh

tests/AqlUserFunctionTest.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function testRegisterListAndUnRegisterAqlUserFunctionWithInitialConfig()
8181
$result = $userFunction->register();
8282

8383
static::assertEquals(
84-
$result['error'], false, 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
84+
false, $result['error'], 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
8585
);
8686
$list = $this->filter($userFunction->getRegisteredUserFunctions());
8787

@@ -95,7 +95,7 @@ public function testRegisterListAndUnRegisterAqlUserFunctionWithInitialConfig()
9595
$result = $userFunction->unregister();
9696

9797
static::assertEquals(
98-
$result['error'], false, 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
98+
false, $result['error'], 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
9999
);
100100
}
101101

@@ -113,7 +113,7 @@ public function testRegisterListAndUnRegisterAqlUserFunctionUsingShortcut()
113113
$result = $userFunction->register($name, $code);
114114

115115
static::assertEquals(
116-
$result['error'], false, 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
116+
false, $result['error'], 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
117117
);
118118
$list = $this->filter($userFunction->getRegisteredUserFunctions());
119119

@@ -126,7 +126,7 @@ public function testRegisterListAndUnRegisterAqlUserFunctionUsingShortcut()
126126
$result = $userFunction->unregister($name);
127127

128128
static::assertEquals(
129-
$result['error'], false, 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
129+
false, $result['error'], 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
130130
);
131131
}
132132

@@ -146,28 +146,28 @@ public function testRegisterListAndUnRegisterAqlUserFunctionWithGettersAndSetter
146146

147147
// check if getters work fine
148148
static::assertEquals(
149-
$userFunction->getName(), $name, 'Did not return name, instead returned: ' . $userFunction->getName()
149+
$name, $userFunction->getName(), 'Did not return name, instead returned: ' . $userFunction->getName()
150150
);
151151
static::assertEquals(
152-
$userFunction->getCode(), $code, 'Did not return code, instead returned: ' . $userFunction->getCode()
152+
$code, $userFunction->getCode(), 'Did not return code, instead returned: ' . $userFunction->getCode()
153153
);
154154

155155

156156
// also check setters/getters if wrong/no attribute is given
157157
static::assertEquals(
158-
$userFunction->getFakeAttributeName, null, 'Getter with unknown attribute did not return null, instead returned: ' . $userFunction->getFakeAttributeName
158+
null, $userFunction->getFakeAttributeName, 'Getter with unknown attribute did not return null, instead returned: ' . $userFunction->getFakeAttributeName
159159
);
160160

161161
static::assertEquals(
162-
$userFunction->setFakeAttributeName, null, 'Setter with unknown attribute did not return chainable object, instead returned..: ' . $userFunction->setFakeAttributeName
162+
null, $userFunction->setFakeAttributeName, 'Setter with unknown attribute did not return chainable object, instead returned..: ' . $userFunction->setFakeAttributeName
163163
);
164164

165165
// Check setting/getting class properties via set/get methods
166166
static::assertSame(
167-
$userFunction->set('FakeAttributeName', 1), $userFunction, 'Set-method did not return chainable object'
167+
$userFunction, $userFunction->set('FakeAttributeName', 1), 'Set-method did not return chainable object'
168168
);
169169
static::assertSame(
170-
$userFunction->get('FakeAttributeName'), 1, 'Get-method did not return previously set property'
170+
1, $userFunction->get('FakeAttributeName'), 'Get-method did not return previously set property'
171171
);
172172

173173
// Check giving the set method a non-string key
@@ -184,7 +184,7 @@ public function testRegisterListAndUnRegisterAqlUserFunctionWithGettersAndSetter
184184
$result = $userFunction->register();
185185

186186
static::assertEquals(
187-
$result['error'], false, 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
187+
false, $result['error'], 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
188188
);
189189
$list = $this->filter($userFunction->getRegisteredUserFunctions());
190190
static::assertCount(1, $list, 'List returned did not return expected 1 attribute');
@@ -196,7 +196,7 @@ public function testRegisterListAndUnRegisterAqlUserFunctionWithGettersAndSetter
196196
$result = $userFunction->unregister();
197197

198198
static::assertEquals(
199-
$result['error'], false, 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
199+
false, $result['error'], 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
200200
);
201201
}
202202

@@ -218,16 +218,16 @@ public function testRegisterListAndUnRegisterAqlUserFunctionWithWithMagicSetters
218218

219219
// check if getters work fine
220220
static::assertEquals(
221-
$userFunction->name, $name, 'Did not return name, instead returned: ' . $userFunction->name
221+
$name, $userFunction->name, 'Did not return name, instead returned: ' . $userFunction->name
222222
);
223223
static::assertEquals(
224-
$userFunction->code, $code, 'Did not return code, instead returned: ' . $userFunction->code
224+
$code, $userFunction->code, 'Did not return code, instead returned: ' . $userFunction->code
225225
);
226226

227227
$result = $userFunction->register();
228228

229229
static::assertEquals(
230-
$result['error'], false, 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
230+
false, $result['error'], 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
231231
);
232232
$list = $this->filter($userFunction->getRegisteredUserFunctions());
233233
static::assertCount(1, $list, 'List returned did not return expected 1 attribute');
@@ -239,7 +239,7 @@ public function testRegisterListAndUnRegisterAqlUserFunctionWithWithMagicSetters
239239
$result = $userFunction->unregister();
240240

241241
static::assertEquals(
242-
$result['error'], false, 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
242+
false, $result['error'], 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
243243
);
244244
}
245245

@@ -263,13 +263,13 @@ public function testReRegisterListAndUnRegisterAqlUserFunctionTwice()
263263
$result = $userFunction->register();
264264

265265
static::assertEquals(
266-
$result['error'], false, 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
266+
false, $result['error'], 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
267267
);
268268

269269
$result = $userFunction->register();
270270

271271
static::assertEquals(
272-
$result['error'], false, 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
272+
false, $result['error'], 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
273273
);
274274

275275
$list = $this->filter($userFunction->getRegisteredUserFunctions());
@@ -282,7 +282,7 @@ public function testReRegisterListAndUnRegisterAqlUserFunctionTwice()
282282
$result = $userFunction->unregister();
283283

284284
static::assertEquals(
285-
$result['error'], false, 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
285+
false, $result['error'], 'result[\'error\'] Did not return false, instead returned: ' . print_r($result, 1)
286286
);
287287

288288
$e = null;
@@ -292,7 +292,7 @@ public function testReRegisterListAndUnRegisterAqlUserFunctionTwice()
292292
}
293293

294294
static::assertEquals(
295-
$e->getCode(), 404, 'Did not return code 404, instead returned: ' . $e->getCode()
295+
404, $e->getCode(), 'Did not return code 404, instead returned: ' . $e->getCode()
296296
);
297297
}
298298

tests/BatchTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public function testCreateDocumentBatchWithDefinedBatchSize()
212212

213213
static::assertInstanceOf(BatchPart::class, $documentId, 'Did not return a BatchPart Object!');
214214

215-
static::assertEquals($batch->getConnectionCaptureMode($this->connection), true);
215+
static::assertEquals(true, $batch->getConnectionCaptureMode($this->connection));
216216

217217
$batch->stopCapture();
218218

@@ -297,12 +297,12 @@ public function testCreateMixedBatchWithPartIds()
297297

298298
$resultingCollectionId = $batch->getProcessedPartResponse('testCollection1');
299299
$testCollection1Part = $batch->getPart('testCollection1');
300-
static::assertEquals($testCollection1Part->getHttpCode(), 200, 'Did not return an HttpCode 200!');
300+
static::assertEquals(200, $testCollection1Part->getHttpCode(), 'Did not return an HttpCode 200!');
301301
$resultingCollection = $collectionHandler->get($batch->getProcessedPartResponse('testCollection1'));
302302

303303
$resultingAttribute = $resultingCollection->getName();
304304
static::assertSame(
305-
$name, $resultingAttribute, 'The created collection name and resulting collection name do not match!'
305+
$resultingAttribute, $name, 'The created collection name and resulting collection name do not match!'
306306
);
307307

308308
static::assertEquals(Collection::getDefaultType(), $resultingCollection->getType());
@@ -318,7 +318,7 @@ public function testCreateMixedBatchWithPartIds()
318318
);
319319
$documentBatchPart = $documentHandler->save($resultingCollectionId, $document);
320320

321-
static::assertEquals($documentBatchPart->getType(), 'document');
321+
static::assertEquals('document', $documentBatchPart->getType());
322322

323323
static::assertInstanceOf(BatchPart::class, $documentBatchPart, 'Did not return a BatchPart Object!');
324324

@@ -375,7 +375,7 @@ public function testCreateMixedBatchWithPartIds()
375375
is_a($edge, HttpResponse::class),
376376
'Edge batch creation did return an error: ' . print_r($edge, true)
377377
);
378-
static::assertNotSame($edge, '', 'Edge batch creation did return empty string: ' . print_r($edge, true));
378+
static::assertNotSame('', $edge, 'Edge batch creation did return empty string: ' . print_r($edge, true));
379379

380380

381381
$batch = new Batch($this->connection);

tests/CollectionBasicTest.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function testCreateAndDeleteCollectionPre1_2()
120120

121121
$resultingAttribute = $resultingCollection->getName();
122122
static::assertSame(
123-
$name, $resultingAttribute, 'The created collection name and resulting collection name do not match!'
123+
$resultingAttribute, $name, 'The created collection name and resulting collection name do not match!'
124124
);
125125

126126
static::assertEquals(Collection::getDefaultType(), $resultingCollection->getType());
@@ -159,25 +159,25 @@ public function testCreateCollectionWithKeyOptionsAndVerifyProperties()
159159
$resultingCollection = $collectionHandler->getProperties($response);
160160
$properties = $resultingCollection->getAll();
161161

162-
static::assertEquals($properties[Collection::ENTRY_STATUS], 3, 'Status does not match.');
162+
static::assertEquals(3, $properties[Collection::ENTRY_STATUS], 'Status does not match.');
163163
static::assertEquals(
164-
$properties[Collection::ENTRY_KEY_OPTIONS]['type'],
165164
'autoincrement',
165+
$properties[Collection::ENTRY_KEY_OPTIONS]['type'],
166166
'Key options type does not match'
167167
);
168168
static::assertEquals(
169-
$properties[Collection::ENTRY_KEY_OPTIONS]['allowUserKeys'],
170169
false,
170+
$properties[Collection::ENTRY_KEY_OPTIONS]['allowUserKeys'],
171171
'Key options allowUserKeys does not match'
172172
);
173173
static::assertEquals(
174-
$properties[Collection::ENTRY_KEY_OPTIONS]['increment'],
175174
5,
175+
$properties[Collection::ENTRY_KEY_OPTIONS]['increment'],
176176
'Key options increment does not match'
177177
);
178178
static::assertEquals(
179-
$properties[Collection::ENTRY_KEY_OPTIONS]['offset'],
180179
10,
180+
$properties[Collection::ENTRY_KEY_OPTIONS]['offset'],
181181
'Key options offset does not match'
182182
);
183183
$collectionHandler->drop($collection);
@@ -216,7 +216,7 @@ public function testCreateCollectionWithKeyOptionsCluster()
216216
} catch (\Exception $e) {
217217
}
218218

219-
static::assertEquals($e->getCode(), 501);
219+
static::assertEquals(501, $e->getCode());
220220
}
221221

222222

@@ -250,8 +250,8 @@ public function testCreateCollectionWithNumberOfShardsCluster()
250250
$resultingCollection = $collectionHandler->getProperties($response);
251251
$properties = $resultingCollection->getAll();
252252

253-
static::assertEquals($properties[Collection::ENTRY_NUMBER_OF_SHARDS], 4, 'Number of shards does not match.');
254-
static::assertEquals($properties[Collection::ENTRY_SHARD_KEYS], ['_key'], 'Shard keys do not match.');
253+
static::assertEquals(4, $properties[Collection::ENTRY_NUMBER_OF_SHARDS], 'Number of shards does not match.');
254+
static::assertEquals(['_key'], $properties[Collection::ENTRY_SHARD_KEYS], 'Shard keys do not match.');
255255
}
256256

257257

@@ -285,13 +285,15 @@ public function testCreateCollectionWithShardKeysCluster()
285285
$resultingCollection = $collectionHandler->getProperties($response);
286286
$properties = $resultingCollection->getAll();
287287

288-
static::assertEquals($properties[Collection::ENTRY_NUMBER_OF_SHARDS], 1, 'Number of shards does not match.');
288+
static::assertEquals(1, $properties[Collection::ENTRY_NUMBER_OF_SHARDS], 'Number of shards does not match.');
289289
static::assertEquals(
290-
$properties[Collection::ENTRY_SHARD_KEYS], [
291-
'_key',
292-
'a',
293-
'b'
294-
], 'Shard keys do not match.'
290+
[
291+
'_key',
292+
'a',
293+
'b'
294+
],
295+
$properties[Collection::ENTRY_SHARD_KEYS],
296+
'Shard keys do not match.'
295297
);
296298
}
297299

@@ -320,7 +322,7 @@ public function testCreateAndDeleteCollection()
320322

321323
$resultingAttribute = $resultingCollection->getName();
322324
static::assertSame(
323-
$name, $resultingAttribute, 'The created collection name and resulting collection name do not match!'
325+
$resultingAttribute, $name, 'The created collection name and resulting collection name do not match!'
324326
);
325327

326328
static::assertEquals(Collection::getDefaultType(), $resultingCollection->getType());
@@ -354,7 +356,7 @@ public function testCreateAndDeleteEdgeCollection()
354356

355357
$resultingAttribute = $resultingCollection->getName();
356358
static::assertSame(
357-
$name, $resultingAttribute, 'The created collection name and resulting collection name do not match!'
359+
$resultingAttribute, $name, 'The created collection name and resulting collection name do not match!'
358360
);
359361

360362
static::assertEquals(Collection::TYPE_EDGE, $resultingCollection->getType());
@@ -386,7 +388,7 @@ public function testCreateAndDeleteEdgeCollectionWithoutCreatingObject()
386388

387389
$resultingAttribute = $resultingCollection->getName();
388390
static::assertSame(
389-
$name, $resultingAttribute, 'The created collection name and resulting collection name do not match!'
391+
$resultingAttribute, $name, 'The created collection name and resulting collection name do not match!'
390392
);
391393

392394
static::assertEquals(Collection::TYPE_EDGE, $resultingCollection->getType());
@@ -417,7 +419,7 @@ public function testCreateAndDeleteVolatileCollectionWithoutCreatingObject()
417419

418420
$resultingAttribute = $resultingCollection->getName();
419421
static::assertSame(
420-
$name, $resultingAttribute, 'The created collection name and resulting collection name do not match!'
422+
$resultingAttribute, $name, 'The created collection name and resulting collection name do not match!'
421423
);
422424
$resultingCollectionProperties = $collectionHandler->getProperties($name);
423425
static::assertTrue($resultingCollectionProperties->getIsVolatile());
@@ -449,7 +451,7 @@ public function testCreateAndDeleteSystemCollectionWithoutCreatingObject()
449451

450452
$resultingAttribute = $resultingCollection->getName();
451453
static::assertSame(
452-
$name, $resultingAttribute, 'The created collection name and resulting collection name do not match!'
454+
$resultingAttribute, $name, 'The created collection name and resulting collection name do not match!'
453455
);
454456
$resultingCollectionProperties = $collectionHandler->getProperties($name);
455457
static::assertTrue($resultingCollectionProperties->getIsSystem());

0 commit comments

Comments
 (0)