@@ -46,6 +46,76 @@ public function test_shortcode_single_element() {
4646 $ this ->assertStringContainsString ( "iframe title= \"$ title \" src= \"https://archive.org/embed/ $ id \" width= \"600 \" height= \"300 \"" , $ shortcode_content );
4747 }
4848
49+ /**
50+ * Verify that autoplay and poster attributes render as a proper query string.
51+ */
52+ public function test_shortcode_autoplay_and_poster () {
53+ $ content = "[archiveorg id='Wonderfu1958' autoplay=1 poster='http://archive.org/img.png'] " ;
54+ $ shortcode_content = do_shortcode ( $ content );
55+ $ this ->assertStringContainsString ( 'src="https://archive.org/embed/Wonderfu1958?autoplay=1&poster=http://archive.org/img.png" ' , $ shortcode_content );
56+ }
57+
58+ /**
59+ * Verify that the playlist attribute renders as a proper query parameter.
60+ */
61+ public function test_shortcode_playlist_attribute () {
62+ $ content = "[archiveorg id='sentidodelobjeto' playlist=1] " ;
63+ $ shortcode_content = do_shortcode ( $ content );
64+ $ this ->assertStringContainsString ( 'src="https://archive.org/embed/sentidodelobjeto?playlist=1" ' , $ shortcode_content );
65+ }
66+
67+ /**
68+ * Verify that query parameters baked into the identifier with "&" are converted to a proper query string.
69+ */
70+ public function test_shortcode_query_string_in_id_with_ampersand () {
71+ $ shortcode_content = do_shortcode ( '[archiveorg sentidodelobjeto&playlist=1 width=640 height=300] ' );
72+ $ this ->assertStringContainsString ( 'src="https://archive.org/embed/sentidodelobjeto?playlist=1" ' , $ shortcode_content );
73+ }
74+
75+ /**
76+ * Verify that query parameters baked into the identifier with "?" pass through correctly.
77+ */
78+ public function test_shortcode_query_string_in_id_with_question_mark () {
79+ $ shortcode_content = do_shortcode ( '[archiveorg sentidodelobjeto?playlist=1 width=640 height=300] ' );
80+ $ this ->assertStringContainsString ( 'src="https://archive.org/embed/sentidodelobjeto?playlist=1" ' , $ shortcode_content );
81+ }
82+
83+ /**
84+ * Verify that an HTML-encoded "&" baked into the identifier is normalized before splitting,
85+ * matching what reaches do_shortcode in environments where the_content encodes ampersands first.
86+ */
87+ public function test_shortcode_query_string_in_id_with_html_encoded_ampersand () {
88+ $ shortcode_content = do_shortcode ( '[archiveorg sentidodelobjeto&playlist=1 width=640 height=300] ' );
89+ $ this ->assertStringContainsString ( 'src="https://archive.org/embed/sentidodelobjeto?playlist=1" ' , $ shortcode_content );
90+ }
91+
92+ /**
93+ * Verify that an identifier consisting of only a query string returns the missing-ID error
94+ * rather than producing an item-less embed URL.
95+ */
96+ public function test_shortcode_returns_error_when_id_is_only_a_query_string () {
97+ $ this ->assertEquals ( '<!-- error: missing archive.org ID --> ' , do_shortcode ( '[archiveorg ?playlist=1] ' ) );
98+ $ this ->assertEquals ( '<!-- error: missing archive.org ID --> ' , do_shortcode ( '[archiveorg &playlist=1] ' ) );
99+ }
100+
101+ /**
102+ * Verify that a query parameter supplied both via the identifier and as a shortcode attribute
103+ * appears only once in the rendered URL.
104+ */
105+ public function test_shortcode_dedupes_duplicate_query_params_from_id_and_atts () {
106+ $ shortcode_content = do_shortcode ( '[archiveorg myitem&playlist=1 playlist=1] ' );
107+ $ this ->assertStringContainsString ( 'src="https://archive.org/embed/myitem?playlist=1" ' , $ shortcode_content );
108+ $ this ->assertSame ( 1 , substr_count ( $ shortcode_content , 'playlist=1 ' ) );
109+ }
110+
111+ /**
112+ * Verify that a "#" fragment in the identifier stays after the query string rather than swallowing it.
113+ */
114+ public function test_shortcode_places_query_before_fragment_in_id () {
115+ $ shortcode_content = do_shortcode ( '[archiveorg myitem#frag&playlist=1] ' );
116+ $ this ->assertStringContainsString ( 'src="https://archive.org/embed/myitem?playlist=1#frag" ' , $ shortcode_content );
117+ }
118+
49119 /**
50120 * Verify that rendering the archiveorg-book shortcode returns an ArchiveOrg book.
51121 *
0 commit comments