Source of file OrderProcessorTest_PlaceFailExtension.php
Size: 0,622 Bytes - Last Modified: 2021-12-24T06:35:03+00:00
/var/www/docs.ssmods.com/process/src/tests/php/Checkout/OrderProcessorTest_PlaceFailExtension.php
123456789101112131415161718192021222324252627 | <?php namespace SilverShop\Tests\Checkout; // Extension to Order that will allow us a failed placement use SilverStripe\Dev\TestOnly; use SilverStripe\ORM\DataExtension; class OrderProcessorTest_PlaceFailExtension extends DataExtension implements TestOnly { private $willFail = false; public function onPlaceOrder() { // flag this order to fail $this->willFail = true; } public function onAfterWrite() { // fail after writing, so that we can test if DB rollback works as intended if ($this->willFail) { user_error('Order failed'); } } } |