GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — wordpress-plugin/tests/SettingTypeTest.php at develop · axeptio/wordpress-plugin Expand file tree/ Copy pathSettingTypeTest.phpMore file actions 66 lines (57 loc) · 1.85 KB / Copy pathSettingTypeTest.phpFile metadata and controls66 lines (57 loc) · 1.85 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 <?php use Axeptio\Plugin\Models\Setting_Type; /** * Read the cases shared with the JavaScript resolver. * * @param string $group Case group. * @return array<int, array> */ function xpwp_type_cases( string $group ): array { $fixture = json_decode( (string) file_get_contents( __DIR__ . '/fixtures/setting-types.json' ), true ); return $fixture[ $group ]; } it( 'splits a declared type into a primitive and its literals', function () { foreach ( xpwp_type_cases( 'parse' ) as $case ) { $resolved = Setting_Type::parse( $case['type'] ); expect( $resolved['primitive'] )->toBe( $case['primitive'], "primitive of {$case['type']}" ); expect( $resolved['literals'] )->toBe( $case['literals'], "literals of {$case['type']}" ); } } ); it( 'rejects empty values and values that do not match their type', function () { foreach ( xpwp_type_cases( 'validate' ) as $case ) { expect( Setting_Type::validate( $case['type'], $case['value'] ) ) ->toBe( $case['valid'], "{$case['type']} with '{$case['value']}'" ); } } ); it( 'unifies boolean notations without swallowing an empty value', function () { foreach ( xpwp_type_cases( 'normalize' ) as $case ) { expect( Setting_Type::normalize( $case['type'], $case['value'] ) ) ->toBe( $case['expected'], "{$case['type']} with '{$case['value']}'" ); } } ); it( 'casts union members to the type the SDK expects', function () { foreach ( xpwp_type_cases( 'cast' ) as $case ) { expect( Setting_Type::cast( $case['type'], $case['value'] ) ) ->toBe( $case['expected'], "{$case['type']} with '{$case['value']}'" ); } } ); it( 'falls back to text for a type it does not know', function () { expect( Setting_Type::parse( 'Token' )['primitive'] )->toBeNull(); expect( Setting_Type::cast( 'Token', 'abc' ) )->toBe( 'abc' ); expect( Setting_Type::validate( 'Token', 'abc' ) )->toBeTrue(); } ); |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |