@@ -81,28 +81,16 @@ public function test_integrations_register_versions() {
8181 * @covers ::add_rewrite_rules
8282 */
8383 public function test_rewrite_rules_added () {
84- global $ wp_rewrite ;
85-
86- // Save original permalink structure.
87- $ original_structure = $ wp_rewrite ->permalink_structure ;
88-
89- // Enable permalinks for testing.
90- $ wp_rewrite ->set_permalink_structure ( '/%postname%/ ' );
91-
92- // Add rewrite rules.
93- \Nodeinfo \Nodeinfo::get_instance ()->add_rewrite_rules ();
94- $ wp_rewrite ->flush_rules ();
84+ $ instance = \Nodeinfo \Nodeinfo::get_instance ();
9585
96- $ rules = $ wp_rewrite ->wp_rewrite_rules ();
86+ // Test the filter directly.
87+ $ rules = $ instance ->add_rewrite_rules ( array () );
9788
98- // Ensure rules is an array.
9989 $ this ->assertIsArray ( $ rules );
10090 $ this ->assertArrayHasKey ( '^.well-known/nodeinfo ' , $ rules );
10191 $ this ->assertArrayHasKey ( '^.well-known/x-nodeinfo2 ' , $ rules );
102-
103- // Restore original permalink structure.
104- $ wp_rewrite ->set_permalink_structure ( $ original_structure );
105- $ wp_rewrite ->flush_rules ();
92+ $ this ->assertEquals ( 'index.php?rest_route=/nodeinfo/discovery ' , $ rules ['^.well-known/nodeinfo ' ] );
93+ $ this ->assertEquals ( 'index.php?rest_route=/nodeinfo2/1.0 ' , $ rules ['^.well-known/x-nodeinfo2 ' ] );
10694 }
10795
10896 /**
@@ -175,30 +163,16 @@ public function test_init_guard_prevents_double_initialization() {
175163 }
176164
177165 /**
178- * Test activate() method registers rewrite rules.
166+ * Test activate() method initializes plugin and flushes rewrite rules.
179167 *
180168 * @covers ::activate
181169 */
182- public function test_activate_registers_rewrite_rules () {
183- global $ wp_rewrite ;
184-
185- // Save original permalink structure.
186- $ original_structure = $ wp_rewrite ->permalink_structure ;
187-
188- // Enable permalinks for testing.
189- $ wp_rewrite ->set_permalink_structure ( '/%postname%/ ' );
190-
191- // Call activate.
170+ public function test_activate_initializes_and_flushes () {
171+ // Verify activate() runs without errors and initializes the plugin.
192172 \Nodeinfo \Nodeinfo::activate ();
193173
194- $ rules = $ wp_rewrite ->wp_rewrite_rules ();
195-
196- $ this ->assertIsArray ( $ rules );
197- $ this ->assertArrayHasKey ( '^.well-known/nodeinfo ' , $ rules );
198-
199- // Restore original permalink structure.
200- $ wp_rewrite ->set_permalink_structure ( $ original_structure );
201- $ wp_rewrite ->flush_rules ();
174+ // Verify the rewrite_rules_array filter is registered.
175+ $ this ->assertNotFalse ( has_filter ( 'rewrite_rules_array ' ) );
202176 }
203177
204178 /**
0 commit comments