Fix phpunit tests

This commit is contained in:
dinamiko 2022-03-17 16:29:30 +01:00
parent afd77cf9da
commit a237b9af53
2 changed files with 10 additions and 5 deletions

View file

@ -68,11 +68,11 @@ class AmountFactoryTest extends TestCase
$this->assertEquals((float) 1, $result->value());
$this->assertEquals((float) 10, $result->breakdown()->discount()->value());
$this->assertEquals($this->currency, $result->breakdown()->discount()->currency_code());
$this->assertEquals((float) 9, $result->breakdown()->shipping()->value());
$this->assertEquals((float) 4, $result->breakdown()->shipping()->value());
$this->assertEquals($this->currency, $result->breakdown()->shipping()->currency_code());
$this->assertEquals((float) 5, $result->breakdown()->item_total()->value());
$this->assertEquals($this->currency, $result->breakdown()->item_total()->currency_code());
$this->assertEquals((float) 8, $result->breakdown()->tax_total()->value());
$this->assertEquals((float) 13, $result->breakdown()->tax_total()->value());
$this->assertEquals($this->currency, $result->breakdown()->tax_total()->currency_code());
}
@ -161,7 +161,7 @@ class AmountFactoryTest extends TestCase
$result = $this->testee->from_wc_order($order);
$this->assertEquals((float) 3, $result->breakdown()->discount()->value());
$this->assertEquals((float) 6, $result->breakdown()->item_total()->value());
$this->assertEquals((float) 1.5, $result->breakdown()->shipping()->value());
$this->assertEquals((float) 1, $result->breakdown()->shipping()->value());
$this->assertEquals((float) 100, $result->value());
$this->assertEquals((float) 2, $result->breakdown()->tax_total()->value());
$this->assertEquals($this->currency, $result->breakdown()->discount()->currency_code());

View file

@ -41,6 +41,7 @@ class ItemFactoryTest extends TestCase
$cart
->expects('get_cart_contents')
->andReturn($items);
$cart->expects('get_shipping_tax')->andReturn(1);
expect('wc_get_price_including_tax')
->with($product)
@ -72,7 +73,7 @@ class ItemFactoryTest extends TestCase
$this->assertEquals('name', $item->name());
$this->assertEquals('sku', $item->sku());
$this->assertEquals(1, $item->unit_amount()->value());
$this->assertEquals(2, $item->tax()->value());
$this->assertEquals(3, $item->tax()->value());
}
public function testFromCartDigitalGood()
@ -102,6 +103,7 @@ class ItemFactoryTest extends TestCase
$cart
->expects('get_cart_contents')
->andReturn($items);
$cart->expects('get_shipping_tax')->andReturn(1);
expect('wc_get_price_including_tax')
->with($product)
@ -172,6 +174,7 @@ class ItemFactoryTest extends TestCase
$order
->expects('get_fees')
->andReturn([]);
$order->expects('get_shipping_tax')->andReturn(1);
$result = $testee->from_wc_order($order);
$this->assertCount(1, $result);
@ -185,7 +188,7 @@ class ItemFactoryTest extends TestCase
$this->assertEquals(1, $item->quantity());
$this->assertEquals(Item::PHYSICAL_GOODS, $item->category());
$this->assertEquals(1, $item->unit_amount()->value());
$this->assertEquals(2, $item->tax()->value());
$this->assertEquals(3, $item->tax()->value());
}
public function testFromWcOrderDigitalGood()
@ -235,6 +238,7 @@ class ItemFactoryTest extends TestCase
$order
->expects('get_fees')
->andReturn([]);
$order->expects('get_shipping_tax')->andReturn(1);
$result = $testee->from_wc_order($order);
$item = current($result);
@ -293,6 +297,7 @@ class ItemFactoryTest extends TestCase
$order
->expects('get_fees')
->andReturn([]);
$order->expects('get_shipping_tax')->andReturn(1);
$result = $testee->from_wc_order($order);
$item = current($result);