Changeset 48937 for trunk/tests/phpunit/tests/filters.php
- Timestamp:
- 09/02/2020 12:35:36 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/filters.php
r47122 r48937 14 14 15 15 add_filter( $tag, array( $a, 'filter' ) ); 16 $this->assert Equals( $val, apply_filters( $tag, $val ) );16 $this->assertSame( $val, apply_filters( $tag, $val ) ); 17 17 18 18 // Only one event occurred for the hook, with empty args. 19 $this->assert Equals( 1, $a->get_call_count() );19 $this->assertSame( 1, $a->get_call_count() ); 20 20 // Only our hook was called. 21 $this->assert Equals( array( $tag ), $a->get_tags() );21 $this->assertSame( array( $tag ), $a->get_tags() ); 22 22 23 23 $argsvar = $a->get_args(); 24 24 $args = array_pop( $argsvar ); 25 $this->assert Equals( array( $val ), $args );25 $this->assertSame( array( $val ), $args ); 26 26 } 27 27 … … 32 32 33 33 add_filter( $tag, array( $a, 'filter' ) ); 34 $this->assert Equals( $val, apply_filters( $tag, $val ) );34 $this->assertSame( $val, apply_filters( $tag, $val ) ); 35 35 36 36 // Make sure our hook was called correctly. 37 $this->assert Equals( 1, $a->get_call_count() );38 $this->assert Equals( array( $tag ), $a->get_tags() );37 $this->assertSame( 1, $a->get_call_count() ); 38 $this->assertSame( array( $tag ), $a->get_tags() ); 39 39 40 40 // Now remove the filter, do it again, and make sure it's not called this time. 41 41 remove_filter( $tag, array( $a, 'filter' ) ); 42 $this->assert Equals( $val, apply_filters( $tag, $val ) );43 $this->assert Equals( 1, $a->get_call_count() );44 $this->assert Equals( array( $tag ), $a->get_tags() );42 $this->assertSame( $val, apply_filters( $tag, $val ) ); 43 $this->assertSame( 1, $a->get_call_count() ); 44 $this->assertSame( array( $tag ), $a->get_tags() ); 45 45 46 46 } … … 53 53 $this->assertFalse( has_filter( $tag ) ); 54 54 add_filter( $tag, $func ); 55 $this->assert Equals( 10, has_filter( $tag, $func ) );55 $this->assertSame( 10, has_filter( $tag, $func ) ); 56 56 $this->assertTrue( has_filter( $tag ) ); 57 57 remove_filter( $tag, $func ); … … 71 71 add_filter( $tag, array( $a2, 'filter' ) ); 72 72 73 $this->assert Equals( $val, apply_filters( $tag, $val ) );73 $this->assertSame( $val, apply_filters( $tag, $val ) ); 74 74 75 75 // Both filters called once each. 76 $this->assert Equals( 1, $a1->get_call_count() );77 $this->assert Equals( 1, $a2->get_call_count() );76 $this->assertSame( 1, $a1->get_call_count() ); 77 $this->assertSame( 1, $a2->get_call_count() ); 78 78 } 79 79 … … 86 86 add_filter( $tag, array( $a, 'filter' ), 10, 2 ); 87 87 // Call the filter with a single argument. 88 $this->assert Equals( $val, apply_filters( $tag, $val, $arg1 ) );89 90 $this->assert Equals( 1, $a->get_call_count() );88 $this->assertSame( $val, apply_filters( $tag, $val, $arg1 ) ); 89 90 $this->assertSame( 1, $a->get_call_count() ); 91 91 $argsvar = $a->get_args(); 92 $this->assert Equals( array( $val, $arg1 ), array_pop( $argsvar ) );92 $this->assertSame( array( $val, $arg1 ), array_pop( $argsvar ) ); 93 93 } 94 94 … … 105 105 add_filter( $tag, array( $a2, 'filter' ) ); 106 106 // Call the filter with two arguments. 107 $this->assert Equals( $val, apply_filters( $tag, $val, $arg1, $arg2 ) );107 $this->assertSame( $val, apply_filters( $tag, $val, $arg1, $arg2 ) ); 108 108 109 109 // $a1 should be called with both args. 110 $this->assert Equals( 1, $a1->get_call_count() );110 $this->assertSame( 1, $a1->get_call_count() ); 111 111 $argsvar1 = $a1->get_args(); 112 $this->assert Equals( array( $val, $arg1, $arg2 ), array_pop( $argsvar1 ) );112 $this->assertSame( array( $val, $arg1, $arg2 ), array_pop( $argsvar1 ) ); 113 113 114 114 // $a2 should be called with one only. 115 $this->assert Equals( 1, $a2->get_call_count() );115 $this->assertSame( 1, $a2->get_call_count() ); 116 116 $argsvar2 = $a2->get_args(); 117 $this->assert Equals( array( $val ), array_pop( $argsvar2 ) );117 $this->assertSame( array( $val ), array_pop( $argsvar2 ) ); 118 118 } 119 119 … … 126 126 add_filter( $tag, array( $a, 'filter' ), 10 ); 127 127 add_filter( $tag, array( $a, 'filter2' ), 9 ); 128 $this->assert Equals( $val, apply_filters( $tag, $val ) );128 $this->assertSame( $val, apply_filters( $tag, $val ) ); 129 129 130 130 // There should be two events, one per filter. 131 $this->assert Equals( 2, $a->get_call_count() );131 $this->assertSame( 2, $a->get_call_count() ); 132 132 133 133 $expected = array( … … 146 146 ); 147 147 148 $this->assert Equals( $expected, $a->get_events() );148 $this->assertSame( $expected, $a->get_events() ); 149 149 } 150 150 … … 158 158 add_filter( 'all', array( $a, 'filterall' ) ); 159 159 // Apply some filters. 160 $this->assert Equals( $val, apply_filters( $tag1, $val ) );161 $this->assert Equals( $val, apply_filters( $tag2, $val ) );162 $this->assert Equals( $val, apply_filters( $tag1, $val ) );163 $this->assert Equals( $val, apply_filters( $tag1, $val ) );160 $this->assertSame( $val, apply_filters( $tag1, $val ) ); 161 $this->assertSame( $val, apply_filters( $tag2, $val ) ); 162 $this->assertSame( $val, apply_filters( $tag1, $val ) ); 163 $this->assertSame( $val, apply_filters( $tag1, $val ) ); 164 164 165 165 // Our filter should have been called once for each apply_filters call. 166 $this->assert Equals( 4, $a->get_call_count() );166 $this->assertSame( 4, $a->get_call_count() ); 167 167 // The right hooks should have been called in order. 168 $this->assert Equals( array( $tag1, $tag2, $tag1, $tag1 ), $a->get_tags() );168 $this->assertSame( array( $tag1, $tag2, $tag1, $tag1 ), $a->get_tags() ); 169 169 170 170 remove_filter( 'all', array( $a, 'filterall' ) ); … … 180 180 add_filter( 'all', array( $a, 'filterall' ) ); 181 181 $this->assertTrue( has_filter( 'all' ) ); 182 $this->assert Equals( 10, has_filter( 'all', array( $a, 'filterall' ) ) );183 $this->assert Equals( $val, apply_filters( $tag, $val ) );182 $this->assertSame( 10, has_filter( 'all', array( $a, 'filterall' ) ) ); 183 $this->assertSame( $val, apply_filters( $tag, $val ) ); 184 184 185 185 // Make sure our hook was called correctly. 186 $this->assert Equals( 1, $a->get_call_count() );187 $this->assert Equals( array( $tag ), $a->get_tags() );186 $this->assertSame( 1, $a->get_call_count() ); 187 $this->assertSame( array( $tag ), $a->get_tags() ); 188 188 189 189 // Now remove the filter, do it again, and make sure it's not called this time. … … 191 191 $this->assertFalse( has_filter( 'all', array( $a, 'filterall' ) ) ); 192 192 $this->assertFalse( has_filter( 'all' ) ); 193 $this->assert Equals( $val, apply_filters( $tag, $val ) );193 $this->assertSame( $val, apply_filters( $tag, $val ) ); 194 194 // Call cound should remain at 1. 195 $this->assert Equals( 1, $a->get_call_count() );196 $this->assert Equals( array( $tag ), $a->get_tags() );195 $this->assertSame( 1, $a->get_call_count() ); 196 $this->assertSame( array( $tag ), $a->get_tags() ); 197 197 } 198 198 … … 249 249 $result = apply_filters_ref_array( $tag, array( 'string', &$obj ) ); 250 250 251 $this->assert Equals( $result, 'string_append_append' );251 $this->assertSame( $result, 'string_append_append' ); 252 252 253 253 $args = $a->get_args(); … … 374 374 remove_action( 'test_current_priority', array( $this, '_other_priority_action' ), 99 ); 375 375 376 $this->assert Same( false,$this->current_priority );376 $this->assertFalse( $this->current_priority ); 377 377 } 378 378
Note: See TracChangeset
for help on using the changeset viewer.