Skip to content

Commit 4c2a126

Browse files
committed
Adopt expectation API
1 parent 6b955e4 commit 4c2a126

13 files changed

+171
-171
lines changed

tests/AdminManagerTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
test('get version', function () {
1414
$result = $this->adminManager->getVersion();
1515

16-
$this->assertSame('arango', $result->server);
17-
$this->assertSame('community', $result->license);
18-
$this->assertIsString($result->version);
16+
expect($result->server)->toBe('arango');
17+
expect($result->license)->toBe('community');
18+
expect($result->version)->toBeString();
1919
});
2020

2121
test('get version with details', function () {
2222
$result = $this->adminManager->getVersion(true);
2323

24-
$this->assertSame('arango', $result->server);
25-
$this->assertSame('community', $result->license);
26-
$this->assertIsString($result->version);
24+
expect($result->server)->toBe('arango');
25+
expect($result->license)->toBe('community');
26+
expect($result->version)->toBeString();
2727
});
2828

2929
test('get running transactions', function () {
3030
$transactions = $this->adminManager->getRunningTransactions();
31-
$this->assertEmpty($transactions);
31+
expect($transactions)->toBeEmpty();
3232
});

tests/ArangoClientTest.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
];
3131

3232
$config = $this->arangoClient->getConfig();
33-
$this->assertSame($defaultConfig, $config);
33+
expect($config)->toBe($defaultConfig);
3434
});
3535

3636
test('get config with endpoint without host port', function () {
@@ -40,7 +40,7 @@
4040
];
4141

4242
$returnedConfig = $this->arangoClient->getConfig();
43-
$this->assertSame($config['endpoint'], $returnedConfig['endpoint']);
43+
expect($returnedConfig['endpoint'])->toBe($config['endpoint']);
4444
});
4545

4646
test('client with host port config', function () {
@@ -52,7 +52,7 @@
5252
$client = new ArangoClient($config);
5353
$retrievedConfig = $client->getConfig();
5454

55-
$this->assertEquals('http://127.0.0.1:1234', $retrievedConfig['endpoint']);
55+
expect($retrievedConfig['endpoint'])->toEqual('http://127.0.0.1:1234');
5656
});
5757

5858
test('config with alien properties', function () {
@@ -77,32 +77,32 @@
7777
$this->arangoClient->setHttpClient($newClient);
7878
$retrievedClient = $this->arangoClient->getHttpClient();
7979

80-
$this->assertInstanceOf(Client::class, $oldClient);
81-
$this->assertEquals($newClient::class, $retrievedClient::class);
80+
expect($oldClient)->toBeInstanceOf(Client::class);
81+
expect($retrievedClient::class)->toEqual($newClient::class);
8282
});
8383

8484
test('request', function () {
8585
$result = $this->arangoClient->request('get', '/_api/version', []);
8686

87-
$this->assertSame('arango', $result->server);
88-
$this->assertSame('community', $result->license);
89-
$this->assertIsString($result->version);
87+
expect($result->server)->toBe('arango');
88+
expect($result->license)->toBe('community');
89+
expect($result->version)->toBeString();
9090
});
9191

9292
test('get user', function () {
9393
$user = $this->arangoClient->getUser();
94-
$this->assertSame('root', $user);
94+
expect($user)->toBe('root');
9595
});
9696

9797
test('set and get database name', function () {
9898
$database = $this->arangoClient->getDatabase();
99-
$this->assertSame($this->testDatabaseName, $database);
99+
expect($database)->toBe($this->testDatabaseName);
100100

101101
$newDatabaseName = 'ArangoClientDB';
102102
$this->arangoClient->setDatabase($newDatabaseName);
103103

104104
$database = $this->arangoClient->getDatabase();
105-
$this->assertSame($newDatabaseName, $database);
105+
expect($database)->toBe($newDatabaseName);
106106
});
107107

108108
test('database name is used in requests', function () {
@@ -126,15 +126,15 @@
126126
$this->arangoClient->request('get', $uri, ['handler' => $handlerStack]);
127127

128128
foreach ($container as $transaction) {
129-
$this->assertSame('/_db/' . $database . $uri, $transaction['request']->getUri()->getPath());
129+
expect($transaction['request']->getUri()->getPath())->toBe('/_db/' . $database . $uri);
130130
}
131131

132132
$this->arangoClient->schema()->deleteDatabase($database);
133133
});
134134

