File: bug00672.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 (31 lines) | stat: -rw-r--r-- 761 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
--TEST--
Test for PHP-672: MongoGridFSFile::write() leaks memory
--SKIPIF--
<?php require_once "tests/utils/standalone.inc";?>
--FILE--
<?php
require_once "tests/utils/server.inc";
$mongo = new_mongo_standalone();
$gridfs = $mongo->files->getGridFS();
$gridfs->drop();
$i = 0;
foreach(glob(dirname(__FILE__) . "/*") as $file) {
    $gridfs->put($file);
    if ($i++ > 10) {
        break;
    }
}

$file = $mongo->files->getGridFS()->find()->sort(array('length' => -1))->limit(1)->getNext();

$attempts = 10;
while ($attempts--) {
	$mongo->files->getGridFS()->find()->sort(array('length' => -1))->limit(1)->getNext()->write('./test.bin');
}
@unlink("./test.bin");

echo "No memory leaks should be reported\n";
?>
--EXPECTF--
No memory leaks should be reported