public function testInvalidScopeNoSuchEntityException() { $scope = 'websites'; $scopeId = 1; $this->scopeResolverPool->expects($this->once())->method('get')->with($scope)->willThrowException(new NoSuchEntityException(new Phrase('no such entity exception'))); $this->assertFalse($this->model->isValidScope($scope, $scopeId)); }
public function testGetScopeTitle() { $scope = 'websites'; $scopeId = 1; $scopeTypeName = 'Website'; $this->request->expects($this->exactly(2))->method('getParam')->willReturnMap([['scope', null, $scope], ['scope_id', null, $scopeId]]); $scopeObject = $this->getMockBuilder('Magento\\Framework\\App\\ScopeInterface')->getMockForAbstractClass(); $scopeObject->expects($this->once())->method('getScopeTypeName')->willReturn($scopeTypeName); $scopeResolver = $this->getMockBuilder('Magento\\Framework\\App\\ScopeResolverInterface')->getMockForAbstractClass(); $scopeResolver->expects($this->once())->method('getScope')->with($scopeId)->willReturn($scopeObject); $this->scopeResolverPool->expects($this->once())->method('get')->with($scope)->willReturn($scopeResolver); $this->assertEquals(__('%1', $scopeTypeName), $this->block->getScopeTitle()); }
public function testToOptionArray() { $scopeId = 1; $scopeName = 'Scope Name'; $scopeData = ['value' => $scopeId, 'label' => $scopeName]; $result = [$scopeData, $scopeData]; /** @var ScopeResolverInterface|\PHPUnit_Framework_MockObject_MockObject $scopeResolverMock */ $scopeResolverMock = $this->getMockBuilder('Magento\\Framework\\App\\ScopeResolverInterface')->getMockForAbstractClass(); /** @var ScopeInterface|\PHPUnit_Framework_MockObject_MockObject $scopeMock */ $scopeMock = $this->getMockBuilder('Magento\\Framework\\App\\ScopeInterface')->getMockForAbstractClass(); $this->scopeResolverPoolMock->expects($this->once())->method('get')->with($this->scope)->willReturn($scopeResolverMock); $scopeResolverMock->expects($this->once())->method('getScopes')->willReturn([$scopeMock, $scopeMock]); $scopeMock->expects($this->exactly(2))->method('getId')->willReturn($scopeId); $scopeMock->expects($this->exactly(2))->method('getName')->willReturn($scopeName); $this->assertEquals($result, $this->model->toOptionArray()); }
public function testScope() { $scope = 'websites'; $scopeId = 1; $scopeName = 'Website Name'; $this->request->expects($this->exactly(4))->method('getParam')->willReturnMap([['scope', null, $scope], ['scope_id', null, $scopeId]]); $this->scopeValidator->expects($this->once())->method('isValidScope')->with($scope, $scopeId)->willReturn(true); $pageTitle = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock(); $pageTitle->expects($this->once())->method('prepend')->with(__('%1', $scopeName))->willReturnSelf(); $pageConfig = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock(); $pageConfig->expects($this->once())->method('getTitle')->willReturn($pageTitle); $scopeObject = $this->getMockBuilder('Magento\\Framework\\App\\ScopeInterface')->getMockForAbstractClass(); $scopeObject->expects($this->once())->method('getName')->willReturn($scopeName); $scopeResolver = $this->getMockBuilder('Magento\\Framework\\App\\ScopeResolverInterface')->getMockForAbstractClass(); $scopeResolver->expects($this->once())->method('getScope')->with($scopeId)->willReturn($scopeObject); $this->scopeResolverPool->expects($this->once())->method('get')->with($scope)->willReturn($scopeResolver); $this->resultPage->expects($this->once())->method('setActiveMenu')->with('Magento_Theme::design_config')->willReturnSelf(); $this->resultPage->expects($this->once())->method('getConfig')->willReturn($pageConfig); $this->assertSame($this->resultPage, $this->controller->execute()); }