Changeset 53557 for trunk/tests/phpunit/tests/term/slashes.php
- Timestamp:
- 06/23/2022 02:24:08 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/slashes.php
r52010 r53557 7 7 */ 8 8 class Tests_Term_Slashes extends WP_Ajax_UnitTestCase { 9 10 /* 11 * It is important to test with both even and odd numbered slashes, 12 * as KSES does a strip-then-add slashes in some of its function calls. 13 */ 14 15 const SLASH_1 = 'String with 1 slash \\'; 16 const SLASH_2 = 'String with 2 slashes \\\\'; 17 const SLASH_3 = 'String with 3 slashes \\\\\\'; 18 const SLASH_4 = 'String with 4 slashes \\\\\\\\'; 19 const SLASH_5 = 'String with 5 slashes \\\\\\\\\\'; 20 const SLASH_6 = 'String with 6 slashes \\\\\\\\\\\\'; 21 const SLASH_7 = 'String with 7 slashes \\\\\\\\\\\\\\'; 22 9 23 protected static $author_id; 10 24 … … 17 31 18 32 wp_set_current_user( self::$author_id ); 19 20 $this->slash_1 = 'String with 1 slash \\';21 $this->slash_2 = 'String with 2 slashes \\\\';22 $this->slash_3 = 'String with 3 slashes \\\\\\';23 $this->slash_4 = 'String with 4 slashes \\\\\\\\';24 $this->slash_5 = 'String with 5 slashes \\\\\\\\\\';25 $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\';26 $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\';27 33 } 28 34 … … 37 43 foreach ( $taxonomies as $taxonomy ) { 38 44 $insert = wp_insert_term( 39 $this->slash_1,45 self::SLASH_1, 40 46 $taxonomy, 41 47 array( 42 48 'slug' => 'slash_test_1_' . $taxonomy, 43 'description' => $this->slash_3,49 'description' => self::SLASH_3, 44 50 ) 45 51 ); 46 52 $term = get_term( $insert['term_id'], $taxonomy ); 47 $this->assertSame( wp_unslash( $this->slash_1 ), $term->name );48 $this->assertSame( wp_unslash( $this->slash_3 ), $term->description );53 $this->assertSame( wp_unslash( self::SLASH_1 ), $term->name ); 54 $this->assertSame( wp_unslash( self::SLASH_3 ), $term->description ); 49 55 50 56 $insert = wp_insert_term( 51 $this->slash_3,57 self::SLASH_3, 52 58 $taxonomy, 53 59 array( 54 60 'slug' => 'slash_test_2_' . $taxonomy, 55 'description' => $this->slash_5,61 'description' => self::SLASH_5, 56 62 ) 57 63 ); 58 64 $term = get_term( $insert['term_id'], $taxonomy ); 59 $this->assertSame( wp_unslash( $this->slash_3 ), $term->name );60 $this->assertSame( wp_unslash( $this->slash_5 ), $term->description );65 $this->assertSame( wp_unslash( self::SLASH_3 ), $term->name ); 66 $this->assertSame( wp_unslash( self::SLASH_5 ), $term->description ); 61 67 62 68 $insert = wp_insert_term( 63 $this->slash_2,69 self::SLASH_2, 64 70 $taxonomy, 65 71 array( 66 72 'slug' => 'slash_test_3_' . $taxonomy, 67 'description' => $this->slash_4,73 'description' => self::SLASH_4, 68 74 ) 69 75 ); 70 76 $term = get_term( $insert['term_id'], $taxonomy ); 71 $this->assertSame( wp_unslash( $this->slash_2 ), $term->name );72 $this->assertSame( wp_unslash( $this->slash_4 ), $term->description );77 $this->assertSame( wp_unslash( self::SLASH_2 ), $term->name ); 78 $this->assertSame( wp_unslash( self::SLASH_4 ), $term->description ); 73 79 } 74 80 } … … 93 99 $taxonomy, 94 100 array( 95 'name' => $this->slash_1,96 'description' => $this->slash_3,101 'name' => self::SLASH_1, 102 'description' => self::SLASH_3, 97 103 ) 98 104 ); 99 105 100 106 $term = get_term( $term_id, $taxonomy ); 101 $this->assertSame( wp_unslash( $this->slash_1 ), $term->name );102 $this->assertSame( wp_unslash( $this->slash_3 ), $term->description );107 $this->assertSame( wp_unslash( self::SLASH_1 ), $term->name ); 108 $this->assertSame( wp_unslash( self::SLASH_3 ), $term->description ); 103 109 104 110 $update = wp_update_term( … … 106 112 $taxonomy, 107 113 array( 108 'name' => $this->slash_3,109 'description' => $this->slash_5,114 'name' => self::SLASH_3, 115 'description' => self::SLASH_5, 110 116 ) 111 117 ); 112 118 $term = get_term( $term_id, $taxonomy ); 113 $this->assertSame( wp_unslash( $this->slash_3 ), $term->name );114 $this->assertSame( wp_unslash( $this->slash_5 ), $term->description );119 $this->assertSame( wp_unslash( self::SLASH_3 ), $term->name ); 120 $this->assertSame( wp_unslash( self::SLASH_5 ), $term->description ); 115 121 116 122 $update = wp_update_term( … … 118 124 $taxonomy, 119 125 array( 120 'name' => $this->slash_2,121 'description' => $this->slash_4,126 'name' => self::SLASH_2, 127 'description' => self::SLASH_4, 122 128 ) 123 129 ); 124 130 $term = get_term( $term_id, $taxonomy ); 125 $this->assertSame( wp_unslash( $this->slash_2 ), $term->name );126 $this->assertSame( wp_unslash( $this->slash_4 ), $term->description );131 $this->assertSame( wp_unslash( self::SLASH_2 ), $term->name ); 132 $this->assertSame( wp_unslash( self::SLASH_4 ), $term->description ); 127 133 } 128 134 }
Note: See TracChangeset
for help on using the changeset viewer.