createMock(WizardController::class); $this->GivenSetupMode($oWizard); $oWiz = new \WizStepWelcome($oWizard, ""); $this->assertEquals(false, $oWiz->DisplaySetupShortcutButton()); } public function testDisplaySetupShortcutButton_NoButtonWhenNoItopVersionFetched() { $oWizard = $this->createMock(WizardController::class); $this->GivenSetupMode($oWizard, 'upgrade'); $aApplicationVersion = [ 'product_name' => ITOP_APPLICATION, ]; $this->GivenGetApplicationVersion($aApplicationVersion); $oWiz = new \WizStepWelcome($oWizard, ""); $this->assertEquals(false, $oWiz->DisplaySetupShortcutButton()); } public function testDisplaySetupShortcutButton_NoButtonWhenNoApplicationVersionFetched() { $oWizard = $this->createMock(WizardController::class); $this->GivenSetupMode($oWizard, 'upgrade'); $aApplicationVersion = [ 'product_version' => ITOP_VERSION_FULL, ]; $this->GivenGetApplicationVersion($aApplicationVersion); $oWiz = new \WizStepWelcome($oWizard, ""); $this->assertEquals(false, $oWiz->DisplaySetupShortcutButton()); } public function testDisplaySetupShortcutButton_NoButtonWhenApplicationChangeDuringUpgrade() { $oWizard = $this->createMock(WizardController::class); $this->GivenSetupMode($oWizard, 'upgrade'); $aApplicationVersion = [ 'product_version' => ITOP_VERSION_FULL, 'product_name' => 'toto', ]; $this->GivenGetApplicationVersion($aApplicationVersion); $oWiz = new \WizStepWelcome($oWizard, ""); $this->assertEquals(false, $oWiz->DisplaySetupShortcutButton()); } public function testDisplaySetupShortcutButton_NoButtonWhenVersionChangeDuringUpgrade() { $oWizard = $this->createMock(WizardController::class); $this->GivenSetupMode($oWizard, 'upgrade'); $aApplicationVersion = [ 'product_version' => '6.6.6', 'product_name' => ITOP_APPLICATION, ]; $this->GivenGetApplicationVersion($aApplicationVersion); $oWiz = new \WizStepWelcome($oWizard, ""); $this->assertEquals(false, $oWiz->DisplaySetupShortcutButton()); } public function testDisplaySetupShortcutButton_NoButtonWhenMySQLException() { $oWizard = $this->createMock(WizardController::class); $this->GivenSetupMode($oWizard, 'upgrade'); $this->GivenGetApplicationVersion(false); $oWiz = new \WizStepWelcome($oWizard, ""); $this->assertEquals(false, $oWiz->DisplaySetupShortcutButton()); } public function testDisplaySetupShortcutButton_ButtonDisplayed() { $oWizard = $this->createMock(WizardController::class); $this->GivenSetupMode($oWizard, 'upgrade'); $aApplicationVersion = [ 'product_version' => ITOP_VERSION_FULL, 'product_name' => ITOP_APPLICATION, ]; $this->GivenGetApplicationVersion($aApplicationVersion); $oWiz = new \WizStepWelcome($oWizard, ""); $this->assertEquals(true, $oWiz->DisplaySetupShortcutButton()); } private function GivenSetupMode(WizardController $oWizardMock, $sMode = 'install'): void { $oWizardMock->expects($this->once()) ->method('GetParameter') ->with('mode') ->willReturn($sMode); } private function GivenGetApplicationVersion($sExpectedReturnedValue): void { $oModuleInstallationRepository = $this->createMock(ModuleInstallationRepository::class); ModuleInstallationRepository::SetInstance($oModuleInstallationRepository); $oModuleInstallationRepository->expects($this->once()) ->method('GetApplicationVersion') ->willReturn($sExpectedReturnedValue); } }