-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathMongaTests.php
71 lines (55 loc) · 1.63 KB
/
MongaTests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
use League\Monga;
class MongaTests extends PHPUnit_Framework_TestCase
{
public function testMongaId()
{
$id = Monga::id('516ba5033b21c50005a93f76');
$this->assertInstanceOf('MongoId', $id);
}
public function testMongoData()
{
$data = Monga::data('something');
$this->assertInstanceOf('MongoBinData', $data);
}
public function testMongoDataWithType()
{
$data = Monga::data('something', MongoBinData::CUSTOM);
$this->assertInstanceOf('MongoBinData', $data);
$this->assertEquals($data->bin, 'something');
$this->assertEquals($data->type, MongoBinData::CUSTOM);
}
public function testMongaCode()
{
$code = Monga::code('__code__');
$this->assertInstanceOf('MongoCode', $code);
$string = (string) $code;
$this->assertEquals('__code__', $string);
}
public function testMongaDate()
{
// random time
$time = time() - 100;
$date = Monga::date($time, 2);
$this->assertInstanceOf('MongoDate', $date);
$this->assertEquals($time, $date->sec);
}
public function testMongaRegex()
{
$regex = Monga::regex('/(.*)/imu');
$this->assertInstanceOf('MongoRegex', $regex);
$this->assertEquals('imu', $regex->flags);
}
/**
* @expectedException MongoException
*/
public function testInvalidRegex()
{
$regex = Monga::regex('#(.*)#imu');
}
public function testMongaConnection()
{
$connection = Monga::connection();
$this->assertInstanceOf('League\Monga\\Connection', $connection);
}
}