File: mongogridfs-storefile_error-001.phpt

package info (click to toggle)
php-mongo 1.4.5-1~bpo70%2B1
  • links: PTS
  • area: main
  • in suites: wheezy-backports
  • size: 9,828 kB
  • sloc: ansic: 13,275; xml: 1,702; php: 1,625; pascal: 255; makefile: 106; sh: 27
file content (23 lines) | stat: -rw-r--r-- 710 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
--TEST--
MongoGridFS::storeFile() throws exception if insert fails with safe option
--SKIPIF--
<?php require "tests/utils/standalone.inc";?>
--FILE--
<?php
require_once "tests/utils/server.inc";
$mongo = mongo_standalone();
$db = $mongo->selectDB(dbname());

$gridfs = $db->getGridFS();
$gridfs->drop();
$gridfs->storeFile(__FILE__, array('_id' => 1), array('safe' => true));

try {
    $gridfs->storeFile(__FILE__, array('_id' => 1), array('safe' => true));
    var_dump(false);
} catch (MongoGridFSException $e) {
    var_dump($e->getMessage(), $e->getCode());
}
--EXPECTF--
string(%d) "Could not store file:%sE11000 duplicate key error index: %s.fs.chunks.$files_id_1_n_1  dup key: { : 1, : 0 }"
int(11000)