File: bug00747.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 (54 lines) | stat: -rw-r--r-- 1,054 bytes parent folder | download | duplicates (2)
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
--TEST--
Test for PHP-747: Improve numeric check for write concern option
--SKIPIF--
<?php if (version_compare(phpversion(), "5.3.0", "lt")) exit("skip setCallback and closures are 5.3+"); ?>
--FILE--
<?php
include 'tests/utils/server.inc';

printlogs(MongoLog::ALL, MongoLog::ALL, '/^- Found option \'w\'/');
$formats = array(
	'w=',
	'w=0',
	'w=1',
	'w=1-',
	'w=fasdfads',
	'w=873253',
	'w=-1',
	'w=majority',
	'w=allDCs',
	'w=3.141592654',
);

foreach($formats as $format) {
	try {
		$m = new MongoClient('mongodb://localhost/?' . $format, array('connect' => false ) );
	} catch (MongoConnectionException $e) {
		var_dump($e->getCode());
		var_dump($e->getMessage());
	}
	echo "\n";
}
?>
--EXPECT--
- Found option 'w': 0

- Found option 'w': 0

- Found option 'w': 1

- Found option 'w': '1-'

- Found option 'w': 'fasdfads'

- Found option 'w': 873253

- Found option 'w': -1
int(23)
string(55) "The value of 'w' needs to be 0 or higher (or a string)."

- Found option 'w': 'majority'

- Found option 'w': 'allDCs'

- Found option 'w': '3.141592654'