Make WordPress Core


Ignore:
Timestamp:
03/23/2026 07:39:45 PM (4 months ago)
Author:
jorbin
Message:

Abilities API: Revert Allow nested namespace ability names.

Abilities should follow the same pattern as all other namespaces and use a single namespace.

Reverts [61602].

See #64596.
Props jorgefilipecosta, justlevine, audrasjb.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/abilities-api/wpAbilitiesRegistry.php

    r61602 r62094  
    138138
    139139        /**
    140          * Should accept ability name with 3 segments (2 slashes).
    141          *
    142          * @ticket 64098
    143          *
    144          * @covers WP_Abilities_Registry::register
    145          */
    146         public function test_register_valid_name_with_three_segments() {
    147                 $result = $this->registry->register( 'test/sub/add-numbers', self::$test_ability_args );
    148                 $this->assertInstanceOf( WP_Ability::class, $result );
    149                 $this->assertSame( 'test/sub/add-numbers', $result->get_name() );
    150         }
    151 
    152         /**
    153          * Should accept ability name with 4 segments (3 slashes).
    154          *
    155          * @ticket 64098
    156          *
    157          * @covers WP_Abilities_Registry::register
    158          */
    159         public function test_register_valid_name_with_four_segments() {
    160                 $result = $this->registry->register( 'test/sub/deep/add-numbers', self::$test_ability_args );
    161                 $this->assertInstanceOf( WP_Ability::class, $result );
    162                 $this->assertSame( 'test/sub/deep/add-numbers', $result->get_name() );
    163         }
    164 
    165         /**
    166          * Should reject ability name with 5 segments (exceeds maximum of 4).
    167          *
    168          * @ticket 64098
    169          *
    170          * @covers WP_Abilities_Registry::register
    171          *
    172          * @expectedIncorrectUsage WP_Abilities_Registry::register
    173          */
    174         public function test_register_invalid_name_with_five_segments() {
    175                 $result = $this->registry->register( 'test/a/b/c/too-deep', self::$test_ability_args );
    176                 $this->assertNull( $result );
    177         }
    178 
    179         /**
    180          * Should reject ability name with empty segments (double slashes).
    181          *
    182          * @ticket 64098
    183          *
    184          * @covers WP_Abilities_Registry::register
    185          *
    186          * @expectedIncorrectUsage WP_Abilities_Registry::register
    187          */
    188         public function test_register_invalid_name_with_empty_segment() {
    189                 $result = $this->registry->register( 'test//add-numbers', self::$test_ability_args );
    190                 $this->assertNull( $result );
    191         }
    192 
    193         /**
    194          * Should reject ability name with trailing slash.
    195          *
    196          * @ticket 64098
    197          *
    198          * @covers WP_Abilities_Registry::register
    199          *
    200          * @expectedIncorrectUsage WP_Abilities_Registry::register
    201          */
    202         public function test_register_invalid_name_with_trailing_slash() {
    203                 $result = $this->registry->register( 'test/add-numbers/', self::$test_ability_args );
    204                 $this->assertNull( $result );
    205         }
    206 
    207         /**
    208140         * Should reject ability registration without a label.
    209141         *
Note: See TracChangeset for help on using the changeset viewer.