Skip to content

Commit dd16db9

Browse files
committed
PHPC-180: Fix limited batch import
Also fixed cache mtime debug check :)
1 parent b32ebba commit dd16db9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/utils/fixtures-users.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if ( ! is_readable(__DIR__ . '/../../vendor/autoload.php')) {
44
exit('skip composer dependencies not available');
55
}
66

7-
$LIMIT = isset($LIMIT) ? (int)$LIMIT : 8192;
7+
$LIMIT = isset($LIMIT) ? (int)$LIMIT : 1024;
88

99
require_once __DIR__ . '/basic.inc';
1010
require_once __DIR__ . '/../../vendor/autoload.php';
@@ -55,7 +55,7 @@ $manager = new MongoDB\Driver\Manager(STANDALONE);
5555
$bulk = new MongoDB\Driver\BulkWrite;
5656

5757

58-
if (file_exists($CACHE) && filemtime($CACHE) < filemtime(__FILE__)) {
58+
if (file_exists($CACHE) && filemtime($CACHE) > filemtime(__FILE__)) {
5959
$data = file_get_contents($CACHE);
6060
$users = json_decode($data, true);
6161
} else {
@@ -73,14 +73,14 @@ if (file_exists($CACHE) && filemtime($CACHE) < filemtime(__FILE__)) {
7373
foreach($users as $n => $user) {
7474
$bulk->insert($user);
7575

76-
if ($n >= $LIMIT) {
76+
if ($n >= $LIMIT-1) {
7777
break;
7878
}
7979
}
8080
$retval = $manager->executeBulkWrite(NS, $bulk);
8181

82-
if ($retval->getInsertedCount() !== 1024) {
83-
exit(sprintf('skip Fixtures were not loaded (expected: %d, actual: %d)', 1024, $retval->getInsertedCount()));
82+
if ($retval->getInsertedCount() !== $LIMIT) {
83+
exit(sprintf('skip Fixtures were not loaded (expected: %d, actual: %d)', $LIMIT, $retval->getInsertedCount()));
8484
}
8585

8686

0 commit comments

Comments
 (0)