Skip to content

Commit 5ce205c

Browse files
committed
Merge branch 'main' into docs/166-roadmap-reset
2 parents 6a23dc2 + fda3bed commit 5ce205c

3 files changed

Lines changed: 104 additions & 11 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* The one template a classic theme must have. Its existence (and the absence
4+
* of templates/index.html + theme.json) is what makes wp_is_block_theme()
5+
* return false, which is the only thing the test suite needs from it.
6+
*
7+
* @package Saddle
8+
*/
9+
10+
get_header();
11+
the_post();
12+
the_content();
13+
get_footer();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
Theme Name: Saddle Classic Fixture
3+
Theme URI: https://plugpress.co/saddle/
4+
Author: PlugPress
5+
Description: A minimal classic (PHP-template) theme used only by Saddle's test suite. CI provisions a fresh WordPress core whose bundled themes are all block themes, so without this fixture the classic-theme branches of the playbook can never be exercised there — they passed locally only because the developer's host install happened to run a classic theme.
6+
Version: 1.0.0
7+
Requires at least: 6.9
8+
Tested up to: 7.0
9+
Requires PHP: 7.4
10+
License: GPL-2.0-or-later
11+
License URI: https://www.gnu.org/licenses/gpl-2.0.html
12+
Text Domain: saddle-classic-fixture
13+
*/

tests/skills-test.php

Lines changed: 78 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -332,17 +332,55 @@ private function builtin_names() {
332332
}
333333

334334
/**
335-
* The test site runs a CLASSIC theme, which is exactly the case the old
336-
* wp_is_block_theme() gate excluded — so a classic site with no builder,
337-
* the one with no site editor to fall back on, got no playbook at all.
335+
* Run assertions with a fixture theme active, then put the host theme back.
336+
*
337+
* The theme in force during a test is an environment fact, not a fixture:
338+
* the harness symlinks wp-content/themes from whichever WordPress it was
339+
* pointed at. On the developer's host that happens to be a classic theme;
340+
* CI provisions a fresh core whose bundled themes are ALL block themes. A
341+
* test that assumes either one passes on one machine and fails on the other
342+
* (#145), so anything that branches on wp_is_block_theme() switches to the
343+
* fixture it means, explicitly, the way site-editor-test.php already does.
344+
*
345+
* @param string $slug 'saddle-classic-fixture' or 'saddle-block-fixture'.
346+
* @param callable $fn Assertions.
347+
*/
348+
private function with_theme( $slug, callable $fn ) {
349+
$previous = get_stylesheet();
350+
351+
register_theme_directory( __DIR__ . '/fixtures/themes' );
352+
delete_site_transient( 'theme_roots' );
353+
wp_clean_themes_cache();
354+
355+
$this->assertTrue( wp_get_theme( $slug )->exists(), "Fixture theme {$slug} is missing from tests/fixtures/themes." );
356+
switch_theme( $slug );
357+
358+
try {
359+
$fn();
360+
} finally {
361+
if ( get_stylesheet() !== $previous ) {
362+
switch_theme( $previous );
363+
}
364+
}
365+
}
366+
367+
/**
368+
* A classic theme is exactly the case the old wp_is_block_theme() gate
369+
* excluded — so a classic site with no builder, the one with no site editor
370+
* to fall back on, got no playbook at all.
338371
*/
339372
public function test_the_playbooks_ship_on_a_classic_theme_with_no_builder() {
340-
$this->with_no_foreign_builder(
373+
$this->with_theme(
374+
'saddle-classic-fixture',
341375
function () {
342-
$names = $this->builtin_names();
376+
$this->with_no_foreign_builder(
377+
function () {
378+
$names = $this->builtin_names();
343379

344-
$this->assertContains( 'build-page', $names );
345-
$this->assertContains( 'fix-page', $names );
380+
$this->assertContains( 'build-page', $names );
381+
$this->assertContains( 'fix-page', $names );
382+
}
383+
);
346384
}
347385
);
348386
}
@@ -381,12 +419,41 @@ function () {
381419
* not send the agent after get-template — it would be refused.
382420
*/
383421
public function test_the_playbook_adapts_step_two_to_a_classic_theme() {
384-
$this->with_no_foreign_builder(
422+
$this->with_theme(
423+
'saddle-classic-fixture',
424+
function () {
425+
$this->assertFalse( wp_is_block_theme(), 'The classic fixture must not read as a block theme.' );
426+
427+
$this->with_no_foreign_builder(
428+
function () {
429+
$body = Saddle_Skills::find( 'build-page' )['body'];
430+
431+
$this->assertStringContainsString( 'classic theme', $body );
432+
$this->assertStringNotContainsString( 'saddle/get-template on the header', $body );
433+
}
434+
);
435+
}
436+
);
437+
}
438+
439+
/**
440+
* The other branch, pinned for the same reason: a block theme has header
441+
* and footer parts Saddle CAN read, so step 2 sends the agent to them.
442+
*/
443+
public function test_the_playbook_sends_step_two_to_the_template_parts_on_a_block_theme() {
444+
$this->with_theme(
445+
'saddle-block-fixture',
385446
function () {
386-
$body = Saddle_Skills::find( 'build-page' )['body'];
447+
$this->assertTrue( wp_is_block_theme(), 'The block fixture must read as a block theme.' );
448+
449+
$this->with_no_foreign_builder(
450+
function () {
451+
$body = Saddle_Skills::find( 'build-page' )['body'];
387452

388-
$this->assertStringContainsString( 'classic theme', $body );
389-
$this->assertStringNotContainsString( 'saddle/get-template on the header', $body );
453+
$this->assertStringContainsString( 'saddle/get-template on the header', $body );
454+
$this->assertStringNotContainsString( 'this is a classic theme', $body );
455+
}
456+
);
390457
}
391458
);
392459
}

0 commit comments

Comments
 (0)