Commit 201b6ab6 authored by Katherine Walker's avatar Katherine Walker

PHPLIB-216: Use expectException() method instead of annotation in tests

parent 5d046bd2
......@@ -6,6 +6,7 @@ use MongoDB\Client;
use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\InvalidArgumentException;
/**
* Unit tests for the Client class.
......@@ -20,11 +21,11 @@ class ClientTest extends TestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorDriverOptions
*/
public function testConstructorDriverOptionTypeChecks(array $driverOptions)
{
$this->expectException(InvalidArgumentException::class);
new Client($this->getUri(), [], $driverOptions);
}
......
......@@ -8,6 +8,7 @@ use MongoDB\Driver\BulkWrite;
use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\MapReduce;
/**
......@@ -16,21 +17,21 @@ use MongoDB\Operation\MapReduce;
class CollectionFunctionalTest extends FunctionalTestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDatabaseAndCollectionNames
*/
public function testConstructorDatabaseNameArgument($databaseName)
{
$this->expectException(InvalidArgumentException::class);
// TODO: Move to unit test once ManagerInterface can be mocked (PHPC-378)
new Collection($this->manager, $databaseName, $this->getCollectionName());
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDatabaseAndCollectionNames
*/
public function testConstructorCollectionNameArgument($collectionName)
{
$this->expectException(InvalidArgumentException::class);
// TODO: Move to unit test once ManagerInterface can be mocked (PHPC-378)
new Collection($this->manager, $this->getDatabaseName(), $collectionName);
}
......@@ -44,11 +45,11 @@ class CollectionFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new Collection($this->manager, $this->getDatabaseName(), $this->getCollectionName(), $options);
}
......@@ -111,11 +112,11 @@ class CollectionFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @todo Move this to a unit test once Manager can be mocked
*/
public function testDropIndexShouldNotAllowWildcardCharacter()
{
$this->expectException(InvalidArgumentException::class);
$this->collection->dropIndex('*');
}
......
......@@ -7,6 +7,7 @@ use MongoDB\Driver\BulkWrite;
use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\InvalidArgumentException;
/**
* Functional tests for the Database class.
......@@ -14,11 +15,11 @@ use MongoDB\Driver\WriteConcern;
class DatabaseFunctionalTest extends FunctionalTestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDatabaseNames
*/
public function testConstructorDatabaseNameArgument($databaseName)
{
$this->expectException(InvalidArgumentException::class);
// TODO: Move to unit test once ManagerInterface can be mocked (PHPC-378)
new Database($this->manager, $databaseName);
}
......@@ -32,11 +33,11 @@ class DatabaseFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new Database($this->manager, $this->getDatabaseName(), $options);
}
......@@ -115,11 +116,11 @@ class DatabaseFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testCommandCommandArgumentTypeCheck($command)
{
$this->expectException(InvalidArgumentException::class);
$this->database->command($command);
}
......
......@@ -6,6 +6,7 @@ use MongoDB\Model\BSONArray;
use MongoDB\Model\BSONDocument;
use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\InvalidArgumentException;
/**
* Unit tests for utility functions.
......@@ -80,11 +81,11 @@ class FunctionsTest extends TestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testGenerateIndexNameArgumentTypeCheck($document)
{
$this->expectException(InvalidArgumentException::class);
\MongoDB\generate_index_name($document);
}
......@@ -109,11 +110,11 @@ class FunctionsTest extends TestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testIsFirstKeyOperatorArgumentTypeCheck($document)
{
$this->expectException(InvalidArgumentException::class);
\MongoDB\is_first_key_operator($document);
}
......
......@@ -6,11 +6,13 @@ use MongoDB\BSON\Binary;
use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\GridFS\Bucket;
use MongoDB\GridFS\Exception\FileNotFoundException;
use MongoDB\Model\IndexInfo;
use MongoDB\Operation\ListCollections;
use MongoDB\Operation\ListIndexes;
use PHPUnit\Framework\Error\Warning;
/**
* Functional tests for the Bucket class.
......@@ -32,11 +34,11 @@ class BucketFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new Bucket($this->manager, $this->getDatabaseName(), $options);
}
......@@ -71,12 +73,10 @@ class BucketFunctionalTest extends FunctionalTestCase
return $options;
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage Expected "chunkSizeBytes" option to be >= 1, 0 given
*/
public function testConstructorShouldRequireChunkSizeBytesOptionToBePositive()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Expected "chunkSizeBytes" option to be >= 1, 0 given');
new Bucket($this->manager, $this->getDatabaseName(), ['chunkSizeBytes' => 0]);
}
......@@ -112,11 +112,9 @@ class BucketFunctionalTest extends FunctionalTestCase
];
}
/**
* @expectedException MongoDB\GridFS\Exception\FileNotFoundException
*/
public function testDeleteShouldRequireFileToExist()
{
$this->expectException(FileNotFoundException::class);
$this->bucket->delete('nonexistent-id');
}
......@@ -140,21 +138,16 @@ class BucketFunctionalTest extends FunctionalTestCase
$this->assertCollectionCount($this->chunksCollection, 0);
}
/**
* @expectedException PHPUnit\Framework\Error\Warning
*/
public function testDownloadingFileWithMissingChunk()
{
$id = $this->bucket->uploadFromStream("filename", $this->createStream("foobar"));
$this->chunksCollection->deleteOne(['files_id' => $id, 'n' => 0]);
$this->expectException(Warning::class);
stream_get_contents($this->bucket->openDownloadStream($id));
}
/**
* @expectedException PHPUnit\Framework\Error\Warning
*/
public function testDownloadingFileWithUnexpectedChunkIndex()
{
$id = $this->bucket->uploadFromStream("filename", $this->createStream("foobar"));
......@@ -164,12 +157,10 @@ class BucketFunctionalTest extends FunctionalTestCase
['$set' => ['n' => 1]]
);
$this->expectException(Warning::class);
stream_get_contents($this->bucket->openDownloadStream($id));
}
/**
* @expectedException PHPUnit\Framework\Error\Warning
*/
public function testDownloadingFileWithUnexpectedChunkSize()
{
$id = $this->bucket->uploadFromStream("filename", $this->createStream("foobar"));
......@@ -179,6 +170,7 @@ class BucketFunctionalTest extends FunctionalTestCase
['$set' => ['data' => new Binary('fooba', Binary::TYPE_GENERIC)]]
);
$this->expectException(Warning::class);
stream_get_contents($this->bucket->openDownloadStream($id));
}
......@@ -195,11 +187,11 @@ class BucketFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidStreamValues
*/
public function testDownloadToStreamShouldRequireDestinationStream($destination)
{
$this->expectException(InvalidArgumentException::class);
$this->bucket->downloadToStream('id', $destination);
}
......@@ -208,11 +200,9 @@ class BucketFunctionalTest extends FunctionalTestCase
return $this->wrapValuesForDataProvider($this->getInvalidStreamValues());
}
/**
* @expectedException MongoDB\GridFS\Exception\FileNotFoundException
*/
public function testDownloadToStreamShouldRequireFileToExist()
{
$this->expectException(FileNotFoundException::class);
$this->bucket->downloadToStream('nonexistent-id', $this->createStream());
}
......@@ -252,16 +242,15 @@ class BucketFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidStreamValues
*/
public function testDownloadToStreamByNameShouldRequireDestinationStream($destination)
{
$this->expectException(InvalidArgumentException::class);
$this->bucket->downloadToStreamByName('filename', $destination);
}
/**
* @expectedException MongoDB\GridFS\Exception\FileNotFoundException
* @dataProvider provideNonexistentFilenameAndRevision
*/
public function testDownloadToStreamByNameShouldRequireFilenameAndRevisionToExist($filename, $revision)
......@@ -270,6 +259,7 @@ class BucketFunctionalTest extends FunctionalTestCase
$this->bucket->uploadFromStream('filename', $this->createStream('bar'));
$destination = $this->createStream();
$this->expectException(FileNotFoundException::class);
$this->bucket->downloadToStreamByName($filename, $destination, ['revision' => $revision]);
}
......@@ -430,11 +420,11 @@ class BucketFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidGridFSStreamValues
*/
public function testGetFileDocumentForStreamShouldRequireGridFSStreamResource($stream)
{
$this->expectException(InvalidArgumentException::class);
$this->bucket->getFileDocumentForStream($stream);
}
......@@ -469,11 +459,11 @@ class BucketFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidGridFSStreamValues
*/
public function testGetFileIdForStreamShouldRequireGridFSStreamResource($stream)
{
$this->expectException(InvalidArgumentException::class);
$this->bucket->getFileIdForStream($stream);
}
......@@ -516,19 +506,15 @@ class BucketFunctionalTest extends FunctionalTestCase
$this->assertEquals($input, $buffer);
}
/**
* @expectedException MongoDB\GridFS\Exception\FileNotFoundException
*/
public function testOpenDownloadStreamShouldRequireFileToExist()
{
$this->expectException(FileNotFoundException::class);
$this->bucket->openDownloadStream('nonexistent-id');
}
/**
* @expectedException MongoDB\GridFS\Exception\FileNotFoundException
*/
public function testOpenDownloadStreamByNameShouldRequireFilenameToExist()
{
$this->expectException(FileNotFoundException::class);
$this->bucket->openDownloadStream('nonexistent-filename');
}
......@@ -548,7 +534,6 @@ class BucketFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\GridFS\Exception\FileNotFoundException
* @dataProvider provideNonexistentFilenameAndRevision
*/
public function testOpenDownloadStreamByNameShouldRequireFilenameAndRevisionToExist($filename, $revision)
......@@ -556,6 +541,7 @@ class BucketFunctionalTest extends FunctionalTestCase
$this->bucket->uploadFromStream('filename', $this->createStream('foo'));
$this->bucket->uploadFromStream('filename', $this->createStream('bar'));
$this->expectException(FileNotFoundException::class);
$this->bucket->openDownloadStream($filename, ['revision' => $revision]);
}
......@@ -617,11 +603,9 @@ class BucketFunctionalTest extends FunctionalTestCase
$this->assertStreamContents('foo', $this->bucket->openDownloadStreamByName('a'));
}
/**
* @expectedException MongoDB\GridFS\Exception\FileNotFoundException
*/
public function testRenameShouldRequireFileToExist()
{
$this->expectException(FileNotFoundException::class);
$this->bucket->rename('nonexistent-id', 'b');
}
......@@ -645,11 +629,11 @@ class BucketFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidStreamValues
*/
public function testUploadFromStreamShouldRequireSourceStream($source)
{
$this->expectException(InvalidArgumentException::class);
$this->bucket->uploadFromStream('filename', $source);
}
......
......@@ -3,8 +3,10 @@
namespace MongoDB\Tests\GridFS;
use MongoDB\BSON\Binary;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\GridFS\CollectionWrapper;
use MongoDB\GridFS\ReadableStream;
use MongoDB\GridFS\Exception\CorruptFileException;
use MongoDB\Tests\CommandObserver;
use stdClass;
......@@ -48,11 +50,11 @@ class ReadableStreamFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\GridFS\Exception\CorruptFileException
* @dataProvider provideInvalidConstructorFileDocuments
*/
public function testConstructorFileDocumentChecks($file)
{
$this->expectException(CorruptFileException::class);
new ReadableStream($this->collectionWrapper, $file);
}
......@@ -134,10 +136,6 @@ class ReadableStreamFunctionalTest extends FunctionalTestCase
}
}
/**
* @expectedException MongoDB\GridFS\Exception\CorruptFileException
* @expectedExceptionMessage Chunk not found for index "2"
*/
public function testReadBytesWithMissingChunk()
{
$this->chunksCollection->deleteOne(['files_id' => 'length-10', 'n' => 2]);
......@@ -145,13 +143,11 @@ class ReadableStreamFunctionalTest extends FunctionalTestCase
$fileDocument = $this->collectionWrapper->findFileById('length-10');
$stream = new ReadableStream($this->collectionWrapper, $fileDocument);
$this->expectException(CorruptFileException::class);
$this->expectExceptionMessage('Chunk not found for index "2"');
$stream->readBytes(10);
}
/**
* @expectedException MongoDB\GridFS\Exception\CorruptFileException
* @expectedExceptionMessage Expected chunk to have index "1" but found "2"
*/
public function testReadBytesWithUnexpectedChunkIndex()
{
$this->chunksCollection->deleteOne(['files_id' => 'length-10', 'n' => 1]);
......@@ -159,13 +155,11 @@ class ReadableStreamFunctionalTest extends FunctionalTestCase
$fileDocument = $this->collectionWrapper->findFileById('length-10');
$stream = new ReadableStream($this->collectionWrapper, $fileDocument);
$this->expectException(CorruptFileException::class);
$this->expectExceptionMessage('Expected chunk to have index "1" but found "2"');
$stream->readBytes(10);
}
/**
* @expectedException MongoDB\GridFS\Exception\CorruptFileException
* @expectedExceptionMessage Expected chunk to have size "2" but found "1"
*/
public function testReadBytesWithUnexpectedChunkSize()
{
$this->chunksCollection->updateOne(
......@@ -176,17 +170,17 @@ class ReadableStreamFunctionalTest extends FunctionalTestCase
$fileDocument = $this->collectionWrapper->findFileById('length-10');
$stream = new ReadableStream($this->collectionWrapper, $fileDocument);
$this->expectException(CorruptFileException::class);
$this->expectExceptionMessage('Expected chunk to have size "2" but found "1"');
$stream->readBytes(10);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
*/
public function testReadBytesWithNegativeLength()
{
$fileDocument = $this->collectionWrapper->findFileById('length-0');
$stream = new ReadableStream($this->collectionWrapper, $fileDocument);
$this->expectException(InvalidArgumentException::class);
$stream->readBytes(-1);
}
......@@ -199,15 +193,13 @@ class ReadableStreamFunctionalTest extends FunctionalTestCase
$this->assertSame('ij', $stream->readBytes(2));
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage $offset must be >= 0 and <= 10; given: 11
*/
public function testSeekOutOfRange()
{
$fileDocument = $this->collectionWrapper->findFileById('length-10');
$stream = new ReadableStream($this->collectionWrapper, $fileDocument);
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('$offset must be >= 0 and <= 10; given: 11');
$stream->seek(11);
}
......
......@@ -2,6 +2,7 @@
namespace MongoDB\Tests\GridFS;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\GridFS\CollectionWrapper;
use MongoDB\GridFS\WritableStream;
......@@ -32,11 +33,11 @@ class WritableStreamFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new WritableStream($this->collectionWrapper, 'filename', $options);
}
......@@ -55,12 +56,10 @@ class WritableStreamFunctionalTest extends FunctionalTestCase
return $options;
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage Expected "chunkSizeBytes" option to be >= 1, 0 given
*/
public function testConstructorShouldRequireChunkSizeBytesOptionToBePositive()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Expected "chunkSizeBytes" option to be >= 1, 0 given');
new WritableStream($this->collectionWrapper, 'filename', ['chunkSizeBytes' => 0]);
}
......
......@@ -11,13 +11,13 @@ class CachingIteratorTest extends TestCase
/**
* Sanity check for all following tests.
*
* @expectedException \Exception
* @expectedExceptionMessage Cannot traverse an already closed generator
*/
public function testTraversingGeneratorConsumesIt()
{
$iterator = $this->getTraversable([1, 2, 3]);
$this->assertSame([1, 2, 3], iterator_to_array($iterator));
$this->expectException(Exception::class);
$this->expectExceptionMessage('Cannot traverse an already closed generator');
$this->assertSame([1, 2, 3], iterator_to_array($iterator));
}
......
......@@ -2,6 +2,7 @@
namespace MongoDB\Tests\Model;
use MongoDB\Exception\BadMethodCallException;
use MongoDB\Model\IndexInfo;
use MongoDB\Tests\TestCase;
......@@ -111,10 +112,6 @@ class IndexInfoTest extends TestCase
$this->assertSame('x_1', $info['name']);
}
/**
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\IndexInfo is immutable
*/
public function testOffsetSetCannotBeCalled()
{
$info = new IndexInfo([
......@@ -124,13 +121,11 @@ class IndexInfoTest extends TestCase
'ns' => 'foo.bar',
]);
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('MongoDB\Model\IndexInfo is immutable');
$info['v'] = 2;
}
/**
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\IndexInfo is immutable
*/
public function testOffsetUnsetCannotBeCalled()
{
$info = new IndexInfo([
......@@ -140,6 +135,8 @@ class IndexInfoTest extends TestCase
'ns' => 'foo.bar',
]);
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('MongoDB\Model\IndexInfo is immutable');
unset($info['v']);
}
}
......@@ -2,34 +2,31 @@
namespace MongoDB\Tests\Model;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Model\IndexInput;
use MongoDB\Tests\TestCase;
use stdClass;
class IndexInputTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
*/
public function testConstructorShouldRequireKey()
{
$this->expectException(InvalidArgumentException::class);
new IndexInput([]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
*/
public function testConstructorShouldRequireKeyToBeArrayOrObject()
{
$this->expectException(InvalidArgumentException::class);
new IndexInput(['key' => 'foo']);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidFieldOrderValues
*/
public function testConstructorShouldRequireKeyFieldOrderToBeNumericOrString($order)
{
$this->expectException(InvalidArgumentException::class);
new IndexInput(['key' => ['x' => $order]]);
}
......@@ -38,27 +35,21 @@ class IndexInputTest extends TestCase
return $this->wrapValuesForDataProvider([true, [], new stdClass]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
*/
public function testConstructorShouldRequireNamespace()
{
$this->expectException(InvalidArgumentException::class);
new IndexInput(['key' => ['x' => 1]]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
*/
public function testConstructorShouldRequireNamespaceToBeString()
{
$this->expectException(InvalidArgumentException::class);
new IndexInput(['key' => ['x' => 1], 'ns' => 1]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
*/
public function testConstructorShouldRequireNameToBeString()
{
$this->expectException(InvalidArgumentException::class);
new IndexInput(['key' => ['x' => 1], 'ns' => 'foo.bar', 'name' => 1]);
}
......
......@@ -2,6 +2,7 @@
namespace MongoDB\Tests\Model;
use MongoDB\Exception\BadMethodCallException;
use MongoDB\Model\TypeMapArrayIterator;
use MongoDB\Tests\TestCase;
......@@ -59,8 +60,6 @@ class TypeMapArrayIteratorTest extends TestCase
/**
* @dataProvider provideMutateMethods
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\TypeMapArrayIterator is immutable
*/
public function testMutateMethodsCannotBeCalled($method, $args)
{
......@@ -79,6 +78,8 @@ class TypeMapArrayIteratorTest extends TestCase
$iterator->rewind();
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('MongoDB\Model\TypeMapArrayIterator is immutable');
call_user_func_array([$iterator, $method], $args);
}
......
......@@ -4,6 +4,7 @@ namespace MongoDB\Tests\Operation;
use MongoDB\Driver\BulkWrite;
use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException;
use MongoDB\Operation\Aggregate;
use MongoDB\Tests\CommandObserver;
use ArrayIterator;
......@@ -65,12 +66,10 @@ class AggregateFunctionalTest extends FunctionalTestCase
$this->assertEquals($expectedDocuments, $results);
}
/**
* @expectedException MongoDB\Driver\Exception\RuntimeException
*/
public function testUnrecognizedPipelineState()
{
$operation = new Aggregate($this->getDatabaseName(), $this->getCollectionName(), [['$foo' => 1]]);
$this->expectException(RuntimeException::class);
$operation->execute($this->getPrimaryServer());
}
......
......@@ -2,25 +2,24 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\Aggregate;
class AggregateTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage $pipeline is not a list (unexpected index: "1")
*/
public function testConstructorPipelineArgumentMustBeAList()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('$pipeline is not a list (unexpected index: "1")');
new Aggregate($this->getDatabaseName(), $this->getCollectionName(), [1 => ['$match' => ['x' => 1]]]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new Aggregate($this->getDatabaseName(), $this->getCollectionName(), [['$match' => ['x' => 1]]], $options);
}
......@@ -91,12 +90,10 @@ class AggregateTest extends TestCase
return $options;
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage "batchSize" option should not be used if "useCursor" is false
*/
public function testConstructorBatchSizeOptionRequiresUseCursor()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('"batchSize" option should not be used if "useCursor" is false');
new Aggregate(
$this->getDatabaseName(),
$this->getCollectionName(),
......
......@@ -6,6 +6,8 @@ use MongoDB\BulkWriteResult;
use MongoDB\Collection;
use MongoDB\Driver\BulkWrite as Bulk;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\BadMethodCallException;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Model\BSONDocument;
use MongoDB\Operation\BulkWrite;
use MongoDB\Tests\CommandObserver;
......@@ -161,82 +163,80 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesDeletedCount(BulkWriteResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getDeletedCount();
}
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesInsertCount(BulkWriteResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getInsertedCount();
}
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesMatchedCount(BulkWriteResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getMatchedCount();
}
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesModifiedCount(BulkWriteResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getModifiedCount();
}
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesUpsertedCount(BulkWriteResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getUpsertedCount();
}
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesUpsertedIds(BulkWriteResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getUpsertedIds();
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage Unknown operation type "foo" in $operations[0]
*/
public function testUnknownOperation()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Unknown operation type "foo" in $operations[0]');
new BulkWrite($this->getDatabaseName(), $this->getCollectionName(), [
['foo' => [['_id' => 1]]],
]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Missing (first|second) argument for \$operations\[\d+\]\["\w+\"]/
* @dataProvider provideOpsWithMissingArguments
*/
public function testMissingArguments(array $ops)
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/Missing (first|second) argument for \$operations\[\d+\]\["\w+\"]/');
new BulkWrite($this->getDatabaseName(), $this->getCollectionName(), $ops);
}
......@@ -255,34 +255,28 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
];
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage First key in $operations[0]["updateOne"][1] is not an update operator
*/
public function testUpdateOneRequiresUpdateOperators()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('First key in $operations[0]["updateOne"][1] is not an update operator');
new BulkWrite($this->getDatabaseName(), $this->getCollectionName(), [
['updateOne' => [['_id' => 1], ['x' => 1]]],
]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage First key in $operations[0]["updateMany"][1] is not an update operator
*/
public function testUpdateManyRequiresUpdateOperators()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('First key in $operations[0]["updateMany"][1] is not an update operator');
new BulkWrite($this->getDatabaseName(), $this->getCollectionName(), [
['updateMany' => [['_id' => ['$gt' => 1]], ['x' => 1]]],
]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage First key in $operations[0]["replaceOne"][1] is an update operator
*/
public function testReplaceOneRequiresReplacementDocument()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('First key in $operations[0]["replaceOne"][1] is an update operator');
new BulkWrite($this->getDatabaseName(), $this->getCollectionName(), [
['replaceOne' => [['_id' => 1], ['$inc' => ['x' => 1]]]],
]);
......
This diff is collapsed.
......@@ -2,25 +2,26 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\Count;
class CountTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorFilterArgumentTypeCheck($filter)
{
$this->expectException(InvalidArgumentException::class);
new Count($this->getDatabaseName(), $this->getCollectionName(), $filter);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new Count($this->getDatabaseName(), $this->getCollectionName(), [], $options);
}
......
......@@ -2,16 +2,17 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\CreateCollection;
class CreateCollectionTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), $options);
}
......
......@@ -2,6 +2,7 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Driver\Exception\RuntimeException;
use MongoDB\Model\IndexInfo;
use MongoDB\Operation\CreateIndexes;
use MongoDB\Operation\DropIndexes;
......@@ -113,9 +114,6 @@ class CreateIndexesFunctionalTest extends FunctionalTestCase
});
}
/**
* @expectedException MongoDB\Driver\Exception\RuntimeException
*/
public function testCreateConflictingIndexesWithCommand()
{
$indexes = [
......@@ -124,6 +122,7 @@ class CreateIndexesFunctionalTest extends FunctionalTestCase
];
$operation = new CreateIndexes($this->getDatabaseName(), $this->getCollectionName(), $indexes);
$this->expectException(RuntimeException::class);
$createdIndexNames = $operation->execute($this->getPrimaryServer());
}
......
......@@ -2,25 +2,24 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\CreateIndexes;
class CreateIndexesTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage $indexes is not a list (unexpected index: "1")
*/
public function testConstructorIndexesArgumentMustBeAList()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('$indexes is not a list (unexpected index: "1")');
new CreateIndexes($this->getDatabaseName(), $this->getCollectionName(), [1 => ['key' => ['x' => 1]]]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new CreateIndexes($this->getDatabaseName(), $this->getCollectionName(), [['key' => ['x' => 1]]], $options);
}
......@@ -43,21 +42,19 @@ class CreateIndexesTest extends TestCase
return $options;
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage $indexes is empty
*/
public function testConstructorRequiresAtLeastOneIndex()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('$indexes is empty');
new CreateIndexes($this->getDatabaseName(), $this->getCollectionName(), []);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidIndexSpecificationTypes
*/
public function testConstructorRequiresIndexSpecificationsToBeAnArray($index)
{
$this->expectException(InvalidArgumentException::class);
new CreateIndexes($this->getDatabaseName(), $this->getCollectionName(), [$index]);
}
......
......@@ -2,25 +2,26 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\DatabaseCommand;
class DatabaseCommandTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorCommandArgumentTypeCheck($command)
{
$this->expectException(InvalidArgumentException::class);
new DatabaseCommand($this->getDatabaseName(), $command);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new DatabaseCommand($this->getDatabaseName(), ['ping' => 1], $options);
}
......
......@@ -6,6 +6,7 @@ use MongoDB\DeleteResult;
use MongoDB\Collection;
use MongoDB\Driver\BulkWrite;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\BadMethodCallException;
use MongoDB\Operation\Delete;
use MongoDB\Tests\CommandObserver;
use stdClass;
......@@ -99,11 +100,11 @@ class DeleteFunctionalTest extends FunctionalTestCase
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesDeletedCount(DeleteResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getDeletedCount();
}
......
......@@ -2,26 +2,27 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\Delete;
class DeleteTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorFilterArgumentTypeCheck($filter)
{
$this->expectException(InvalidArgumentException::class);
new Delete($this->getDatabaseName(), $this->getCollectionName(), $filter, 0);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage $limit must be 0 or 1
* @dataProvider provideInvalidLimitValues
*/
public function testConstructorLimitArgumentMustBeOneOrZero($limit)
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('$limit must be 0 or 1');
new Delete($this->getDatabaseName(), $this->getCollectionName(), [], $limit);
}
......@@ -31,11 +32,11 @@ class DeleteTest extends TestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new Delete($this->getDatabaseName(), $this->getCollectionName(), [], 1, $options);
}
......
......@@ -2,25 +2,26 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\Distinct;
class DistinctTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorFilterArgumentTypeCheck($filter)
{
$this->expectException(InvalidArgumentException::class);
new Distinct($this->getDatabaseName(), $this->getCollectionName(), 'x', $filter);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new Distinct($this->getDatabaseName(), $this->getCollectionName(), 'x', [], $options);
}
......
......@@ -2,16 +2,17 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\DropCollection;
class DropCollectionTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new DropCollection($this->getDatabaseName(), $this->getCollectionName(), $options);
}
......
......@@ -2,16 +2,17 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\DropDatabase;
class DropDatabaseTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new DropDatabase($this->getDatabaseName(), $options);
}
......
......@@ -2,24 +2,23 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\DropIndexes;
class DropIndexesTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
*/
public function testDropIndexShouldNotAllowEmptyIndexName()
{
$this->expectException(InvalidArgumentException::class);
new DropIndexes($this->getDatabaseName(), $this->getCollectionName(), '');
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new DropIndexes($this->getDatabaseName(), $this->getCollectionName(), '*', $options);
}
......
......@@ -2,6 +2,7 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\Count;
use MongoDB\Operation\Distinct;
use MongoDB\Operation\Explain;
......@@ -9,12 +10,12 @@ use MongoDB\Operation\Explain;
class ExplainTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$explainable = $this->getMockBuilder('MongoDB\Operation\Explainable')->getMock();
$this->expectException(InvalidArgumentException::class);
new Explain($this->getDatabaseName(), $explainable, $options);
}
......
......@@ -2,16 +2,17 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\FindAndModify;
class FindAndModifyTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new FindAndModify($this->getDatabaseName(), $this->getCollectionName(), $options);
}
......@@ -78,12 +79,10 @@ class FindAndModifyTest extends TestCase
return $options;
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage The "remove" option must be true or an "update" document must be specified, but not both
*/
public function testConstructorUpdateAndRemoveOptionsAreMutuallyExclusive()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The "remove" option must be true or an "update" document must be specified, but not both');
new FindAndModify($this->getDatabaseName(), $this->getCollectionName(), ['remove' => true, 'update' => []]);
}
}
......@@ -2,25 +2,26 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\FindOneAndDelete;
class FindOneAndDeleteTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorFilterArgumentTypeCheck($filter)
{
$this->expectException(InvalidArgumentException::class);
new FindOneAndDelete($this->getDatabaseName(), $this->getCollectionName(), $filter);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new FindOneAndDelete($this->getDatabaseName(), $this->getCollectionName(), [], $options);
}
......
......@@ -2,43 +2,42 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\FindOneAndReplace;
class FindOneAndReplaceTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorFilterArgumentTypeCheck($filter)
{
$this->expectException(InvalidArgumentException::class);
new FindOneAndReplace($this->getDatabaseName(), $this->getCollectionName(), $filter, []);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorReplacementArgumentTypeCheck($replacement)
{
$this->expectException(InvalidArgumentException::class);
new FindOneAndReplace($this->getDatabaseName(), $this->getCollectionName(), [], $replacement);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage First key in $replacement argument is an update operator
*/
public function testConstructorReplacementArgumentRequiresNoOperators()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('First key in $replacement argument is an update operator');
new FindOneAndReplace($this->getDatabaseName(), $this->getCollectionName(), [], ['$set' => ['x' => 1]]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new FindOneAndReplace($this->getDatabaseName(), $this->getCollectionName(), [], [], $options);
}
......@@ -58,11 +57,11 @@ class FindOneAndReplaceTest extends TestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorReturnDocumentOptions
*/
public function testConstructorReturnDocumentOption($returnDocument)
{
$this->expectException(InvalidArgumentException::class);
new FindOneAndReplace($this->getDatabaseName(), $this->getCollectionName(), [], [], ['returnDocument' => $returnDocument]);
}
......
......@@ -2,43 +2,42 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\FindOneAndUpdate;
class FindOneAndUpdateTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorFilterArgumentTypeCheck($filter)
{
$this->expectException(InvalidArgumentException::class);
new FindOneAndUpdate($this->getDatabaseName(), $this->getCollectionName(), $filter, []);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorUpdateArgumentTypeCheck($update)
{
$this->expectException(InvalidArgumentException::class);
new FindOneAndUpdate($this->getDatabaseName(), $this->getCollectionName(), [], $update);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage First key in $update argument is not an update operator
*/
public function testConstructorUpdateArgumentRequiresOperators()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('First key in $update argument is not an update operator');
new FindOneAndUpdate($this->getDatabaseName(), $this->getCollectionName(), [], []);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new FindOneAndUpdate($this->getDatabaseName(), $this->getCollectionName(), [], ['$set' => ['x' => 1]], $options);
}
......@@ -58,11 +57,11 @@ class FindOneAndUpdateTest extends TestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorReturnDocumentOptions
*/
public function testConstructorReturnDocumentOption($returnDocument)
{
$this->expectException(InvalidArgumentException::class);
new FindOneAndUpdate($this->getDatabaseName(), $this->getCollectionName(), [], [], ['returnDocument' => $returnDocument]);
}
......
......@@ -2,25 +2,26 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\Find;
class FindTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorFilterArgumentTypeCheck($filter)
{
$this->expectException(InvalidArgumentException::class);
new Find($this->getDatabaseName(), $this->getCollectionName(), $filter);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new Find($this->getDatabaseName(), $this->getCollectionName(), [], $options);
}
......@@ -133,11 +134,11 @@ class FindTest extends TestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorCursorTypeOptions
*/
public function testConstructorCursorTypeOption($cursorType)
{
$this->expectException(InvalidArgumentException::class);
new Find($this->getDatabaseName(), $this->getCollectionName(), [], ['cursorType' => $cursorType]);
}
......
......@@ -5,6 +5,7 @@ namespace MongoDB\Tests\Operation;
use MongoDB\Collection;
use MongoDB\InsertManyResult;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\BadMethodCallException;
use MongoDB\Model\BSONDocument;
use MongoDB\Operation\InsertMany;
use MongoDB\Tests\CommandObserver;
......@@ -90,11 +91,11 @@ class InsertManyFunctionalTest extends FunctionalTestCase
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesInsertedCount(InsertManyResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getInsertedCount();
}
......
......@@ -2,44 +2,41 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\InsertMany;
class InsertManyTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage $documents is empty
*/
public function testConstructorDocumentsMustNotBeEmpty()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('$documents is empty');
new InsertMany($this->getDatabaseName(), $this->getCollectionName(), []);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage $documents is not a list (unexpected index: "1")
*/
public function testConstructorDocumentsMustBeAList()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('$documents is not a list (unexpected index: "1")');
new InsertMany($this->getDatabaseName(), $this->getCollectionName(), [1 => ['x' => 1]]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$documents\[0\] to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorDocumentsArgumentElementTypeChecks($document)
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/Expected \$documents[0\] to have type "array or object" but found "[\w ]+"/');
new InsertMany($this->getDatabaseName(), $this->getCollectionName(), [$document]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new InsertMany($this->getDatabaseName(), $this->getCollectionName(), [['x' => 1]], $options);
}
......
......@@ -5,6 +5,7 @@ namespace MongoDB\Tests\Operation;
use MongoDB\Collection;
use MongoDB\InsertOneResult;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\BadMethodCallException;
use MongoDB\Model\BSONDocument;
use MongoDB\Operation\InsertOne;
use MongoDB\Tests\CommandObserver;
......@@ -105,11 +106,11 @@ class InsertOneFunctionalTest extends FunctionalTestCase
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesInsertedCount(InsertOneResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getInsertedCount();
}
......
......@@ -2,25 +2,26 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\InsertOne;
class InsertOneTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorDocumentArgumentTypeCheck($document)
{
$this->expectException(InvalidArgumentException::class);
new InsertOne($this->getDatabaseName(), $this->getCollectionName(), $document);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new InsertOne($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], $options);
}
......
......@@ -2,16 +2,17 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\ListCollections;
class ListCollectionsTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new ListCollections($this->getDatabaseName(), $options);
}
......
......@@ -2,16 +2,17 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\ListDatabases;
class ListDatabasesTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new ListDatabases($options);
}
......
......@@ -2,16 +2,17 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\ListIndexes;
class ListIndexesTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new ListIndexes($this->getDatabaseName(), $this->getCollectionName(), $options);
}
......
......@@ -4,13 +4,13 @@ namespace MongoDB\Tests\Operation;
use MongoDB\BSON\Javascript;
use MongoDB\BSON\ObjectId;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\MapReduce;
use stdClass;
class MapReduceTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidOutValues
*/
public function testConstructorOutArgumentTypeCheck($out)
......@@ -18,6 +18,7 @@ class MapReduceTest extends TestCase
$map = new Javascript('function() { emit(this.x, this.y); }');
$reduce = new Javascript('function(key, values) { return Array.sum(values); }');
$this->expectException(InvalidArgumentException::class);
new MapReduce($this->getDatabaseName(), $this->getCollectionName(), $map, $reduce, $out);
}
......@@ -27,7 +28,6 @@ class MapReduceTest extends TestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
......@@ -36,6 +36,7 @@ class MapReduceTest extends TestCase
$reduce = new Javascript('function(key, values) { return Array.sum(values); }');
$out = ['inline' => 1];
$this->expectException(InvalidArgumentException::class);
new MapReduce($this->getDatabaseName(), $this->getCollectionName(), $map, $reduce, $out, $options);
}
......
......@@ -2,26 +2,27 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Model\BSONDocument;
use MongoDB\Operation\ReplaceOne;
class ReplaceOneTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorFilterArgumentTypeCheck($filter)
{
$this->expectException(InvalidArgumentException::class);
new ReplaceOne($this->getDatabaseName(), $this->getCollectionName(), $filter, ['y' => 1]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorReplacementArgumentTypeCheck($replacement)
{
$this->expectException(InvalidArgumentException::class);
new ReplaceOne($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], $replacement);
}
......@@ -35,12 +36,12 @@ class ReplaceOneTest extends TestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage First key in $replacement argument is an update operator
* @dataProvider provideUpdateDocuments
*/
public function testConstructorReplacementArgumentRequiresNoOperators($replacement)
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('First key in $replacement argument is an update operator');
new ReplaceOne($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], $replacement);
}
......
......@@ -6,6 +6,7 @@ use MongoDB\Collection;
use MongoDB\UpdateResult;
use MongoDB\Driver\BulkWrite;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\BadMethodCallException;
use MongoDB\Operation\Update;
use MongoDB\Tests\CommandObserver;
use stdClass;
......@@ -165,41 +166,41 @@ class UpdateFunctionalTest extends FunctionalTestCase
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesMatchedCount(UpdateResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getMatchedCount();
}
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesModifiedCount(UpdateResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getModifiedCount();
}
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesUpsertedCount(UpdateResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getUpsertedCount();
}
/**
* @depends testUnacknowledgedWriteConcern
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessageRegExp /[\w:\\]+ should not be called for an unacknowledged write result/
*/
public function testUnacknowledgedWriteConcernAccessesUpsertedId(UpdateResult $result)
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
$result->getUpsertedId();
}
......
......@@ -2,26 +2,27 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Model\BSONDocument;
use MongoDB\Operation\UpdateMany;
class UpdateManyTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorFilterArgumentTypeCheck($filter)
{
$this->expectException(InvalidArgumentException::class);
new UpdateMany($this->getDatabaseName(), $this->getCollectionName(), $filter, ['$set' => ['x' => 1]]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorUpdateArgumentTypeCheck($update)
{
$this->expectException(InvalidArgumentException::class);
new UpdateMany($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], $update);
}
......@@ -35,12 +36,12 @@ class UpdateManyTest extends TestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage First key in $update argument is not an update operator
* @dataProvider provideReplacementDocuments
*/
public function testConstructorUpdateArgumentRequiresOperators($replacement)
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('First key in $update argument is not an update operator');
new UpdateMany($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], $replacement);
}
......
......@@ -2,26 +2,27 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Model\BSONDocument;
use MongoDB\Operation\UpdateOne;
class UpdateOneTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorFilterArgumentTypeCheck($filter)
{
$this->expectException(InvalidArgumentException::class);
new UpdateOne($this->getDatabaseName(), $this->getCollectionName(), $filter, ['$set' => ['x' => 1]]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorUpdateArgumentTypeCheck($update)
{
$this->expectException(InvalidArgumentException::class);
new UpdateOne($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], $update);
}
......@@ -35,12 +36,12 @@ class UpdateOneTest extends TestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage First key in $update argument is not an update operator
* @dataProvider provideReplacementDocuments
*/
public function testConstructorUpdateArgumentRequiresOperators($replacement)
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('First key in $update argument is not an update operator');
new UpdateOne($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], $replacement);
}
......
......@@ -2,36 +2,37 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\Update;
class UpdateTest extends TestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$filter to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorFilterArgumentTypeCheck($filter)
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/Expected \$filter to have type "array or object" but found "[\w ]+"/');
new Update($this->getDatabaseName(), $this->getCollectionName(), $filter, ['$set' => ['x' => 1]]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$update to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
*/
public function testConstructorUpdateArgumentTypeCheck($update)
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/Expected \$update to have type "array or object" but found "[\w ]+"/');
new Update($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], $update);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new Update($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], ['y' => 1], $options);
}
......
......@@ -8,6 +8,7 @@ use MongoDB\Driver\Manager;
use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\ConnectionTimeoutException;
use MongoDB\Exception\ResumeTokenException;
use MongoDB\Operation\DatabaseCommand;
use MongoDB\Operation\InsertOne;
use MongoDB\Operation\Watch;
......@@ -305,14 +306,13 @@ class WatchFunctionalTest extends FunctionalTestCase
$this->assertFalse($cursor->isDead());
}
/**
* @expectedException MongoDB\Exception\ResumeTokenException
* @expectedExceptionMessage Resume token not found in change document
*/
public function testNextResumeTokenNotFound()
{
$pipeline = [['$project' => ['_id' => 0 ]]];
$this->expectException(ResumeTokenException::class);
$this->expectExceptionMessage('Resume token not found in change document');
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), $pipeline, ['maxAwaitTimeMS' => 100]);
$changeStream = $operation->execute($this->getPrimaryServer());
......@@ -323,14 +323,13 @@ class WatchFunctionalTest extends FunctionalTestCase
$changeStream->next();
}
/**
* @expectedException MongoDB\Exception\ResumeTokenException
* @expectedExceptionMessage Resume token not found in change document
*/
public function testRewindResumeTokenNotFound()
{
$pipeline = [['$project' => ['_id' => 0 ]]];
$this->expectException(ResumeTokenException::class);
$this->expectExceptionMessage('Resume token not found in change document');
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), $pipeline, ['maxAwaitTimeMS' => 100]);
$changeStream = $operation->execute($this->getPrimaryServer());
......@@ -339,14 +338,13 @@ class WatchFunctionalTest extends FunctionalTestCase
$changeStream->rewind();
}
/**
* @expectedException MongoDB\Exception\ResumeTokenException
* @expectedExceptionMessage Expected resume token to have type "array or object" but found "string"
*/
public function testNextResumeTokenInvalidType()
{
$pipeline = [['$project' => ['_id' => ['$literal' => 'foo']]]];
$this->expectException(ResumeTokenException::class);
$this->expectExceptionMessage('Expected resume token to have type "array or object" but found "string"');
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), $pipeline, ['maxAwaitTimeMS' => 100]);
$changeStream = $operation->execute($this->getPrimaryServer());
......@@ -357,14 +355,13 @@ class WatchFunctionalTest extends FunctionalTestCase
$changeStream->next();
}
/**
* @expectedException MongoDB\Exception\ResumeTokenException
* @expectedExceptionMessage Expected resume token to have type "array or object" but found "string"
*/
public function testRewindResumeTokenInvalidType()
{
$pipeline = [['$project' => ['_id' => ['$literal' => 'foo']]]];
$this->expectException(ResumeTokenException::class);
$this->expectExceptionMessage('Expected resume token to have type "array or object" but found "string"');
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), $pipeline, ['maxAwaitTimeMS' => 100]);
$changeStream = $operation->execute($this->getPrimaryServer());
......
......@@ -2,6 +2,7 @@
namespace MongoDB\Tests\Operation;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\Watch;
/**
......@@ -10,12 +11,11 @@ use MongoDB\Operation\Watch;
*/
class WatchTest extends FunctionalTestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage $pipeline is not a list (unexpected index: "foo")
*/
public function testConstructorPipelineArgumentMustBeAList()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('$pipeline is not a list (unexpected index: "foo")');
/* Note: Watch uses array_unshift() to prepend the $changeStream stage
* to the pipeline. Since array_unshift() reindexes numeric keys, we'll
* use a string key to test for this exception. */
......@@ -23,11 +23,11 @@ class WatchTest extends FunctionalTestCase
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecks(array $options)
{
$this->expectException(InvalidArgumentException::class);
new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $options);
}
......
......@@ -11,6 +11,33 @@ use stdClass;
abstract class TestCase extends BaseTestCase
{
public function expectException($exception)
{
if (method_exists(BaseTestCase::class, 'expectException')) {
parent::expectException($exception);
return;
}
parent::setExpectedException($exception);
}
public function expectExceptionMessage($exceptionMessage)
{
if (method_exists(BaseTestCase::class, 'expectExceptionMessage')) {
parent::expectExceptionMessage($exceptionMessage);
return;
}
parent::setExpectedException($this->getExpectedException(), $exceptionMessage);
}
public function expectExceptionMessageRegExp($exceptionMessageRegExp)
{
if (method_exists(BaseTestCase::class, 'expectExceptionMessageRegExp')) {
parent::expectExceptionMessageRegExp($exceptionMessageRegExp);
return;
}
parent::setExpectedExceptionRegExp($this->getExpectedException(), $exceptionMessageRegExp);
}
public function provideInvalidArrayValues()
{
return $this->wrapValuesForDataProvider($this->getInvalidArrayValues());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment