@@ -815,4 +815,86 @@ function test_create_publish_default_status() {
815815 $ post = self ::check_create ( self ::create_json_request ( $ input ) );
816816 $ this ->assertEquals ( 'publish ' , $ post ->post_status );
817817 }
818+
819+ function test_create_plain_text_autolinks_urls () {
820+ $ input = array (
821+ 'type ' => array ( 'h-entry ' ),
822+ 'properties ' => array (
823+ 'content ' => array ( 'Check out https://example.com for more info ' ),
824+ ),
825+ );
826+ $ post = self ::check_create ( self ::create_json_request ( $ input ) );
827+ // URLs in plain text content should be auto-linked.
828+ $ this ->assertStringContainsString ( '<a href="https://example.com" ' , $ post ->post_content );
829+ $ this ->assertStringContainsString ( 'https://example.com</a> ' , $ post ->post_content );
830+ }
831+
832+ function test_create_plain_text_autolinks_multiple_urls () {
833+ $ input = array (
834+ 'type ' => array ( 'h-entry ' ),
835+ 'properties ' => array (
836+ 'content ' => array ( 'Visit https://example.com and http://test.org today ' ),
837+ ),
838+ );
839+ $ post = self ::check_create ( self ::create_json_request ( $ input ) );
840+ // Both URLs should be auto-linked.
841+ $ this ->assertStringContainsString ( '<a href="https://example.com" ' , $ post ->post_content );
842+ $ this ->assertStringContainsString ( '<a href="http://test.org" ' , $ post ->post_content );
843+ }
844+
845+ function test_create_html_content_not_autolinked () {
846+ $ input = array (
847+ 'type ' => array ( 'h-entry ' ),
848+ 'properties ' => array (
849+ 'content ' => array (
850+ array ( 'html ' => '<p>Visit https://example.com today</p> ' ),
851+ ),
852+ ),
853+ );
854+ $ post = self ::check_create ( self ::create_json_request ( $ input ) );
855+ // HTML content should not be auto-linked (preserved as-is).
856+ $ this ->assertEquals ( '<p>Visit https://example.com today</p> ' , $ post ->post_content );
857+ }
858+
859+ function test_create_html_content_existing_link_preserved () {
860+ $ input = array (
861+ 'type ' => array ( 'h-entry ' ),
862+ 'properties ' => array (
863+ 'content ' => array (
864+ array ( 'html ' => '<p>Visit <a href="https://example.com">my site</a> today</p> ' ),
865+ ),
866+ ),
867+ );
868+ $ post = self ::check_create ( self ::create_json_request ( $ input ) );
869+ // Existing links in HTML content should be preserved.
870+ $ this ->assertEquals ( '<p>Visit <a href="https://example.com">my site</a> today</p> ' , $ post ->post_content );
871+ }
872+
873+ function test_create_html_content_code_block_preserved () {
874+ $ input = array (
875+ 'type ' => array ( 'h-entry ' ),
876+ 'properties ' => array (
877+ 'content ' => array (
878+ array ( 'html ' => '<p>Example: <code>https://example.com/api</code></p> ' ),
879+ ),
880+ ),
881+ );
882+ $ post = self ::check_create ( self ::create_json_request ( $ input ) );
883+ // URLs in code blocks should not be auto-linked.
884+ $ this ->assertEquals ( '<p>Example: <code>https://example.com/api</code></p> ' , $ post ->post_content );
885+ }
886+
887+ function test_create_html_content_pre_block_preserved () {
888+ $ input = array (
889+ 'type ' => array ( 'h-entry ' ),
890+ 'properties ' => array (
891+ 'content ' => array (
892+ array ( 'html ' => '<pre>curl https://example.com/api</pre> ' ),
893+ ),
894+ ),
895+ );
896+ $ post = self ::check_create ( self ::create_json_request ( $ input ) );
897+ // URLs in pre blocks should not be auto-linked.
898+ $ this ->assertEquals ( '<pre>curl https://example.com/api</pre> ' , $ post ->post_content );
899+ }
818900}
0 commit comments