@@ -153,4 +153,65 @@ public function test_admin_hooks_registered() {
153153
154154 $ this ->assertNotFalse ( has_action ( 'admin_init ' ) );
155155 }
156+
157+ /**
158+ * Test that init() guard prevents multiple initializations.
159+ *
160+ * @covers ::init
161+ */
162+ public function test_init_guard_prevents_double_initialization () {
163+ $ instance = \Nodeinfo \Nodeinfo::get_instance ();
164+
165+ // Get the filter count before calling init again.
166+ $ filter_count_before = has_filter ( 'nodeinfo_discovery ' );
167+
168+ // Call init() again - should be guarded.
169+ $ instance ->init ();
170+
171+ // Filter count should remain the same.
172+ $ filter_count_after = has_filter ( 'nodeinfo_discovery ' );
173+
174+ $ this ->assertSame ( $ filter_count_before , $ filter_count_after );
175+ }
176+
177+ /**
178+ * Test activate() method registers rewrite rules.
179+ *
180+ * @covers ::activate
181+ */
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.
192+ \Nodeinfo \Nodeinfo::activate ();
193+
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 ();
202+ }
203+
204+ /**
205+ * Test deactivate() method flushes rewrite rules.
206+ *
207+ * @covers ::deactivate
208+ */
209+ public function test_deactivate_flushes_rewrite_rules () {
210+ // This test verifies deactivate() runs without errors.
211+ // The actual effect (flushing rules) is internal to WordPress.
212+ \Nodeinfo \Nodeinfo::deactivate ();
213+
214+ // If we get here without exceptions, the test passes.
215+ $ this ->assertTrue ( true );
216+ }
156217}
0 commit comments