Source of file PartialUseDiscountTest.php
Size: 1,560 Bytes - Last Modified: 2021-12-24T06:35:13+00:00
/var/www/docs.ssmods.com/process/src/tests/PartialUseDiscountTest.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | <?php namespace SilverShop\Discounts\Tests; use SilverStripe\Dev\SapphireTest; use SilverShop\Discounts\Model\PartialUseDiscount; class PartialUseDiscountTest extends SapphireTest { protected static $fixture_file = [ 'shop.yml', 'PartialUseDiscount.yml' ]; public function testCreateRemainder() { //basic remainder $discount = $this->objFromFixture(PartialUseDiscount::class, 'partial'); $this->assertNull($discount->createRemainder(5000)); $this->assertNull($discount->createRemainder(90)); $remainderdiscount = $discount->createRemainder(40); $this->assertEquals(50, $remainderdiscount->Amount, 'Subtract $40 from $90 discount'); $discount->Active = false; $discount->write(); $this->assertNull($discount->createRemainder(30), 'Cannot recreate remainder'); //TODO: check basic relationships match, e.g. group //check constraints copying works $discount = $this->objFromFixture(PartialUseDiscount::class, 'constrained'); $remainder = $discount->createRemainder(40); $this->assertListEquals( [ ['FirstName' => 'Joe'] ], $remainder->Members() ); $this->assertListEquals( [ ['Title' => 'ProductA'], ['Title' => 'ProductB'] ], $remainder->Products() ); } public function testCheckoutProcessing() { $this->markTestIncomplete('This should be tested'); } } |