@@ -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