/**
  * Data provider for mergeing item prices
  */
 public function mergeProvider()
 {
     $collection1 = new ItemPriceCollection();
     $collection2 = new ItemPriceCollection();
     $collection3 = new ItemPriceCollection();
     $collection4 = new ItemPriceCollection();
     $item1 = new ItemPrice(10, 1);
     $item1->setKey('id');
     $item2 = new ItemPrice(20, 2);
     $item2->setKey('test');
     $item3 = new ItemPrice(15, 1);
     $item3->setKey('id');
     $collection1->append($item1)->append($item2);
     $collection2->append($item2)->append($item3);
     $collection3->append($item3);
     $collection4->append($item2);
     return [[$collection1, $collection2, 2], [$collection1, $collection3, 1], [$collection2, $collection3, 1], [$collection3, $collection1, 1], [$collection3, $collection4, 0]];
 }
Exemple #2
0
 /**
  * @covers ::taxes
  * @uses Blesta\Pricing\Type\ItemPrice::setTax
  * @uses Blesta\Pricing\Type\ItemPrice::__construct
  * @uses Blesta\Pricing\Type\ItemPrice::resetDiscountSubtotal
  * @uses Blesta\Pricing\Type\ItemPrice::subtotal
  * @uses Blesta\Pricing\Type\UnitPrice::__construct
  * @uses Blesta\Pricing\Type\UnitPrice::setPrice
  * @uses Blesta\Pricing\Type\UnitPrice::setQty
  * @uses Blesta\Pricing\Type\UnitPrice::setKey
  * @uses Blesta\Pricing\Type\UnitPrice::total
  * @uses Blesta\Pricing\Modifier\TaxPrice::__construct
  * @uses Blesta\Pricing\Modifier\AbstractPriceModifier::__construct
  * @dataProvider taxesProvider
  */
 public function testTaxes($unique, $taxes, $expected_count, $expected_total)
 {
     $item = new ItemPrice(10);
     foreach ($taxes as $tax_group) {
         call_user_func_array([$item, 'setTax'], $tax_group);
     }
     // Determine the total tax count based on $unique
     $this->assertCount($expected_count, $item->taxes($unique));
     // Determine the total count of all taxes
     $total = 0;
     foreach ($item->taxes() as $group) {
         $total++;
     }
     $this->assertEquals($expected_total, $total);
 }