135135
test('schema', function () {
136136
$result = $this->arangoClient->schema();
137-
$this->assertInstanceOf(SchemaManager::class, $result);
137+
expect($result)->toBeInstanceOf(SchemaManager::class);
138138

139139
$database = $this->arangoClient->schema()->getCurrentDatabase();
140140

@@ -143,7 +143,7 @@
143143

144144
test('admin', function () {
145145
$result = $this->arangoClient->admin();
146-
$this->assertInstanceOf(AdminManager::class, $result);
146+
expect($result)->toBeInstanceOf(AdminManager::class);
147147

148148
$version = $this->arangoClient->admin()->getVersion();
149149

@@ -153,7 +153,7 @@
153153
test('prepare', function () {
154154
$statement = $this->arangoClient->prepare('FOR doc IN users RETURN doc');
155155

156-
$this->assertInstanceOf(Statement::class, $statement);
156+
expect($statement)->toBeInstanceOf(Statement::class);
157157
});
158158

159159
test('connection protocol version', function () {
@@ -165,7 +165,7 @@
165165
$options['version'] = 2;
166166
$response = $this->arangoClient->debugRequest('get', $uri, $options);
167167

168-
$this->assertEquals(2, $response->getProtocolVersion());
168+
expect($response->getProtocolVersion())->toEqual(2);
169169
});
170170

171171
test('connection protocol version with default setting', function () {
@@ -179,25 +179,25 @@
179179
$options['version'] = 2;
180180
$response = $this->arangoClient->debugRequest('get', $uri, $options);
181181

182-
$this->assertEquals(2, $response->getProtocolVersion());
182+
expect($response->getProtocolVersion())->toEqual(2);
183183
});
184184

185185
test('json encode', function () {
186186
$results = $this->arangoClient->jsonEncode([]);
187187

188-
$this->assertSame('{}', $results);
188+
expect($results)->toBe('{}');
189189
});
190190

191191
test('json encode empty array', function () {
192192
$results = $this->arangoClient->jsonEncode([]);
193193

194-
$this->assertSame('{}', $results);
194+
expect($results)->toBe('{}');
195195
});
196196

197197
test('json encode empty string', function () {
198198
$results = $this->arangoClient->jsonEncode('');
199199

200-
$this->assertSame('""', $results);
200+
expect($results)->toBe('""');
201201
});
202202

203203
test('json encode invalid data', function () {
@@ -230,7 +230,7 @@
230230
$statement->execute();
231231
$users = $statement->fetchAll();
232232

233-
$this->assertEquals($insertResult[0], $users[0]);
233+
expect($users[0])->toEqual($insertResult[0]);
234234

235235
$this->schemaManager->deleteCollection($collection);
236236
});

tests/MonitorManagerTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
test('get metrics', function () {
1010
$result = $this->arangoClient->monitor()->getMetrics();
11-
$this->assertIsObject($result);
12-
$this->assertEquals("gauge", $result->arangodb_agency_cache_callback_number->type);
13-
$this->assertCount(1, $result->arangodb_agency_cache_callback_number->labels);
11+
expect($result)->toBeObject();
12+
expect($result->arangodb_agency_cache_callback_number->type)->toEqual("gauge");
13+
expect($result->arangodb_agency_cache_callback_number->labels)->toHaveCount(1);
1414
});
1515

1616
test('summary metric', function () {
@@ -26,7 +26,7 @@
2626

2727

2828
$result = $prometheus->parseText($rawMetrics);
29-
$this->assertIsObject($result);
29+
expect($result)->toBeObject();
3030
});
3131

3232
test('historgram parsing', function () {
@@ -59,9 +59,9 @@
5959
';
6060

6161
$result = $prometheus->parseText($rawMetrics);
62-
$this->assertCount(20, $result->arangodb_aql_query_time->buckets);
63-
$this->assertEquals(177, $result->arangodb_aql_query_time->count);
64-
$this->assertEquals(0.03518, $result->arangodb_aql_query_time->sum);
62+
expect($result->arangodb_aql_query_time->buckets)->toHaveCount(20);
63+
expect($result->arangodb_aql_query_time->count)->toEqual(177);
64+
expect($result->arangodb_aql_query_time->sum)->toEqual(0.03518);
6565
});
6666

6767
test('timestamp parsing', function () {
@@ -72,6 +72,6 @@
7272
arangodb_aql_local_query_memory_limit_reached_total{role="SINGLE"} 0 2211753600';
7373

7474
$result = $prometheus->parseText($rawMetrics);
75-
$this->assertIsObject($result);
76-
$this->assertEquals(2211753600, $result->arangodb_aql_local_query_memory_limit_reached_total->timestamp);
75+
expect($result)->toBeObject();
76+
expect($result->arangodb_aql_local_query_memory_limit_reached_total->timestamp)->toEqual(2211753600);
7777
});

tests/SchemaManagerAnalyzersTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,29 @@
2525

2626
$customAnalyzer = end($analyzers);
2727

28-
$this->assertSame('arangodb_php_client__test::' . $this->analyzer['name'], $customAnalyzer->name);
28+
expect($customAnalyzer->name)->toBe('arangodb_php_client__test::' . $this->analyzer['name']);
2929
});
3030

3131
test('get analyzer', function () {
3232
$analyzer = $this->schemaManager->getAnalyzer($this->analyzer['name']);
3333

34-
$this->assertSame('arangodb_php_client__test::' . $this->analyzer['name'], $analyzer->name);
34+
expect($analyzer->name)->toBe('arangodb_php_client__test::' . $this->analyzer['name']);
3535
$this->assertObjectHasProperty('type', $analyzer);
3636
});
3737

3838
test('get analyzer with full name', function () {
3939
$analyzer = $this->schemaManager->getAnalyzer('arangodb_php_client__test::' . $this->analyzer['name']);
4040

41-
$this->assertSame('arangodb_php_client__test::' . $this->analyzer['name'], $analyzer->name);
41+
expect($analyzer->name)->toBe('arangodb_php_client__test::' . $this->analyzer['name']);
4242
$this->assertObjectHasProperty('type', $analyzer);
4343
});
4444

4545
test('has analyzer', function () {
4646
$result = $this->schemaManager->hasAnalyzer($this->analyzer['name']);
47-
$this->assertTrue($result);
47+
expect($result)->toBeTrue();
4848

4949
$result = $this->schemaManager->hasAnalyzer('someNoneExistingAnalyzer');
50-
$this->assertFalse($result);
50+
expect($result)->toBeFalse();
5151
});
5252

5353
test('replace analyzer', function () {
@@ -58,7 +58,7 @@
5858
;
5959
$newAnalyzer = $this->schemaManager->replaceAnalyzer($this->analyzer['name'], $newAnalyzerProps);
6060

61-
$this->assertSame('arangodb_php_client__test::' . $this->analyzer['name'], $newAnalyzer->name);
61+
expect($newAnalyzer->name)->toBe('arangodb_php_client__test::' . $this->analyzer['name']);
6262
});
6363

6464
test('create and delete analyzer', function () {
@@ -68,10 +68,10 @@
6868
];
6969
$created = $this->schemaManager->createAnalyzer($analyzer);
7070
$this->assertObjectHasProperty('name', $created);
71-
$this->assertSame('arangodb_php_client__test::' . $analyzer['name'], $created->name);
71+
expect($created->name)->toBe('arangodb_php_client__test::' . $analyzer['name']);
7272

7373
$deleted = $this->schemaManager->deleteAnalyzer($analyzer['name']);
74-
$this->assertTrue($deleted);
74+
expect($deleted)->toBeTrue();
7575
});
7676

7777
test('delete with full name', function () {
@@ -86,5 +86,5 @@
8686
$deleted = $this->schemaManager->deleteAnalyzer($fullName);
8787

8888
$hasAnalyzer = $this->schemaManager->hasAnalyzer($fullName);
89-
$this->assertFalse($hasAnalyzer);
89+
expect($hasAnalyzer)->toBeFalse();
9090
});

0 commit comments

Comments
 (0)