Skip to content

Commit fb85b94

Browse files
t-hamanoclaude
andcommitted
Tests: Trim and reorganize icon collection tests.
Drop the redundant coverage cases that only assert trivial singleton, getter, and wrapper behavior already exercised elsewhere, and relocate the `data_invalid_collection_slugs` data provider next to its consumer with a clarifying docblock. Keeps the focus on the meaningful contract: validation failures, duplicate registration, unknown-property rejection, and the cascading unregister behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5b3e5cc commit fb85b94

File tree

1 file changed

+13
-92
lines changed

1 file changed

+13
-92
lines changed

tests/phpunit/tests/icons/wpIconCollectionsRegistry.php

Lines changed: 13 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,6 @@ public function test_register_collection() {
5353
$this->assertSame( 'A collection.', $registered['description'] );
5454
}
5555

56-
public function data_invalid_collection_slugs() {
57-
return array(
58-
'non-string slug' => array( 1 ),
59-
'contains slash' => array( 'plugin/icons' ),
60-
'contains digits' => array( 'plugin1' ),
61-
'uppercase characters' => array( 'Plugin' ),
62-
'leading hyphen' => array( '-plugin' ),
63-
);
64-
}
65-
6656
/**
6757
* @ticket 64847
6858
*
@@ -80,15 +70,22 @@ public function test_register_rejects_invalid_slug( $slug ) {
8070
}
8171

8272
/**
83-
* @ticket 64847
73+
* Data provider for invalid collection slug candidates.
8474
*
85-
* @covers ::register
75+
* Collection slugs must be strings that start with a lowercase letter
76+
* and contain only lowercase letters and hyphens (no digits, no slashes,
77+
* no uppercase characters).
8678
*
87-
* @expectedIncorrectUsage WP_Icon_Collections_Registry::register
79+
* @return array[]
8880
*/
89-
public function test_register_rejects_missing_label() {
90-
$result = $this->collections->register( 'my-collection', array() );
91-
$this->assertFalse( $result );
81+
public function data_invalid_collection_slugs() {
82+
return array(
83+
'non-string slug' => array( 1 ),
84+
'contains slash' => array( 'plugin/icons' ),
85+
'contains digits' => array( 'plugin1' ),
86+
'uppercase characters' => array( 'Plugin' ),
87+
'leading hyphen' => array( '-plugin' ),
88+
);
9289
}
9390

9491
/**
@@ -178,80 +175,4 @@ public function test_unregister_collection_cascades_to_icons() {
178175
public function test_unregister_unknown_collection() {
179176
$this->assertFalse( $this->collections->unregister( 'ghost' ) );
180177
}
181-
182-
/**
183-
* @ticket 64847
184-
*
185-
* @covers ::get_all_registered
186-
*/
187-
public function test_get_all_registered_contains_core() {
188-
$slugs = wp_list_pluck( $this->collections->get_all_registered(), 'slug' );
189-
$this->assertContains( 'core', $slugs );
190-
}
191-
192-
/**
193-
* @ticket 64847
194-
*
195-
* @covers ::get_registered
196-
*/
197-
public function test_get_registered_returns_null_when_missing() {
198-
$this->assertNull( $this->collections->get_registered( 'ghost' ) );
199-
}
200-
201-
/**
202-
* @ticket 64847
203-
*
204-
* @covers ::is_registered
205-
*/
206-
public function test_is_registered_on_default_core() {
207-
$this->assertTrue( $this->collections->is_registered( 'core' ) );
208-
}
209-
210-
/**
211-
* @ticket 64847
212-
*
213-
* @covers ::get_instance
214-
*/
215-
public function test_get_instance_returns_singleton() {
216-
$this->assertSame( $this->collections, WP_Icon_Collections_Registry::get_instance() );
217-
}
218-
219-
/**
220-
* @ticket 64847
221-
*
222-
* @covers ::register
223-
*/
224-
public function test_wp_register_icon_collection_wrapper() {
225-
$this->assertTrue(
226-
wp_register_icon_collection( 'my-collection', array( 'label' => 'My' ) )
227-
);
228-
$this->assertTrue( $this->collections->is_registered( 'my-collection' ) );
229-
230-
$this->assertTrue( wp_unregister_icon_collection( 'my-collection' ) );
231-
$this->assertFalse( $this->collections->is_registered( 'my-collection' ) );
232-
}
233-
234-
/**
235-
* @ticket 64847
236-
*
237-
* @covers ::register
238-
*/
239-
public function test_wp_register_icon_wrapper() {
240-
wp_register_icon_collection( 'my-collection', array( 'label' => 'My' ) );
241-
242-
$this->assertTrue(
243-
wp_register_icon(
244-
'bell',
245-
'my-collection',
246-
array(
247-
'label' => 'Bell',
248-
'content' => '<svg></svg>',
249-
)
250-
)
251-
);
252-
$this->assertTrue( WP_Icons_Registry::get_instance()->is_registered( 'my-collection/bell' ) );
253-
254-
$this->assertTrue( wp_unregister_icon( 'bell', 'my-collection' ) );
255-
$this->assertFalse( WP_Icons_Registry::get_instance()->is_registered( 'my-collection/bell' ) );
256-
}
257178
}

0 commit comments

Comments
 (0)