MongoDBTest.php 890 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Alcaeus\MongoDbAdapter\Tests;
  3. /**
  4. * @author alcaeus <alcaeus@alcaeus.org>
  5. * @covers MongoDB
  6. */
  7. class MongoDBTest extends TestCase
  8. {
  9. public function testGetCollection()
  10. {
  11. $db = $this->getDatabase();
  12. $collection = $db->selectCollection('test');
  13. $this->assertInstanceOf('MongoCollection', $collection);
  14. $this->assertSame('mongo-php-adapter.test', (string) $collection);
  15. }
  16. public function testGetCollectionProperty()
  17. {
  18. $db = $this->getDatabase();
  19. $collection = $db->test;
  20. $this->assertInstanceOf('MongoCollection', $collection);
  21. $this->assertSame('mongo-php-adapter.test', (string) $collection);
  22. }
  23. /**
  24. * @return \MongoDB
  25. */
  26. protected function getDatabase()
  27. {
  28. $client = new \MongoClient();
  29. return $client->selectDB('mongo-php-adapter');
  30. }
  31. }