Source of file ShoppingCartTest_TestShoppingCartErroringHooksExtension.php
Size: 0,562 Bytes - Last Modified: 2021-12-24T06:35:03+00:00
/var/www/docs.ssmods.com/process/src/tests/php/Cart/ShoppingCartTest_TestShoppingCartErroringHooksExtension.php
123456789101112131415161718192021222324 | <?php namespace SilverShop\Tests\Cart; use SilverStripe\Core\Extension; use SilverStripe\Dev\TestOnly; class ShoppingCartTest_TestShoppingCartErroringHooksExtension extends Extension implements TestOnly { public function beforeSetQuantity($buyable, $quantity, $filter) { if ($quantity > 10) { throw new \Exception('Invalid quantity'); } } public function afterAdd($item, $buyable, $quantity, $filter) { if ($item->Quantity > 1) { throw new \Exception('Invalid quantity'); } } } |