19 $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
24 unset($this->objectManagerHelper);
27 public function testPrepareLayout()
29 $options = [[
'value' =>
'value',
'label' =>
'label']];
32 $sourceServiceFactoryMock = $this->createPartialMock(
33 \
Magento\Directory\Model\Currency\Import\Source\ServiceFactory::class,
36 $sourceServiceMock = $this->createMock(\
Magento\Directory\Model\Currency\Import\Source\Service::class);
37 $backendSessionMock = $this->createPartialMock(
38 \
Magento\Backend\Model\Session::class,
39 [
'getCurrencyRateService']
43 $layoutMock = $this->getMockForAbstractClass(
44 \
Magento\Framework\View\LayoutInterface::class,
53 $blockMock = $this->createPartialMock(
54 \
Magento\Framework\View\Element\Html\Select::class,
55 [
'setOptions',
'setId',
'setName',
'setValue',
'setTitle']
58 $layoutMock->expects($this->once())->method(
'createBlock')->willReturn($blockMock);
60 $sourceServiceFactoryMock->expects($this->once())->method(
'create')->willReturn($sourceServiceMock);
61 $sourceServiceMock->expects($this->once())->method(
'toOptionArray')->willReturn(
$options);
62 $backendSessionMock->expects($this->once())->method(
'getCurrencyRateService')->with(
true)->willReturn(
$service);
64 $blockMock->expects($this->once())->method(
'setOptions')->with(
$options)->willReturnSelf();
65 $blockMock->expects($this->once())->method(
'setId')->with(
'rate_services')->willReturnSelf();
66 $blockMock->expects($this->once())->method(
'setName')->with(
'rate_services')->willReturnSelf();
67 $blockMock->expects($this->once())->method(
'setValue')->with(
$service)->willReturnSelf();
68 $blockMock->expects($this->once())->method(
'setTitle')->with(
'Import Service')->willReturnSelf();
71 $block = $this->objectManagerHelper->getObject(
72 \
Magento\CurrencySymbol\Block\Adminhtml\System\Currency\Rate\Services::class,
74 'srcCurrencyFactory' => $sourceServiceFactoryMock,
75 'backendSession' => $backendSessionMock
78 $block->setLayout($layoutMock);