123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Weee\Test\Unit\Model;
- class WeeeConfigProviderTest extends \PHPUnit\Framework\TestCase
- {
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $weeeHelperMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $weeeConfigMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $storeManagerMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $storeMock;
- /**
- * @var \Magento\Weee\Model\WeeeConfigProvider
- */
- protected $model;
- protected function setUp()
- {
- $this->weeeHelperMock = $this->createMock(\Magento\Weee\Helper\Data::class);
- $this->weeeConfigMock = $this->createMock(\Magento\Weee\Model\Config::class);
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class);
- $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock));
- $this->model = new \Magento\Weee\Model\WeeeConfigProvider(
- $this->weeeHelperMock,
- $this->storeManagerMock,
- $this->weeeConfigMock
- );
- }
- /**
- * @dataProvider getConfigDataProvider
- * @param array $expectedResult
- * @param bool $weeeHelperEnabled
- * @param bool $displayWeeeDetails
- * @param bool $weeeConfigEnabled
- * @param bool $includeInSubtotal
- */
- public function testGetConfig(
- $expectedResult,
- $weeeHelperEnabled,
- $displayWeeeDetails,
- $weeeConfigEnabled,
- $includeInSubtotal
- ) {
- $storeId = 1;
- $this->storeMock->expects($this->any())->method('getId')->will($this->returnValue($storeId));
- $this->weeeHelperMock->expects($this->any())->method('isEnabled')->with($storeId)
- ->will($this->returnValue($weeeHelperEnabled));
- $this->weeeHelperMock->expects($this->any())->method('typeOfDisplay')
- ->will($this->returnValue($displayWeeeDetails));
- $this->weeeConfigMock->expects($this->any())->method('isEnabled')
- ->will($this->returnValue($weeeConfigEnabled));
- $this->weeeConfigMock->expects($this->any())->method('includeInSubtotal')
- ->will($this->returnValue($includeInSubtotal));
- $this->assertEquals($expectedResult, $this->model->getConfig());
- }
- /**
- * @return array
- */
- public function getConfigDataProvider()
- {
- return [
- [
- 'expectedResult' => [
- 'isDisplayPriceWithWeeeDetails' => false,
- 'isDisplayFinalPrice' => true,
- 'isWeeeEnabled' => false,
- 'isIncludedInSubtotal' => true,
- 'getIncludeWeeeFlag' => true,
- ],
- 'weeeHelperEnabled' => false,
- 'displayWeeeDetails' => true,
- 'weeeConfigEnabled' => true,
- 'includeInSubtotal' => true,
- ],
- [
- 'expectedResult' => [
- 'isDisplayPriceWithWeeeDetails' => true,
- 'isDisplayFinalPrice' => true,
- 'isWeeeEnabled' => true,
- 'isIncludedInSubtotal' => true,
- 'getIncludeWeeeFlag' => true,
- ],
- 'weeeHelperEnabled' => true,
- 'displayWeeeDetails' => true,
- 'weeeConfigEnabled' => true,
- 'includeInSubtotal' => true,
- ],
- [
- 'expectedResult' => [
- 'isDisplayPriceWithWeeeDetails' => false,
- 'isDisplayFinalPrice' => false,
- 'isWeeeEnabled' => true,
- 'isIncludedInSubtotal' => true,
- 'getIncludeWeeeFlag' => false,
- ],
- 'weeeHelperEnabled' => true,
- 'displayWeeeDetails' => false,
- 'weeeConfigEnabled' => true,
- 'includeInSubtotal' => true,
- ],
- [
- 'expectedResult' => [
- 'isDisplayPriceWithWeeeDetails' => false,
- 'isDisplayFinalPrice' => false,
- 'isWeeeEnabled' => false,
- 'isIncludedInSubtotal' => true,
- 'getIncludeWeeeFlag' => false,
- ],
- 'weeeHelperEnabled' => false,
- 'displayWeeeDetails' => false,
- 'weeeConfigEnabled' => true,
- 'includeInSubtotal' => true,
- ],
- [
- 'expectedResult' => [
- 'isDisplayPriceWithWeeeDetails' => false,
- 'isDisplayFinalPrice' => false,
- 'isWeeeEnabled' => false,
- 'isIncludedInSubtotal' => false,
- 'getIncludeWeeeFlag' => false,
- ],
- 'weeeHelperEnabled' => false,
- 'displayWeeeDetails' => false,
- 'weeeConfigEnabled' => false,
- 'includeInSubtotal' => true,
- ],
- [
- 'expectedResult' => [
- 'isDisplayPriceWithWeeeDetails' => false,
- 'isDisplayFinalPrice' => false,
- 'isWeeeEnabled' => false,
- 'isIncludedInSubtotal' => false,
- 'getIncludeWeeeFlag' => false,
- ],
- 'weeeHelperEnabled' => false,
- 'displayWeeeDetails' => false,
- 'weeeConfigEnabled' => true,
- 'includeInSubtotal' => false,
- ],
- [
- 'expectedResult' => [
- 'isDisplayPriceWithWeeeDetails' => false,
- 'isDisplayFinalPrice' => false,
- 'isWeeeEnabled' => false,
- 'isIncludedInSubtotal' => false,
- 'getIncludeWeeeFlag' => false,
- ],
- 'weeeHelperEnabled' => false,
- 'displayWeeeDetails' => false,
- 'weeeConfigEnabled' => false,
- 'includeInSubtotal' => false,
- ],
- ];
- }
- }
|