123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Weee\Test\Unit\Model\ResourceModel;
- class TaxTest extends \PHPUnit\Framework\TestCase
- {
- /**
- * @var \Magento\Weee\Model\ResourceModel\Tax
- */
- protected $model;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $resourceMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $storeManagerMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $connectionMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $selectMock;
- protected function setUp()
- {
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
- $this->connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
- $this->connectionMock->expects($this->once())
- ->method('select')
- ->willReturn($this->selectMock);
- $this->resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
- $this->resourceMock->expects($this->any())
- ->method('getConnection')
- ->willReturn($this->connectionMock);
- $this->resourceMock->expects($this->atLeastOnce())
- ->method('getTableName')
- ->willReturn('table_name');
- $contextMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class);
- $contextMock->expects($this->any())->method('getResources')->willReturn($this->resourceMock);
- $this->model = $this->objectManager->getObject(
- \Magento\Weee\Model\ResourceModel\Tax::class,
- [
- 'context' => $contextMock,
- ]
- );
- }
- public function testInWeeeLocation()
- {
- $this->selectMock->expects($this->at(1))
- ->method('where')
- ->with('website_id IN(?)', [1, 0])
- ->willReturn($this->selectMock);
- $this->selectMock->expects($this->at(2))
- ->method('where')
- ->with('country = ?', 'US')
- ->willReturn($this->selectMock);
- $this->selectMock->expects($this->at(3))
- ->method('where')
- ->with('state = ?', 0)
- ->willReturn($this->selectMock);
- $this->selectMock->expects($this->any())
- ->method('from')
- ->with('table_name', 'value')
- ->willReturn($this->selectMock);
- $this->model->isWeeeInLocation('US', 0, 1);
- }
- public function testFetchWeeeTaxCalculationsByEntity()
- {
- $this->selectMock->expects($this->any())
- ->method('where')
- ->willReturn($this->selectMock);
- $this->selectMock->expects($this->any())
- ->method('from')
- ->with(
- ['eavTable' => 'table_name'],
- [
- 'eavTable.attribute_code',
- 'eavTable.attribute_id',
- 'eavTable.frontend_label'
- ]
- )->willReturn($this->selectMock);
- $this->selectMock->expects($this->any())
- ->method('joinLeft')
- ->willReturn($this->selectMock);
- $this->selectMock->expects($this->any())
- ->method('joinInner')
- ->willReturn($this->selectMock);
- $this->model->fetchWeeeTaxCalculationsByEntity('US', 0, 1, 3, 4);
- }
- }
|