MongoDBTest.php 871 B

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