public function UbercartStockTestCase::testStockDecrement in Ubercart 7.3
Same name and namespace in other branches
- 6.2 uc_stock/uc_stock.test \UbercartStockTestCase::testStockDecrement()
File
- uc_stock/
tests/ uc_stock.test, line 52 - Ubercart stock related tests.
Class
- UbercartStockTestCase
- @file Ubercart stock related tests.
Code
public function testStockDecrement() {
$stock = rand(100, 1000);
$edit = array(
'stock[0][active]' => 1,
'stock[0][stock]' => $stock,
);
$this
->drupalPost('node/' . $this->product->nid . '/edit/stock', $edit, t('Save changes'));
$this
->assertText('Stock settings saved.');
// Enable product quantity field.
variable_set('uc_product_add_to_cart_qty', TRUE);
$qty = rand(1, 100);
$edit = array(
'qty' => $qty,
);
$this
->drupalPost('node/' . $this->product->nid, $edit, t('Add to cart'));
$this
->checkout();
$this
->assertEqual($stock - $qty, uc_stock_level($this->product->model));
}