diff --git a/php-transformer/tests/contract/plugin-bootstrap.php b/php-transformer/tests/contract/plugin-bootstrap.php
index 19eddcb..8462061 100644
--- a/php-transformer/tests/contract/plugin-bootstrap.php
+++ b/php-transformer/tests/contract/plugin-bootstrap.php
@@ -6,28 +6,43 @@
assertSame('0.1.0', blocks_engine_php_transformer_version(), 'Plugin helper exposes version.');
assertSame(dirname(__DIR__, 2), blocks_engine_php_transformer_path(), 'Plugin helper exposes package path.');
-$htmlResult = blocks_engine_php_transformer_transform_html(
- 'Plugin bootstrap
Ready.
',
- array(
- 'source' => 'fixture:plugin-bootstrap',
- 'scope' => 'contract-test',
- )
+$htmlInput = 'Plugin bootstrap
Ready.
';
+$htmlOptions = array(
+ 'source' => 'fixture:plugin-bootstrap',
+ 'scope' => 'contract-test',
);
+$htmlResult = blocks_engine_php_transformer_transform_html($htmlInput, $htmlOptions);
+
+$canonicalHtmlResult = ( new Automattic\BlocksEngine\PhpTransformer\HtmlToBlocks\HtmlTransformer() )
+ ->transform($htmlInput, $htmlOptions)
+ ->toArray();
assertSame('success', $htmlResult['status'] ?? '', 'HTML helper returns a successful canonical result.');
assertSame('fixture:plugin-bootstrap', $htmlResult['provenance'][0]['source'] ?? '', 'HTML helper preserves provenance source.');
+assertSame(normalizeTransformerResult($canonicalHtmlResult), normalizeTransformerResult($htmlResult), 'HTML helper matches the canonical class result envelope.');
+
+$formatInput = '# Plugin bootstrap';
+$formatResult = blocks_engine_php_transformer_convert_format($formatInput, 'markdown', 'blocks');
+
+$canonicalFormatResult = ( new Automattic\BlocksEngine\PhpTransformer\FormatBridge\FormatBridge() )
+ ->convertResult($formatInput, 'markdown', 'blocks')
+ ->toArray();
-$formatResult = blocks_engine_php_transformer_convert_format('# Plugin bootstrap', 'markdown', 'blocks');
assertSame('success', $formatResult['status'] ?? '', 'Format helper returns a successful canonical result.');
+assertSame(normalizeTransformerResult($canonicalFormatResult), normalizeTransformerResult($formatResult), 'Format helper matches the canonical class result envelope.');
-$artifactResult = blocks_engine_php_transformer_compile_artifact(
- array(
- 'generated_html' => 'Plugin artifact
',
- )
+$artifactInput = array(
+ 'generated_html' => 'Plugin artifact
',
);
+$artifactResult = blocks_engine_php_transformer_compile_artifact($artifactInput);
+
+$canonicalArtifactResult = ( new Automattic\BlocksEngine\PhpTransformer\ArtifactCompiler\ArtifactCompiler() )
+ ->compile($artifactInput)
+ ->toArray();
assertSame('success', $artifactResult['status'] ?? '', 'Artifact helper returns a successful canonical result.');
assertSame('index.html', $artifactResult['source_reports']['artifact']['entry_path'] ?? '', 'Artifact helper exposes canonical source reports.');
+assertSame(normalizeTransformerResult($canonicalArtifactResult), normalizeTransformerResult($artifactResult), 'Artifact helper matches the canonical class result envelope.');
fwrite(STDOUT, "Plugin bootstrap contract passed.\n");
@@ -38,3 +53,17 @@ function assertSame(mixed $expected, mixed $actual, string $message): void
exit(1);
}
}
+
+/**
+ * Remove per-call timing before comparing otherwise identical result envelopes.
+ *
+ * @param array $result Transformer result envelope.
+ * @return array
+ */
+function normalizeTransformerResult(array $result): array
+{
+ unset($result['metrics']['transform_duration_ms']);
+ unset($result['source_reports']['conversion_report']['metrics']['transform_duration_ms']);
+
+ return $result;
+}