getMockBuilder(DatabaseInterface::class) ->disableOriginalConstructor() ->getMock(); $GLOBALS['dbi'] = $dbi; $_GET['route'] = '/preferences/forms'; $_GET['form'] = 'Features'; $template = new Template(); $content = UserPreferencesHeader::getContent($template, new Relation($dbi, $template)); $this->assertStringContainsString( '
  • ', $content ); $this->assertStringContainsString( '', $content ); $this->assertStringContainsString( 'Features Features', $content ); } /** * Test for getContent with "saved" get parameter * * @throws Throwable * @throws Twig_Error_Loader * @throws Twig_Error_Runtime * @throws Twig_Error_Syntax */ public function testGetContentAfterSave(): void { $dbi = $this->getMockBuilder(DatabaseInterface::class) ->disableOriginalConstructor() ->getMock(); $GLOBALS['dbi'] = $dbi; $_GET['saved'] = true; $template = new Template(); $this->assertStringContainsString( 'Configuration has been saved.', UserPreferencesHeader::getContent($template, new Relation($dbi, $template)) ); } /** * Test for getContent with session storage * * @throws Throwable * @throws Twig_Error_Loader * @throws Twig_Error_Runtime * @throws Twig_Error_Syntax */ public function testGetContentWithSessionStorage(): void { $dbi = $this->getMockBuilder(DatabaseInterface::class) ->disableOriginalConstructor() ->getMock(); $GLOBALS['dbi'] = $dbi; $template = new Template(); $this->assertStringContainsString( 'Your preferences will be saved for current session only. Storing them permanently requires', UserPreferencesHeader::getContent($template, new Relation($dbi, $template)) ); } }