1
+ --TEST--
2
+ MongoCursor::count() inherits socket timeout from cursor
3
+ --SKIPIF--
4
+ <?php if (version_compare (phpversion (), "5.3.0 " , "lt " )) exit ("skip setCallback and closures are 5.3+ " ); ?>
5
+ <?php if (!MONGO_STREAMS ) { echo "skip This test requires streams support " ; } ?>
6
+ <?php require_once "tests/utils/standalone.inc " ; ?>
7
+ --FILE--
8
+ <?php require_once "tests/utils/server.inc " ; ?>
9
+ <?php
10
+
11
+ $ host = MongoShellServer::getStandaloneInfo ();
12
+ $ m = new MongoClient ($ host );
13
+ $ c = $ m ->selectCollection (dbname (), collname (__FILE__ ));
14
+
15
+ $ c ->drop ();
16
+ $ c ->insert (array ('x ' => 1 ));
17
+ $ c ->insert (array ('x ' => 2 ));
18
+ $ c ->insert (array ('x ' => 3 ));
19
+ $ c ->insert (array ('x ' => 4 ));
20
+
21
+ printLogs (MongoLog::ALL , MongoLog::ALL , "/timeout/i " );
22
+
23
+ printf ("Count all documents, default timeout: %d \n" , $ c ->find ()->count ());
24
+ echo "\n" ;
25
+ printf ("Count all documents, timeout = 1000: %d \n" , $ c ->find ()->timeout (1000 )->count ());
26
+ ?>
27
+ ===DONE===
28
+ --EXPECTF--
29
+ Initializing cursor timeout to 30000 (from connection options)
30
+ Initializing cursor timeout to 30000 (from connection options)
31
+ No timeout changes for %s:%d;-;%s;%d
32
+ No timeout changes for %s:%d;-;%s;%d
33
+ Count all documents, default timeout: 4
34
+
35
+ Initializing cursor timeout to 30000 (from connection options)
36
+ Initializing cursor timeout to 30000 (from connection options)
37
+ Setting the stream timeout to 1.000000
38
+ Now setting stream timeout back to 30.000000
39
+ Setting the stream timeout to 1.000000
40
+ Now setting stream timeout back to 30.000000
41
+ Count all documents, timeout = 1000: 4
42
+ ===DONE===
0 commit comments