This is an old revision of the document!
Table of Contents
LanguageSwitcherFixture
Layer: Tests · Source: tests/fixtures/language_switcher_fixture.php:18 (lines 18–266)
class LanguageSwitcherFixture
Inheritance
No parent, interface or trait. This is a root type.
Constants (0)
None.
Properties (1)
| Visibility | Type | Name | Default | Line |
|---|---|---|---|---|
private static | static | $dbc | null; | 20 |
Methods (12)
| Visibility | Method | Summary | Line |
|---|---|---|---|
| public static | initDb() | Initialize database connection | 25 |
| public static | getDb() | (undocumented) | 46 |
| public static | isDbAvailable() | (undocumented) | 52 |
| public static | getLanguages() | Get languages from database | 61 |
| public static | getPostsByLocale() | Get posts filtered by locale from the real database | 73 |
| public static | getTopicsByLocale() | Get topics filtered by locale from the real database | 88 |
| public static | getMenuItemsByLocale() | Get menu items filtered by locale from the real database | 103 |
| public static | getAllPublishedPosts() | Get all published posts (no locale filter) | 118 |
| public static | getLanguageDirectionFromDb() | Lookup language direction from real database (same logic as I18nManager::getLan… | 130 |
| public static | processSwitchLang() | Process switch-lang — replicates lib/main.php lines 103-129 EXACTLY. | 155 |
| public static | detectLocale() | Detect locale from session/cookie/default | 215 |
| public static | bootstrapI18nManager() | Initialize I18nManager for testing real is_rtl() function. | 241 |
initDb()
public static function initDb(): void
lines 25–44 (20)
Initialize database connection
Takes no parameters.
Returns: void
getDb()
public static function getDb(): ?PDO
lines 46–50 (5)
Takes no parameters.
Returns: ?PDO
isDbAvailable()
public static function isDbAvailable(): bool
lines 52–56 (5)
Takes no parameters.
Returns: bool
getLanguages()
public static function getLanguages(): array
lines 61–68 (8)
Get languages from database
Takes no parameters.
Returns: array
getPostsByLocale()
public static function getPostsByLocale(string $locale): array
lines 73–83 (11)
Get posts filtered by locale from the real database
| Parameter | Type | Default | Description |
|---|---|---|---|
$locale | string | required | none |
Returns: array
getTopicsByLocale()
public static function getTopicsByLocale(string $locale): array
lines 88–98 (11)
Get topics filtered by locale from the real database
| Parameter | Type | Default | Description |
|---|---|---|---|
$locale | string | required | none |
Returns: array
getMenuItemsByLocale()
public static function getMenuItemsByLocale(string $locale): array
lines 103–113 (11)
Get menu items filtered by locale from the real database
| Parameter | Type | Default | Description |
|---|---|---|---|
$locale | string | required | none |
Returns: array
getAllPublishedPosts()
public static function getAllPublishedPosts(): array
lines 118–125 (8)
Get all published posts (no locale filter)
Takes no parameters.
Returns: array
getLanguageDirectionFromDb()
public static function getLanguageDirectionFromDb(string $locale): string
lines 130–145 (16)
Lookup language direction from real database (same logic as I18nManager::getLanguageDirection)
| Parameter | Type | Default | Description |
|---|---|---|---|
$locale | string | required | none |
Returns: string
processSwitchLang()
public static function processSwitchLang(array &$session, array $get): array
lines 155–209 (55)
Process switch-lang — replicates lib/main.php lines 103-129 EXACTLY.
Differences from real code (required for CLI testability): \- Returns redirect URL string instead of calling header()+exit() \- Returns null for invalid locales instead of silently ignoring \- Returns result struct instead of exit()
| Parameter | Type | Default | Description |
|---|---|---|---|
$session (by reference) | array | required | none |
$get | array | required | none |
Returns: array
detectLocale()
public static function detectLocale(array $session, array $cookie): string
lines 215–235 (21)
Detect locale from session/cookie/default
Same logic as the real LocaleDetector + config default
| Parameter | Type | Default | Description |
|---|---|---|---|
$session | array | required | none |
$cookie | array | required | none |
Returns: string
bootstrapI18nManager()
public static function bootstrapI18nManager(): bool
lines 241–265 (25)
Initialize I18nManager for testing real is_rtl() function.
Uses test database for LanguageDao lookups.
Takes no parameters.
Returns: bool
Conditional Includes
| Mode | Target | Line |
|---|---|---|
require | require_once DIR . '/../../public/themes/blog/functions.php'; | 15 |
This page is generated from source by 'tools/gendoc'. Edits will be overwritten.
