MongoBinDataTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Alcaeus\MongoDbAdapter\Tests;
  3. /**
  4. * @author alcaeus <alcaeus@alcaeus.org>
  5. */
  6. class MongoBinDataTest extends TestCase
  7. {
  8. public function testCreate()
  9. {
  10. $bin = new \MongoBinData('foo', \MongoBinData::FUNC);
  11. $this->assertAttributeSame('foo', 'bin', $bin);
  12. $this->assertAttributeSame(\MongoBinData::FUNC, 'type', $bin);
  13. $this->assertSame('<Mongo Binary Data>', (string) $bin);
  14. $bsonBinary = $bin->toBSONType();
  15. $this->assertInstanceOf('MongoDB\BSON\Binary', $bsonBinary);
  16. $this->assertSame('foo', $bsonBinary->getData());
  17. $this->assertSame(\MongoDB\BSON\Binary::TYPE_FUNCTION, $bsonBinary->getType());
  18. }
  19. public function testCreateWithBsonBinary()
  20. {
  21. $bsonBinary = new \MongoDB\BSON\Binary('foo', \MongoDB\BSON\Binary::TYPE_UUID);
  22. $bin = new \MongoBinData($bsonBinary);
  23. $this->assertAttributeSame('foo', 'bin', $bin);
  24. $this->assertAttributeSame(\MongoBinData::UUID_RFC4122, 'type', $bin);
  25. }
  26. }