configMock = $this->getMockBuilder(ScopeConfigInterface::class) ->disableOriginalConstructor() ->getMock(); $this->resultRedirectFactoryMock = $this->getMockBuilder(RedirectFactory::class) ->disableOriginalConstructor() ->getMock(); $this->redirectMock = $this->getMockBuilder(Redirect::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->signUpController = $this->objectManagerHelper->getObject( SignUp::class, [ 'config' => $this->configMock, 'resultRedirectFactory' => $this->resultRedirectFactoryMock ] ); } /** * @return void */ public function testExecute() { $urlBIEssentialsConfigPath = 'analytics/url/bi_essentials'; $this->configMock->expects($this->once()) ->method('getValue') ->with($urlBIEssentialsConfigPath) ->willReturn('value'); $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($this->redirectMock); $this->redirectMock->expects($this->once())->method('setUrl')->with('value')->willReturnSelf(); $this->assertEquals($this->redirectMock, $this->signUpController->execute()); } }