Skip to content

Commit ed0176f

Browse files
authored
Fix PHPUnit issues (alcaeus#283)
* Remove obsolete configuration for PHPUnit * Use expectErrorMessageMatches for compatibility with PHPUnit 9
1 parent 9c57038 commit ed0176f

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

phpunit.xml.dist

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
</testsuite>
2222
</testsuites>
2323

24-
<filter>
25-
<whitelist>
26-
<directory suffix=".php">./lib/Alcaeus/MongoDbAdapter</directory>
27-
</whitelist>
28-
</filter>
29-
3024
<php>
3125
<const name="MONGODB_URI" value="mongodb://localhost:27017" />
3226
</php>

tests/Alcaeus/MongoDbAdapter/Mongo/MongoClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function testGetHosts()
9393
public function testGetHostsExceptionHandling()
9494
{
9595
$this->expectException(\MongoConnectionException::class);
96-
$this->expectExceptionMessageRegExp('/fake_host/');
96+
$this->expectErrorMessageMatches('/fake_host/');
9797

9898
$client = $this->getClient(null, 'mongodb://fake_host');
9999
$client->getHosts();
@@ -265,7 +265,7 @@ public function testConnectWithUsernameAndPassword()
265265

266266
$collection->insert($document);
267267
}
268-
268+
269269
public function testConnectWithUsernameAndPasswordInConnectionUrl()
270270
{
271271
$this->expectException(\MongoConnectionException::class);

tests/Alcaeus/MongoDbAdapter/Mongo/MongoCollectionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function testInsertDuplicate()
195195
unset($document['_id']);
196196

197197
$this->expectException(\MongoDuplicateKeyException::class);
198-
$this->expectExceptionMessageRegExp('/E11000 duplicate key error .* mongo-php-adapter\.test/');
198+
$this->expectErrorMessageMatches('/E11000 duplicate key error .* mongo-php-adapter\.test/');
199199
$this->expectExceptionCode(11000);
200200
$collection->insert($document);
201201
}
@@ -303,7 +303,7 @@ public function testBatchInsertException()
303303
$documents = [['_id' => $id, 'foo' => 'bar'], ['_id' => $id, 'foo' => 'bleh']];
304304

305305
$this->expectException(\MongoDuplicateKeyException::class);
306-
$this->expectExceptionMessageRegExp('/E11000 duplicate key error .* mongo-php-adapter.test.*_id_/');
306+
$this->expectErrorMessageMatches('/E11000 duplicate key error .* mongo-php-adapter.test.*_id_/');
307307
$this->expectExceptionCode(11000);
308308

309309
$this->getCollection()->batchInsert($documents);
@@ -415,7 +415,7 @@ public function testUpdateReplaceOne()
415415
public function testUpdateReplaceMultiple()
416416
{
417417
$this->expectException(\MongoWriteConcernException::class);
418-
$this->expectExceptionMessageRegExp('/multi update only works with \$ operators/', 9);
418+
$this->expectErrorMessageMatches('/multi update only works with \$ operators/', 9);
419419
$this->getCollection()->update(['foo' => 'bar'], ['foo' => 'foo'], ['multiple' => true]);
420420
}
421421

tests/Alcaeus/MongoDbAdapter/Mongo/MongoGridFSTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public function testStoreByteExceptionWhileInsertingRecord()
327327
$collection->insert($document);
328328

329329
$this->expectException(\MongoGridFSException::class);
330-
$this->expectExceptionMessageRegExp('/Could not store file:.* E11000 duplicate key error .* mongo-php-adapter\.fs\.files/');
330+
$this->expectErrorMessageMatches('/Could not store file:.* E11000 duplicate key error .* mongo-php-adapter\.fs\.files/');
331331
$this->expectExceptionCode(11000);
332332

333333
$collection->storeBytes('foo', ['_id' => $id]);
@@ -342,7 +342,7 @@ public function testStoreByteExceptionWhileInsertingChunks()
342342
$collection->chunks->insert($document);
343343

344344
$this->expectException(\MongoGridFSException::class);
345-
$this->expectExceptionMessageRegExp('/Could not store file:.* E11000 duplicate key error .* mongo-php-adapter\.fs\.chunks/');
345+
$this->expectErrorMessageMatches('/Could not store file:.* E11000 duplicate key error .* mongo-php-adapter\.fs\.chunks/');
346346
$this->expectExceptionCode(11000);
347347

348348
$collection->storeBytes('foo');
@@ -357,7 +357,7 @@ public function testStoreFileExceptionWhileInsertingRecord()
357357
$collection->insert($document);
358358

359359
$this->expectException(\MongoGridFSException::class);
360-
$this->expectExceptionMessageRegExp('/Could not store file:.* E11000 duplicate key error .* mongo-php-adapter\.fs\.files/');
360+
$this->expectErrorMessageMatches('/Could not store file:.* E11000 duplicate key error .* mongo-php-adapter\.fs\.files/');
361361
$this->expectExceptionCode(11000);
362362

363363
$collection->storeFile(__FILE__, ['_id' => $id]);
@@ -372,7 +372,7 @@ public function testStoreFileExceptionWhileInsertingChunks()
372372
$collection->chunks->insert($document);
373373

374374
$this->expectException(\MongoGridFSException::class);
375-
$this->expectExceptionMessageRegExp('/Could not store file:.* E11000 duplicate key error .* mongo-php-adapter\.fs\.chunks/');
375+
$this->expectErrorMessageMatches('/Could not store file:.* E11000 duplicate key error .* mongo-php-adapter\.fs\.chunks/');
376376
$this->expectExceptionCode(11000);
377377

378378
$collection->storeFile(__FILE__);
@@ -387,7 +387,7 @@ public function testStoreFileExceptionWhileUpdatingFileRecord()
387387
$collection->insert($document);
388388

389389
$this->expectException(\MongoGridFSException::class);
390-
$this->expectExceptionMessageRegExp('/Could not store file:.* E11000 duplicate key error .* mongo-php-adapter\.fs\.files/');
390+
$this->expectErrorMessageMatches('/Could not store file:.* E11000 duplicate key error .* mongo-php-adapter\.fs\.files/');
391391
$this->expectExceptionCode(11000);
392392

393393
$collection->storeFile(fopen(__FILE__, 'r'));

0 commit comments

Comments
 (0)