Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@
return;
}

// Polylang only loads its API (the pll_* functions and PLL()) when
// init() enters a context via init_context(). In PHPUnit there is no
// request context and no languages exist yet, so init() detects an
// empty context and returns before requiring src/api.php — leaving
// PLL() undefined and every PolylangTest skipped. Force a frontend
// context so the API loads; languages are (re)created per test by
// TestCase::setPolylangDefaultLanguage() after Refresh_Database rolls
// them back.
add_filter('pll_context', static fn (string $class): string => $class ?: 'PLL_Frontend');

$polylangBootstrap = new \Polylang();
$polylangBootstrap->init();
});
Expand Down
Loading