MongoCodeTest.php 835 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Alcaeus\MongoDbAdapter\Tests;
  3. /**
  4. * @author alcaeus <alcaeus@alcaeus.org>
  5. */
  6. class MongoCodeTest extends TestCase
  7. {
  8. public function testCreate()
  9. {
  10. $code = new \MongoCode('code', ['scope' => 'bleh']);
  11. $this->assertAttributeSame('code', 'code', $code);
  12. $this->assertAttributeSame(['scope' => 'bleh'], 'scope', $code);
  13. $this->assertSame('code', (string) $code);
  14. $bsonCode = $code->toBSONType();
  15. $this->assertInstanceOf('MongoDB\BSON\Javascript', $bsonCode);
  16. }
  17. public function testCreateWithBsonObject()
  18. {
  19. $bsonCode = new \MongoDB\BSON\Javascript('code', ['scope' => 'bleh']);
  20. $code = new \MongoCode($bsonCode);
  21. $this->assertAttributeSame('', 'code', $code);
  22. $this->assertAttributeSame([], 'scope', $code);
  23. }
  24. }