Changeset 41388 for trunk/tests/phpunit/tests/functions.php
- Timestamp:
- 09/18/2017 11:03:06 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions.php
r40564 r41388 902 902 for ( $i = 0; $i < 20; $i += 1 ) { 903 903 $uuid = wp_generate_uuid4(); 904 $this->assert RegExp( '/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/', $uuid);904 $this->assertTrue( wp_is_uuid( $uuid, 4 ) ); 905 905 $uuids[] = $uuid; 906 906 } … … 908 908 $unique_uuids = array_unique( $uuids ); 909 909 $this->assertEquals( $uuids, $unique_uuids ); 910 } 911 912 /** 913 * Tests wp_is_uuid(). 914 * 915 * @covers ::wp_is_uuid 916 * @ticket 39778 917 */ 918 function test_wp_is_valid_uuid() { 919 $uuids_v4 = array( 920 '27fe2421-780c-44c5-b39b-fff753092b55', 921 'b7c7713a-4ee9-45a1-87ed-944a90390fc7', 922 'fbedbe35-7bf5-49cc-a5ac-0343bd94360a', 923 '4c58e67e-123b-4290-a41c-5eeb6970fa3e', 924 'f54f5b78-e414-4637-84a9-a6cdc94a1beb', 925 'd1c533ac-abcf-44b6-9b0e-6477d2c91b09', 926 '7fcd683f-e5fd-454a-a8b9-ed15068830da', 927 '7962c750-e58c-470a-af0d-ec1eae453ff2', 928 'a59878ce-9a67-4493-8ca0-a756b52804b3', 929 '6faa519d-1e13-4415-bd6f-905ae3689d1d', 930 ); 931 932 foreach ( $uuids_v4 as $uuid ) { 933 $this->assertTrue( wp_is_uuid( $uuid, 4 ) ); 934 } 935 936 $uuids = array( 937 '00000000-0000-0000-0000-000000000000', // Nil. 938 '9e3a0460-d72d-11e4-a631-c8e0eb141dab', // Version 1. 939 '2c1d43b8-e6d7-376e-af7f-d4bde997cc3f', // Version 3. 940 '39888f87-fb62-5988-a425-b2ea63f5b81e', // Version 5. 941 ); 942 943 foreach ( $uuids as $uuid ) { 944 $this->assertTrue( wp_is_uuid( $uuid ) ); 945 $this->assertFalse( wp_is_uuid( $uuid, 4 ) ); 946 } 947 948 $invalid_uuids = array( 949 'a19d5192-ea41-41e6-b006', 950 'this-is-not-valid', 951 1234, 952 true, 953 array(), 954 ); 955 956 foreach ( $invalid_uuids as $invalid_uuid ) { 957 $this->assertFalse( wp_is_uuid( $invalid_uuid, 4 ) ); 958 $this->assertFalse( wp_is_uuid( $invalid_uuid ) ); 959 } 910 960 } 911 961
Note: See TracChangeset
for help on using the changeset viewer.