Changeset 42343 for trunk/tests/phpunit/tests/image/size.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/image/size.php
r40533 r42343 10 10 function test_constrain_dims_zero() { 11 11 // no constraint - should have no effect 12 $out = wp_constrain_dimensions( 640, 480, 0, 0);12 $out = wp_constrain_dimensions( 640, 480, 0, 0 ); 13 13 $this->assertSame( array( 640, 480 ), $out ); 14 14 15 $out = wp_constrain_dimensions( 640, 480);15 $out = wp_constrain_dimensions( 640, 480 ); 16 16 $this->assertSame( array( 640, 480 ), $out ); 17 17 18 $out = wp_constrain_dimensions( 0, 0, 0, 0);18 $out = wp_constrain_dimensions( 0, 0, 0, 0 ); 19 19 $this->assertSame( array( 0, 0 ), $out ); 20 20 21 $out = wp_constrain_dimensions( 465, 700, 177, 177);21 $out = wp_constrain_dimensions( 465, 700, 177, 177 ); 22 22 $this->assertSame( array( 118, 177 ), $out ); 23 23 } … … 25 25 function test_constrain_dims_smaller() { 26 26 // image size is smaller than the constraint - no effect 27 $out = wp_constrain_dimensions( 500, 600, 1024, 768);28 $this->assertSame( array( 500, 600 ), $out ); 29 30 $out = wp_constrain_dimensions( 500, 600, 0, 768);31 $this->assertSame( array( 500, 600 ), $out ); 32 33 $out = wp_constrain_dimensions( 500, 600, 1024, 0);27 $out = wp_constrain_dimensions( 500, 600, 1024, 768 ); 28 $this->assertSame( array( 500, 600 ), $out ); 29 30 $out = wp_constrain_dimensions( 500, 600, 0, 768 ); 31 $this->assertSame( array( 500, 600 ), $out ); 32 33 $out = wp_constrain_dimensions( 500, 600, 1024, 0 ); 34 34 $this->assertSame( array( 500, 600 ), $out ); 35 35 } … … 37 37 function test_constrain_dims_equal() { 38 38 // image size is equal to the constraint - no effect 39 $out = wp_constrain_dimensions( 1024, 768, 1024, 768);39 $out = wp_constrain_dimensions( 1024, 768, 1024, 768 ); 40 40 $this->assertSame( array( 1024, 768 ), $out ); 41 41 42 $out = wp_constrain_dimensions( 1024, 768, 0, 768);42 $out = wp_constrain_dimensions( 1024, 768, 0, 768 ); 43 43 $this->assertSame( array( 1024, 768 ), $out ); 44 44 45 $out = wp_constrain_dimensions( 1024, 768, 1024, 0);45 $out = wp_constrain_dimensions( 1024, 768, 1024, 0 ); 46 46 $this->assertSame( array( 1024, 768 ), $out ); 47 47 } … … 49 49 function test_constrain_dims_larger() { 50 50 // image size is larger than the constraint - result should be constrained 51 $out = wp_constrain_dimensions( 1024, 768, 500, 600);52 $this->assertSame( array( 500, 375 ), $out ); 53 54 $out = wp_constrain_dimensions( 1024, 768, 0, 600);51 $out = wp_constrain_dimensions( 1024, 768, 500, 600 ); 52 $this->assertSame( array( 500, 375 ), $out ); 53 54 $out = wp_constrain_dimensions( 1024, 768, 0, 600 ); 55 55 $this->assertSame( array( 800, 600 ), $out ); 56 56 57 $out = wp_constrain_dimensions( 1024, 768, 500, 0);57 $out = wp_constrain_dimensions( 1024, 768, 500, 0 ); 58 58 $this->assertSame( array( 500, 375 ), $out ); 59 59 60 60 // also try a portrait oriented image 61 $out = wp_constrain_dimensions( 300, 800, 500, 600);61 $out = wp_constrain_dimensions( 300, 800, 500, 600 ); 62 62 $this->assertSame( array( 225, 600 ), $out ); 63 63 64 $out = wp_constrain_dimensions( 300, 800, 0, 600);64 $out = wp_constrain_dimensions( 300, 800, 0, 600 ); 65 65 $this->assertSame( array( 225, 600 ), $out ); 66 66 67 $out = wp_constrain_dimensions( 300, 800, 200, 0);67 $out = wp_constrain_dimensions( 300, 800, 200, 0 ); 68 68 $this->assertSame( array( 200, 533 ), $out ); 69 69 } … … 71 71 function test_constrain_dims_boundary() { 72 72 // one dimension is larger than the constraint, one smaller - result should be constrained 73 $out = wp_constrain_dimensions( 1024, 768, 500, 800);74 $this->assertSame( array( 500, 375 ), $out ); 75 76 $out = wp_constrain_dimensions( 1024, 768, 2000, 700);73 $out = wp_constrain_dimensions( 1024, 768, 500, 800 ); 74 $this->assertSame( array( 500, 375 ), $out ); 75 76 $out = wp_constrain_dimensions( 1024, 768, 2000, 700 ); 77 77 $this->assertSame( array( 933, 700 ), $out ); 78 78 79 79 // portrait 80 $out = wp_constrain_dimensions( 768, 1024, 800, 500);80 $out = wp_constrain_dimensions( 768, 1024, 800, 500 ); 81 81 $this->assertSame( array( 375, 500 ), $out ); 82 82 83 $out = wp_constrain_dimensions( 768, 1024, 2000, 700);83 $out = wp_constrain_dimensions( 768, 1024, 2000, 700 ); 84 84 $this->assertSame( array( 525, 700 ), $out ); 85 85 } … … 89 89 */ 90 90 function test_shrink_dimensions_default() { 91 $out = wp_shrink_dimensions( 640, 480);91 $out = wp_shrink_dimensions( 640, 480 ); 92 92 $this->assertSame( array( 128, 96 ), $out ); 93 93 94 $out = wp_shrink_dimensions( 480, 640);94 $out = wp_shrink_dimensions( 480, 640 ); 95 95 $this->assertSame( array( 72, 96 ), $out ); 96 96 } … … 101 101 function test_shrink_dimensions_smaller() { 102 102 // image size is smaller than the constraint - no effect 103 $out = wp_shrink_dimensions( 500, 600, 1024, 768);104 $this->assertSame( array( 500, 600 ), $out ); 105 106 $out = wp_shrink_dimensions( 600, 500, 1024, 768);103 $out = wp_shrink_dimensions( 500, 600, 1024, 768 ); 104 $this->assertSame( array( 500, 600 ), $out ); 105 106 $out = wp_shrink_dimensions( 600, 500, 1024, 768 ); 107 107 $this->assertSame( array( 600, 500 ), $out ); 108 108 } … … 113 113 function test_shrink_dimensions_equal() { 114 114 // image size is equal to the constraint - no effect 115 $out = wp_shrink_dimensions( 500, 600, 500, 600);116 $this->assertSame( array( 500, 600 ), $out ); 117 118 $out = wp_shrink_dimensions( 600, 500, 600, 500);115 $out = wp_shrink_dimensions( 500, 600, 500, 600 ); 116 $this->assertSame( array( 500, 600 ), $out ); 117 118 $out = wp_shrink_dimensions( 600, 500, 600, 500 ); 119 119 $this->assertSame( array( 600, 500 ), $out ); 120 120 } … … 125 125 function test_shrink_dimensions_larger() { 126 126 // image size is larger than the constraint - result should be constrained 127 $out = wp_shrink_dimensions( 1024, 768, 500, 600);128 $this->assertSame( array( 500, 375 ), $out ); 129 130 $out = wp_shrink_dimensions( 300, 800, 500, 600);127 $out = wp_shrink_dimensions( 1024, 768, 500, 600 ); 128 $this->assertSame( array( 500, 375 ), $out ); 129 130 $out = wp_shrink_dimensions( 300, 800, 500, 600 ); 131 131 $this->assertSame( array( 225, 600 ), $out ); 132 132 } … … 137 137 function test_shrink_dimensions_boundary() { 138 138 // one dimension is larger than the constraint, one smaller - result should be constrained 139 $out = wp_shrink_dimensions( 1024, 768, 500, 800);140 $this->assertSame( array( 500, 375 ), $out ); 141 142 $out = wp_shrink_dimensions( 1024, 768, 2000, 700);139 $out = wp_shrink_dimensions( 1024, 768, 500, 800 ); 140 $this->assertSame( array( 500, 375 ), $out ); 141 142 $out = wp_shrink_dimensions( 1024, 768, 2000, 700 ); 143 143 $this->assertSame( array( 933, 700 ), $out ); 144 144 145 145 // portrait 146 $out = wp_shrink_dimensions( 768, 1024, 800, 500);146 $out = wp_shrink_dimensions( 768, 1024, 800, 500 ); 147 147 $this->assertSame( array( 375, 500 ), $out ); 148 148 149 $out = wp_shrink_dimensions( 768, 1024, 2000, 700);149 $out = wp_shrink_dimensions( 768, 1024, 2000, 700 ); 150 150 $this->assertSame( array( 525, 700 ), $out ); 151 151 } 152 152 153 153 function test_constrain_size_for_editor_thumb() { 154 $out = image_constrain_size_for_editor( 600, 400, 'thumb');154 $out = image_constrain_size_for_editor( 600, 400, 'thumb' ); 155 155 $this->assertSame( array( 150, 100 ), $out ); 156 156 157 $out = image_constrain_size_for_editor( 64, 64, 'thumb');157 $out = image_constrain_size_for_editor( 64, 64, 'thumb' ); 158 158 $this->assertSame( array( 64, 64 ), $out ); 159 159 } … … 166 166 167 167 $content_width = 0; 168 update_option( 'medium_size_w', 500);169 update_option( 'medium_size_h', 0);170 171 $out = image_constrain_size_for_editor( 600, 400, 'medium');168 update_option( 'medium_size_w', 500 ); 169 update_option( 'medium_size_h', 0 ); 170 171 $out = image_constrain_size_for_editor( 600, 400, 'medium' ); 172 172 $this->assertSame( array( 500, 333 ), $out ); 173 173 174 $out = image_constrain_size_for_editor( 400, 600, 'medium');174 $out = image_constrain_size_for_editor( 400, 600, 'medium' ); 175 175 $this->assertSame( array( 400, 600 ), $out ); 176 176 177 $out = image_constrain_size_for_editor( 64, 64, 'medium');177 $out = image_constrain_size_for_editor( 64, 64, 'medium' ); 178 178 $this->assertSame( array( 64, 64 ), $out ); 179 179 180 180 // content_width should be ignored 181 181 $content_width = 350; 182 $out = image_constrain_size_for_editor(600, 400, 'medium');182 $out = image_constrain_size_for_editor( 600, 400, 'medium' ); 183 183 $this->assertSame( array( 500, 333 ), $out ); 184 184 … … 192 192 193 193 $content_width = 400; 194 $out = image_constrain_size_for_editor(600, 400, 'full');194 $out = image_constrain_size_for_editor( 600, 400, 'full' ); 195 195 $this->assertSame( array( 600, 400 ), $out ); 196 196 197 $out = image_constrain_size_for_editor( 64, 64, 'full');197 $out = image_constrain_size_for_editor( 64, 64, 'full' ); 198 198 $this->assertSame( array( 64, 64 ), $out ); 199 199 … … 201 201 $content_width = 0; 202 202 203 $out = image_constrain_size_for_editor( 600, 400, 'full');203 $out = image_constrain_size_for_editor( 600, 400, 'full' ); 204 204 $this->assertSame( array( 600, 400 ), $out ); 205 205 206 $out = image_constrain_size_for_editor( 64, 64, 'full');206 $out = image_constrain_size_for_editor( 64, 64, 'full' ); 207 207 $this->assertSame( array( 64, 64 ), $out ); 208 208
Note: See TracChangeset
for help on using the changeset viewer.