File: mongobindata-004.phpt

package info (click to toggle)
php-mongo 1.5.7-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,040 kB
  • ctags: 2,802
  • sloc: ansic: 17,632; xml: 2,195; php: 1,630; pascal: 330; makefile: 52; sh: 39
file content (34 lines) | stat: -rw-r--r-- 1,145 bytes parent folder | download
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
--TEST--
MongoBinData insertion with various types
--SKIPIF--
<?php require_once "tests/utils/standalone.inc";?>
--FILE--
<?php
require_once "tests/utils/server.inc";
$mongo = mongo_standalone();
$coll = $mongo->selectCollection(dbname(), 'mongobindata');
$coll->drop();

$coll->insert(array('bin' => new MongoBinData('pqr', MongoBinData::GENERIC)));
$coll->insert(array('bin' => new MongoBinData('abc', MongoBinData::FUNC)));
$coll->insert(array('bin' => new MongoBinData('def', MongoBinData::BYTE_ARRAY)));
$coll->insert(array('bin' => new MongoBinData('ghi', MongoBinData::UUID)));
$coll->insert(array('bin' => new MongoBinData('stu', MongoBinData::UUID_RFC4122)));
$coll->insert(array('bin' => new MongoBinData('jkl', MongoBinData::MD5)));
$coll->insert(array('bin' => new MongoBinData('mno', MongoBinData::CUSTOM)));


$cursor = $coll->find();

foreach ($cursor as $result) {
    printf("Type %d with data \"%s\"\n", $result['bin']->type, $result['bin']->bin);
}
?>
--EXPECT--
Type 0 with data "pqr"
Type 1 with data "abc"
Type 2 with data "def"
Type 3 with data "ghi"
Type 4 with data "stu"
Type 5 with data "jkl"
Type 128 with data "mno"