|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © 2015 Magento. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +namespace Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate; |
| 7 | + |
| 8 | +class GridTest extends \PHPUnit_Framework_TestCase |
| 9 | +{ |
| 10 | + /** |
| 11 | + * @var \Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate\Grid |
| 12 | + */ |
| 13 | + protected $model; |
| 14 | + |
| 15 | + /** |
| 16 | + * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject |
| 17 | + */ |
| 18 | + protected $storeManagerMock; |
| 19 | + |
| 20 | + protected function setUp() |
| 21 | + { |
| 22 | + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); |
| 23 | + |
| 24 | + $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') |
| 25 | + ->disableOriginalConstructor() |
| 26 | + ->getMock(); |
| 27 | + |
| 28 | + $context = $objectManager->getObject('Magento\Backend\Block\Template\Context', [ |
| 29 | + 'storeManager' => $this->storeManagerMock |
| 30 | + ]); |
| 31 | + |
| 32 | + $this->model = $objectManager->getObject('Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate\Grid', [ |
| 33 | + 'context' => $context, |
| 34 | + ]); |
| 35 | + } |
| 36 | + |
| 37 | + public function testSetWebsiteId() |
| 38 | + { |
| 39 | + $websiteMock = $this->getMockBuilder('Magento\Store\Model\Website') |
| 40 | + ->disableOriginalConstructor() |
| 41 | + ->getMock(); |
| 42 | + |
| 43 | + $this->storeManagerMock->expects($this->once()) |
| 44 | + ->method('getWebsite') |
| 45 | + ->willReturn($websiteMock); |
| 46 | + |
| 47 | + $this->model->setWebsiteId(1); |
| 48 | + } |
| 49 | + |
| 50 | + public function testGetWebsiteId() |
| 51 | + { |
| 52 | + $websiteId = 10; |
| 53 | + |
| 54 | + $websiteMock = $this->getMockBuilder('Magento\Store\Model\Website') |
| 55 | + ->disableOriginalConstructor() |
| 56 | + ->setMethods(['getId']) |
| 57 | + ->getMock(); |
| 58 | + |
| 59 | + $websiteMock->expects($this->once()) |
| 60 | + ->method('getId') |
| 61 | + ->willReturn($websiteId); |
| 62 | + |
| 63 | + $this->storeManagerMock->expects($this->once()) |
| 64 | + ->method('getWebsite') |
| 65 | + ->willReturn($websiteMock); |
| 66 | + |
| 67 | + $this->assertEquals($websiteId, $this->model->getWebsiteId()); |
| 68 | + } |
| 69 | + |
| 70 | + public function testSetConditionName() |
| 71 | + { |
| 72 | + $this->assertEquals($this->model, $this->model->setConditionName('someName')); |
| 73 | + } |
| 74 | + |
| 75 | + public function testGetConditionName() |
| 76 | + { |
| 77 | + $conditionName = 'someName'; |
| 78 | + $this->assertEquals($conditionName, $this->model->setConditionName($conditionName)->getConditionName()); |
| 79 | + } |
| 80 | +} |
0 commit comments