What
Add two integration tests for wu_create_site that verify the subdomain slug sanitization introduced in GH#812 (PR #822) works end-to-end at the API level.
These tests were developed by a prior worker and stashed when the fix PR was filed — NOT included in PR #822 but represent meaningful additional coverage.
Why
PR #822 added unit tests for the sanitization helper (test_subdomain_slug_sanitization_*). These stashed tests verify sanitization is applied when calling wu_create_site() with a path containing special characters — a different layer of the same fix.
How
EDIT: tests/WP_Ultimo/Functions/Site_Functions_Extended_Test.php — append these two methods before the closing } of the class (after the last method, currently ending at line ~209):
/**
* Test wu_create_site sanitizes subdomain slug from path on subdomain installs.
*/
public function test_create_site_sanitizes_subdomain_slug(): void {
add_filter('subdomain_install', '__return_true');
$site = wu_create_site(
[
'title' => 'Sanitized Slug Test',
'path' => '/My Cool Site!/',
]
);
remove_all_filters('subdomain_install');
if (is_wp_error($site)) {
$this->assertNotEquals(
'invalid_site_path',
$site->get_error_code(),
'A valid-ish path should not produce invalid_site_path after sanitization.'
);
} else {
$this->assertStringContainsString('my-cool-site', $site->get_domain());
}
}
/**
* Test wu_create_site returns WP_Error for empty slug on subdomain installs.
*/
public function test_create_site_returns_error_for_empty_subdomain_slug(): void {
add_filter('subdomain_install', '__return_true');
$result = wu_create_site(
[
'title' => 'Empty Slug Test',
'path' => '/!!!/',
]
);
remove_all_filters('subdomain_install');
$this->assertWPError($result);
$this->assertEquals('invalid_site_path', $result->get_error_code());
}
Verification: vendor/bin/phpunit tests/WP_Ultimo/Functions/Site_Functions_Extended_Test.php --filter "test_create_site_sanitizes_subdomain_slug|test_create_site_returns_error_for_empty_subdomain_slug"
Both tests should pass. After applying, drop the stash: git -C /home/dave/Git/ultimate-multisite stash drop stash@{0}
Context
What
Add two integration tests for
wu_create_sitethat verify the subdomain slug sanitization introduced in GH#812 (PR #822) works end-to-end at the API level.These tests were developed by a prior worker and stashed when the fix PR was filed — NOT included in PR #822 but represent meaningful additional coverage.
Why
PR #822 added unit tests for the sanitization helper (
test_subdomain_slug_sanitization_*). These stashed tests verify sanitization is applied when callingwu_create_site()with a path containing special characters — a different layer of the same fix.How
EDIT:
tests/WP_Ultimo/Functions/Site_Functions_Extended_Test.php— append these two methods before the closing}of the class (after the last method, currently ending at line ~209):Verification:
vendor/bin/phpunit tests/WP_Ultimo/Functions/Site_Functions_Extended_Test.php --filter "test_create_site_sanitizes_subdomain_slug|test_create_site_returns_error_for_empty_subdomain_slug"Both tests should pass. After applying, drop the stash:
git -C /home/dave/Git/ultimate-multisite stash drop stash@{0}Context
git stash@{0}onfeature/auto-20260413-120244(now merged PR t806: test: harden Dashboard_Widgets_Test global cleanup with try/finally #821)tests/WP_Ultimo/Functions/Site_Functions_Extended_Test.php