/** * @covers Imbo\Database\MongoDB::getCollection * @expectedException Imbo\Exception\DatabaseException * @expectedExceptionMessage Could not select collection * @expectedExceptionCode 500 */ public function testThrowsExceptionWhenNotAbleToGetCollection() { $driver = new MongoDB([], $this->mongoClient); $this->mongoClient->expects($this->once())->method('selectCollection')->will($this->throwException(new MongoException())); $method = new ReflectionMethod('Imbo\\Database\\MongoDB', 'getCollection'); $method->setAccessible(true); $method->invoke($driver, 'image'); }
/** * @expectedException Imbo\Exception\DatabaseException * @expectedExceptionCode 500 * @expectedExceptionMessage Could not select collection */ public function testThrowsExceptionWhenNotAbleToGetAclGroupCollection() { $adapter = new MongoDB(['databaseName' => 'somename'], $this->client); $this->client->expects($this->once())->method('selectCollection')->with('somename', 'accesscontrolgroup')->will($this->throwException(new MongoException())); $adapter->groupExists('name'); }