|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) |
| 4 | + */ |
| 5 | +namespace Magento\Weee\Model\Resource\Attribute\Backend\Weee; |
| 6 | + |
| 7 | +class TaxTest extends \PHPUnit_Framework_TestCase |
| 8 | +{ |
| 9 | + /** |
| 10 | + * @var \Magento\Weee\Model\Resource\Attribute\Backend\Weee\Tax |
| 11 | + */ |
| 12 | + protected $model; |
| 13 | + |
| 14 | + /** |
| 15 | + * @var \PHPUnit_Framework_MockObject_MockObject |
| 16 | + */ |
| 17 | + protected $resourceMock; |
| 18 | + |
| 19 | + /** |
| 20 | + * @var \PHPUnit_Framework_MockObject_MockObject |
| 21 | + */ |
| 22 | + protected $storeManagerMock; |
| 23 | + |
| 24 | + /** |
| 25 | + * @var \PHPUnit_Framework_MockObject_MockObject |
| 26 | + */ |
| 27 | + protected $adapterMock; |
| 28 | + |
| 29 | + protected function setUp() |
| 30 | + { |
| 31 | + $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); |
| 32 | + $this->adapterMock = $this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'); |
| 33 | + |
| 34 | + $this->resourceMock = $this->getMock('\Magento\Framework\App\Resource', [], [], '', false); |
| 35 | + $this->resourceMock->expects($this->once()) |
| 36 | + ->method('getConnection') |
| 37 | + ->with('core_write') |
| 38 | + ->willReturn($this->adapterMock); |
| 39 | + |
| 40 | + $this->resourceMock->expects($this->once()) |
| 41 | + ->method('getTableName') |
| 42 | + ->willReturn('table_name'); |
| 43 | + |
| 44 | + $this->model = new \Magento\Weee\Model\Resource\Attribute\Backend\Weee\Tax( |
| 45 | + $this->resourceMock, |
| 46 | + $this->storeManagerMock |
| 47 | + ); |
| 48 | + } |
| 49 | + |
| 50 | + public function testInsertProductData() |
| 51 | + { |
| 52 | + $productId = 100; |
| 53 | + $productMock = $this->getMock('\Magento\Catalog\Model\Product', ['getId'], [], '', false); |
| 54 | + $productMock->expects($this->once())->method('getId')->willReturn($productId); |
| 55 | + |
| 56 | + $this->adapterMock->expects($this->once()) |
| 57 | + ->method('insert') |
| 58 | + ->with('table_name', ['entity_id' => $productId]); |
| 59 | + |
| 60 | + $this->assertEquals($this->model, $this->model->insertProductData($productMock, [])); |
| 61 | + } |
| 62 | +} |
0 commit comments