Files
heretek-control-core/tests/Issue112ValidationFallbackTest.php
T
Mian Shahzad RazaandClaude Opus 4.8 5748f005b0 fix(#111,#112): container-experiment guard + atomic dynamic-prop save fallback
#111 (part 2): on installs with Elementor's Flexbox Container experiment OFF, the
'container' element type is unregistered, so add-container/build-page stored pages
that render empty (Elements_Manager skips the uninstantiable element). Add
EMCP_Tools_Atomic_Props::is_container_supported() (authoritative element-type check),
refuse add-container/build-page up front with an actionable container_unsupported
error, and surface supports_container + a warning + recommended_mode='unsupported'
from detect-elementor-version.

#112: Document::save() THROWS Elementor's atomic settings/styles validation on an
editor-authored {$$type:'dynamic'} paragraph whose tag the CLI/REST atomic
dynamic-tags registry can't resolve, and because save() validates the whole tree it
blocked EVERY edit to the document. Route a validation-rejection throw into the
existing raw meta-write fallback (the tree is already coerce_tree'd, so what remains
is data the editor itself persists) via EMCP_Tools_Data::is_atomic_validation_rejection();
genuine fatals still hard-fail.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-08-13 12:57:45 +05:00

52 lines
1.8 KiB
PHP

<?php
/**
* Public unit test for EMCP_Tools_Data::is_atomic_validation_rejection() — the
* issue #112 fix. When Document::save() THROWS Elementor's atomic settings/styles
* validation error (e.g. a valid editor-authored `{$$type:'dynamic'}` paragraph
* whose tag the CLI/REST atomic registry can't resolve), the save path routes the
* throw into the raw meta-write fallback instead of hard-failing the whole edit.
* A genuine fatal (any other message) still hard-fails. This pins that
* classification; the end-to-end fallback is verified on a live HTTP save context.
*
* @package EMCP_Tools
*/
require_once dirname( __DIR__ ) . '/includes/class-elementor-data.php';
class Issue112ValidationFallbackTest extends \PHPUnit\Framework\TestCase {
public function test_settings_validation_failure_is_a_rejection() {
$this->assertTrue(
EMCP_Tools_Data::is_atomic_validation_rejection( 'Settings validation failed. paragraph: invalid_value' )
);
}
public function test_styles_validation_failure_is_a_rejection() {
$this->assertTrue(
EMCP_Tools_Data::is_atomic_validation_rejection( 'Styles validation failed for style `g-1` (widget `abc`)' )
);
}
public function test_bare_invalid_value_is_a_rejection() {
$this->assertTrue(
EMCP_Tools_Data::is_atomic_validation_rejection( 'title: invalid_value' )
);
}
public function test_case_insensitive() {
$this->assertTrue(
EMCP_Tools_Data::is_atomic_validation_rejection( 'SETTINGS VALIDATION FAILED. paragraph: INVALID_VALUE' )
);
}
public function test_genuine_fatal_is_not_a_rejection() {
$this->assertFalse(
EMCP_Tools_Data::is_atomic_validation_rejection( 'Call to a member function get_settings() on null' )
);
}
public function test_empty_message_is_not_a_rejection() {
$this->assertFalse( EMCP_Tools_Data::is_atomic_validation_rejection( '' ) );
}
}