MongoRegexTest.php 909 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace Alcaeus\MongoDbAdapter\Tests;
  3. /**
  4. * @author alcaeus <alcaeus@alcaeus.org>
  5. */
  6. class MongoRegexTest extends TestCase
  7. {
  8. public function testCreate()
  9. {
  10. $regex = new \MongoRegex('/abc/i');
  11. $this->assertAttributeSame('abc', 'regex', $regex);
  12. $this->assertAttributeSame('i', 'flags', $regex);
  13. $this->assertSame('/abc/i', (string) $regex);
  14. $bsonRegex = $regex->toBSONType();
  15. $this->assertInstanceOf('MongoDB\BSON\Regex', $bsonRegex);
  16. $this->assertSame('abc', $bsonRegex->getPattern());
  17. $this->assertSame('i', $bsonRegex->getFlags());
  18. }
  19. public function testCreateWithBsonType()
  20. {
  21. $bsonRegex = new \MongoDB\BSON\Regex('abc', 'i');
  22. $regex = new \MongoRegex($bsonRegex);
  23. $this->assertAttributeSame('abc', 'regex', $regex);
  24. $this->assertAttributeSame('i', 'flags', $regex);
  25. }
  26. }