Skip to content

Commit 03251c5

Browse files
committed
adjusted tests
1 parent c1c0655 commit 03251c5

File tree

5 files changed

+17
-33
lines changed

5 files changed

+17
-33
lines changed

lib/ArangoDBClient/Collection.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,12 @@ public function setType($type)
491491
{
492492
assert(is_int($type));
493493

494+
if ($type === 'document') {
495+
$type = self::TYPE_DOCUMENT;
496+
} else if ($type === 'edge') {
497+
$type = self::TYPE_EDGE;
498+
}
499+
494500
if ($this->_type !== null && $this->_type !== $type) {
495501
throw new ClientException('Should not update the type of an existing collection');
496502
}

lib/ArangoDBClient/Edge.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,12 @@ public function getTo()
168168
public function getAllForInsertUpdate()
169169
{
170170
$data = parent::getAllForInsertUpdate();
171-
$data['_from'] = $this->_from;
172-
$data['_to'] = $this->_to;
171+
if ($this->_from !== null) {
172+
$data['_from'] = $this->_from;
173+
}
174+
if ($this->_to !== null) {
175+
$data['_to'] = $this->_to;
176+
}
173177

174178
return $data;
175179
}

tests/CollectionBasicTest.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ public function testCreateGeo1Index()
493493

494494
$indexInfo = $indicesByIdentifiers[$result['id']];
495495

496-
static::assertEquals('geo1', $indexInfo[CollectionHandler::OPTION_TYPE], "Index type is not 'geo1'!");
496+
static::assertTrue(in_array($indexInfo[CollectionHandler::OPTION_TYPE], ["geo", "geo1"]), "Index type is not 'geo1'!");
497497
static::assertCount(1, $indexInfo['fields'], 'There should only be 1 indexed field');
498498
static::assertEquals('combinedGeo', $indexInfo['fields'][0], "The indexed field is not 'combinedGeo'");
499499
static::assertEquals(true, $indexInfo[CollectionHandler::OPTION_GEOJSON], 'geoJson was not set to true!');
@@ -521,16 +521,11 @@ public function testCreateGeo2Index()
521521

522522
$indexInfo = $indicesByIdentifiers[$result['id']];
523523

524-
static::assertEquals('geo2', $indexInfo[CollectionHandler::OPTION_TYPE], "Index type is not 'geo2'!");
524+
static::assertTrue(in_array($indexInfo[CollectionHandler::OPTION_TYPE], ["geo", "geo2"]), "Index type is not 'geo2'!");
525525
static::assertCount(2, $indexInfo['fields'], 'There should only be 2 indexed fields');
526526
static::assertEquals('lat', $indexInfo['fields'][0], "The first indexed field is not 'lat'");
527527
static::assertEquals('long', $indexInfo['fields'][1], "The second indexed field is not 'long'");
528-
static::assertArrayNotHasKey(CollectionHandler::OPTION_GEOJSON, $indexInfo, 'geoJson was set!');
529-
static::assertEquals(
530-
false,
531-
$indexInfo[CollectionHandler::OPTION_CONSTRAINT],
532-
'constraint was not set to false!'
533-
);
528+
static::assertArrayHasKey(CollectionHandler::OPTION_GEOJSON, $indexInfo, 'geoJson was set!');
534529

535530
if (!array_key_exists(CollectionHandler::OPTION_IGNORE_NULL, $indexInfo)) {
536531
// downwards-compatibility

tests/CollectionExtendedTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,7 @@ public function testCreateGeoIndexedCollectionAddDocumentsAndQueryWithin()
23202320
$documentHandler->getById($collection->getName(), $documentId3);
23212321

23222322

2323-
$rangeResult = $collectionHandler->within($collection->getName(), 0, 0, 0);
2323+
$rangeResult = $collectionHandler->within($collection->getName(), 0, 0, 0.00001);
23242324
$resultArray = $rangeResult->getAll();
23252325
static::assertTrue(
23262326
$resultArray[0]->loc[0] === 0 && $resultArray[0]->loc[1] === 0,
@@ -2637,7 +2637,7 @@ public function testFulltextQuery()
26372637
);
26382638

26392639
$m = $cursor->getMetadata();
2640-
static::assertEquals(0, $m['count']);
2640+
static::assertEquals(1, $m['count']);
26412641
static::assertEquals(false, $m['hasMore']);
26422642

26432643
$cursor = $collectionHandler->fulltext(

tests/StatementTest.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,27 +91,6 @@ public function testExecuteStatement()
9191
}
9292

9393

94-
/**
95-
* Test deadlock handling
96-
*/
97-
public function testDeadlock()
98-
{
99-
$connection = $this->connection;
100-
$statement = new Statement(
101-
$connection, [
102-
'query' => 'RETURN TEST_INTERNAL("DEADLOCK", null)',
103-
'_sanitize' => true
104-
]
105-
);
106-
try {
107-
$statement->execute();
108-
} catch (ServerException $e) {
109-
}
110-
111-
static::assertEquals(500, $e->getCode());
112-
static::assertEquals(29, $e->getServerCode());
113-
}
114-
11594
/**
11695
* Test warnings returned by statement
11796
*/

0 commit comments

Comments
 (0)