Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TaxAdjustmentTest.php
Go to the documentation of this file.
1 <?php
8 
9 class TaxAdjustmentTest extends \PHPUnit\Framework\TestCase
10 {
14  protected $model;
15 
21  protected $weeeHelperMock;
22 
26  protected $objectManager;
27 
31  protected function setUp()
32  {
33  $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
34 
35  $this->weeeHelperMock = $this->createPartialMock(
36  \Magento\Weee\Helper\Data::class,
37  ['typeOfDisplay', 'isTaxable']
38  );
39 
40  $this->model = $this->objectManager->getObject(
41  \Magento\Weee\Pricing\Render\TaxAdjustment::class,
42  [
43  'weeeHelper' => $this->weeeHelperMock,
44  ]
45  );
46  }
47 
53  public function testGetDefaultExclusions($weeeIsExcluded)
54  {
55  //setup
56  $this->weeeHelperMock->expects($this->atLeastOnce())->method('typeOfDisplay')->willReturn($weeeIsExcluded);
57 
58  //test
59  $defaultExclusions = $this->model->getDefaultExclusions();
60  $this->assertNotEmpty($defaultExclusions, 'Expected to have at least one default exclusion: tax');
61 
62  $taxCode = $this->model->getAdjustmentCode(); // since Weee's TaxAdjustment is a subclass of Tax's Adjustment
63  $this->assertContains($taxCode, $defaultExclusions);
64 
66  if ($weeeIsExcluded) {
67  $this->assertContains($weeeCode, $defaultExclusions);
68  } else {
69  $this->assertNotContains($weeeCode, $defaultExclusions);
70  }
71  }
72 
78  {
79  return [
80  'weee part of exclusions' => [true],
81  'weee not part of exclusions' => [false],
82  ];
83  }
84 }