public function testDetach() { $this->processor->detach('unexists_type', $this->observer); $this->processor->attach('some_type', $this->observer); $this->processor->notify('unexists_type'); $this->processor->detach('some_type', $this->observer); }
protected function setUp() { $this->contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass(); $this->filterBuilderMock = $this->getMockBuilder('Magento\\Framework\\Api\\FilterBuilder')->disableOriginalConstructor()->getMock(); $this->processorMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock(); $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($this->processorMock); $this->processorMock->expects($this->once())->method('register'); $this->model = new Form($this->contextMock, $this->filterBuilderMock); }
/** * @param int $isConfirmationRequired * @param string|null $confirmation * @param \Magento\Framework\Phrase $expected * @dataProvider dataProviderPrepareDataSource */ public function testPrepareDataSource($isConfirmationRequired, $confirmation, $expected) { $websiteId = 1; $dataSource = ['data' => ['items' => [['confirmation' => $confirmation, 'website_id' => [$websiteId]]]]]; $this->processor->expects($this->any())->method('register')->with($this->confirmation)->willReturnSelf(); $this->scopeConfig->expects($this->once())->method('getValue')->with(AccountManagement::XML_PATH_IS_CONFIRM, ScopeInterface::SCOPE_WEBSITES, $websiteId)->willReturn($isConfirmationRequired); $this->confirmation->setData('name', 'confirmation'); $result = $this->confirmation->prepareDataSource($dataSource); $this->assertEquals($result['data']['items'][0]['confirmation'], $expected); }
protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->processorMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->setMethods([])->getMock(); $this->contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->disableOriginalConstructor()->setMethods([])->getMock(); $this->uiComponentFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponentFactory')->disableOriginalConstructor()->setMethods([])->getMock(); $this->systemStoreMock = $this->getMockBuilder('Magento\\Store\\Model\\System\\Store')->disableOriginalConstructor()->setMethods([])->getMock(); $this->escaperMock = $this->getMockBuilder('Magento\\Framework\\Escaper')->disableOriginalConstructor()->setMethods([])->getMock(); $this->contextMock->expects($this->atLeastOnce())->method('getProcessor')->willReturn($this->processorMock); $this->processorMock->expects($this->atLeastOnce())->method('register'); $this->model = $objectManager->getObject('Magento\\Store\\Ui\\Component\\Listing\\Column\\Store', ['context' => $this->contextMock, 'uiComponent' => $this->uiComponentFactoryMock, 'systemStore' => $this->systemStoreMock, 'escaper' => $this->escaperMock, 'components' => [], 'data' => ['name' => $this->name]]); }