array( 'url' => 'https://staging.example.test/uploads/hero.jpg', ), 'count' => 3, 'flag' => true, ), $transformer->transformValue( array( 'hero' => array( 'url' => 'https://example.test/uploads/hero.jpg', ), 'count' => 3, 'flag' => true, ), $this->mappings() ) ); } public function test_it_transforms_json_strings(): void { $transformer = new MetadataUrlTransformer( new UrlTransformer() ); $result = $transformer->transformValue( '{"url":"https:\/\/example.test\/uploads\/hero.jpg"}', $this->mappings() ); self::assertSame( '{"url":"https:\/\/staging.example.test\/uploads\/hero.jpg"}', $result ); } public function test_it_preserves_serialized_data_validity(): void { $transformer = new MetadataUrlTransformer( new UrlTransformer() ); // phpcs:ignore -- Test fixture requires native serialized metadata. $serialized = serialize( array( 'url' => 'https://example.test/uploads/hero.jpg', ) ); $result = $transformer->transformValue( $serialized, $this->mappings() ); self::assertSame( array( 'url' => 'https://staging.example.test/uploads/hero.jpg', ), // phpcs:ignore -- Assertion verifies the transformed serialized metadata remains valid. unserialize( $result ) ); } public function test_it_transforms_plain_string_metadata(): void { $transformer = new MetadataUrlTransformer( new UrlTransformer() ); self::assertSame( 'https://staging.example.test/contact', $transformer->transformValue( 'https://example.test/contact', $this->mappings() ) ); } }