@@ -32,4 +32,58 @@ public function test_query_vars_adds_rsscloud() {
3232 $ this ->assertContains ( 'existing_var ' , $ result );
3333 $ this ->assertContains ( 'rsscloud ' , $ result );
3434 }
35+
36+ public function test_add_rss_cloud_element_returns_early_when_not_feed () {
37+ ob_start ();
38+ rsscloud_add_rss_cloud_element ();
39+ $ output = ob_get_clean ();
40+
41+ $ this ->assertEmpty ( $ output );
42+ }
43+
44+ public function test_add_rss_cloud_element_outputs_cloud_tag_on_feed () {
45+ $ this ->go_to ( get_feed_link ( 'rss2 ' ) );
46+
47+ ob_start ();
48+ rsscloud_add_rss_cloud_element ();
49+ $ output = ob_get_clean ();
50+
51+ $ this ->assertStringContainsString ( '<cloud ' , $ output );
52+ $ this ->assertStringContainsString ( "protocol='http-post' " , $ output );
53+ $ this ->assertStringContainsString ( 'rsscloud=notify ' , $ output );
54+ }
55+
56+ public function test_add_rss_cloud_element_uses_correct_domain () {
57+ $ this ->go_to ( get_feed_link ( 'rss2 ' ) );
58+
59+ ob_start ();
60+ rsscloud_add_rss_cloud_element ();
61+ $ output = ob_get_clean ();
62+
63+ $ home = wp_parse_url ( get_option ( 'home ' ) );
64+ $ this ->assertStringContainsString ( "domain=' " . $ home ['host ' ] . "' " , $ output );
65+ }
66+
67+ public function test_add_rss_cloud_element_uses_port_from_home_url () {
68+ $ this ->go_to ( get_feed_link ( 'rss2 ' ) );
69+
70+ ob_start ();
71+ rsscloud_add_rss_cloud_element ();
72+ $ output = ob_get_clean ();
73+
74+ $ home = wp_parse_url ( get_option ( 'home ' ) );
75+ $ port = ! empty ( $ home ['port ' ] ) ? (int ) $ home ['port ' ] : 80 ;
76+ $ this ->assertStringContainsString ( "port=' " . $ port . "' " , $ output );
77+ }
78+
79+ public function test_parse_request_does_nothing_without_rsscloud_var () {
80+ $ wp = new stdClass ();
81+ $ wp ->query_vars = array ( 'p ' => '1 ' );
82+
83+ // Should return without calling exit or any notification processing.
84+ rsscloud_parse_request ( $ wp );
85+
86+ // If we reach this point, the function returned normally.
87+ $ this ->assertTrue ( true );
88+ }
3589}
0 commit comments