$serial = lastElement($quantity->serials());
$quantity->set($serial, $props = range(1, 1200));
$res = stockpile($app, $user_id)->add($item_id, $quantity);
Tap::is($res, $quantity, 'after storing a large list of properties, result coming back still matches. db didn\'t truncate');
// this test doesn't quite work because of caching layer.
$item_id = uniqueNumber(1, 10000000);
$stockpile = stockpile($app, $user_id);
$q = $stockpile->quantity();
$q->set($stockpile->newId(), array());
$stockpile->add($item_id, $q);
$q = $stockpile->get($item_id);
Tap::is(lastElement($q->all()), array(), 'empty properties before callback validator is attached');
$stockpile = new QuantityInspector($stockpile, 'Gaia\\Stockpile\\sanitizeQuantity');
$q = $stockpile->get($item_id);
Tap::is(lastElement($q->all()), array('xp' => 1), 'callback function populated xp into read quantity object');
$stockpile = new QuantityInspector(stockpile($app, $user_id), 'Gaia\\Stockpile\\sanitizeQuantity');
$item_id = uniqueNumber(1, 10000000);
$q = $stockpile->quantity();
$q->set($stockpile->newId(), array());
$res = $stockpile->add($item_id, $q);
Tap::is(lastElement($res->all()), array('xp' => 1), 'callback function populated xp into the quantity on add');
$user_id = uniqueUserID();
$item_id = uniqueNumber(1, 10000000);
$stockpile = stockpile($app, $user_id);
$q = $stockpile->quantity();
$q->set($stockpile->newId(), array());
$q->set($stockpile->newId(), array());
$q->set($stockpile->newId(), array());
$total = $stockpile->add($item_id, $q);
Tap::is($stockpile->set($item_id, $total), $total, 'When calling set with the same set of serials, no items created or subtracted');
$new = $total->grab(array(lastElement($total->serials())));
$item_id = uniqueNumber(1, 10000000);
$quantity = $stockpile->quantity(1);
$serial = lastElement($quantity->serials());
$quantity->set($serial, $props = range(1, 1200));
$res = stockpile($app, $user_id)->add($item_id, $quantity);
Tap::is($res, $quantity, 'after storing a large list of properties, result coming back still matches. db didn\'t truncate');
// this test doesn't quite work because of caching layer.
$item_id = uniqueNumber(1, 10000000);
$stockpile = stockpile($app, $user_id);
$stockpile->add($item_id);
$q = $stockpile->get($item_id);
Tap::is(lastElement($q->all()), array(), 'empty properties before callback validator is attached');
$stockpile = new QuantityInspector($stockpile, 'Gaia\\Stockpile\\sanitizeQuantity');
$q = $stockpile->get($item_id);
Tap::is(lastElement($q->all()), array('xp' => 1), 'callback function populated xp into read quantity object');
$stockpile = new QuantityInspector(stockpile($app, $user_id), 'Gaia\\Stockpile\\sanitizeQuantity');
$item_id = uniqueNumber(1, 10000000);
$res = $stockpile->add($item_id, 1);
Tap::is(lastElement($res->all()), array('xp' => 1), 'callback function populated xp into the quantity on add');
$user_id = uniqueUserID();
$item_id = uniqueNumber(1, 10000000);
$stockpile = stockpile($app, $user_id);
$total = $stockpile->add($item_id, 3);
Tap::is($stockpile->set($item_id, $total), $total, 'When calling set with the same set of serials, no items created or subtracted');
$new = $total->grab(array(lastElement($total->serials())));
Tap::is($stockpile->set($item_id, $new), $new, 'When removing  a serial, everything matches up');
Tap::is($stockpile->set($item_id, $total), $total, 'When adding back a serial, everything matches up');
$user_id1 = uniqueUserID();
$user_id2 = uniqueUserID();
$item_id = uniqueNumber(1, 10000000);
Transaction::reset();