Changeset 42343 for trunk/tests/phpunit/tests/image/dimensions.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/image/dimensions.php
r30639 r42343 9 9 function test_400x400_no_crop() { 10 10 // landscape: resize 640x480 to fit 400x400: 400x300 11 $out = image_resize_dimensions( 640, 480, 400, 400, false);11 $out = image_resize_dimensions( 640, 480, 400, 400, false ); 12 12 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 13 $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480), $out );13 $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out ); 14 14 15 15 // portrait: resize 480x640 to fit 400x400: 300x400 16 $out = image_resize_dimensions( 480, 640, 400, 400, false);16 $out = image_resize_dimensions( 480, 640, 400, 400, false ); 17 17 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 18 $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640), $out );18 $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); 19 19 } 20 20 21 21 function test_400x0_no_crop() { 22 22 // landscape: resize 640x480 to fit 400w: 400x300 23 $out = image_resize_dimensions( 640, 480, 400, 0, false);23 $out = image_resize_dimensions( 640, 480, 400, 0, false ); 24 24 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 25 $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480), $out );25 $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out ); 26 26 27 27 // portrait: resize 480x640 to fit 400w: 400x533 28 $out = image_resize_dimensions( 480, 640, 400, 0, false);28 $out = image_resize_dimensions( 480, 640, 400, 0, false ); 29 29 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 30 $this->assertEquals( array( 0, 0, 0, 0, 400, 533, 480, 640), $out );30 $this->assertEquals( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out ); 31 31 } 32 32 33 33 function test_0x400_no_crop() { 34 34 // landscape: resize 640x480 to fit 400h: 533x400 35 $out = image_resize_dimensions( 640, 480, 0, 400, false);35 $out = image_resize_dimensions( 640, 480, 0, 400, false ); 36 36 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 37 $this->assertEquals( array( 0, 0, 0, 0, 533, 400, 640, 480), $out );37 $this->assertEquals( array( 0, 0, 0, 0, 533, 400, 640, 480 ), $out ); 38 38 39 39 // portrait: resize 480x640 to fit 400h: 300x400 40 $out = image_resize_dimensions( 480, 640, 0, 400, false);40 $out = image_resize_dimensions( 480, 640, 0, 400, false ); 41 41 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 42 $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640), $out );42 $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); 43 43 } 44 44 45 45 function test_800x800_no_crop() { 46 46 // landscape: resize 640x480 to fit 800x800 47 $out = image_resize_dimensions( 640, 480, 800, 800, false);47 $out = image_resize_dimensions( 640, 480, 800, 800, false ); 48 48 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 49 49 $this->assertEquals( false, $out ); 50 50 51 51 // portrait: resize 480x640 to fit 800x800 52 $out = image_resize_dimensions( 480, 640, 800, 800, false);52 $out = image_resize_dimensions( 480, 640, 800, 800, false ); 53 53 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 54 54 $this->assertEquals( false, $out ); … … 57 57 function test_800x0_no_crop() { 58 58 // landscape: resize 640x480 to fit 800w 59 $out = image_resize_dimensions( 640, 480, 800, 0, false);59 $out = image_resize_dimensions( 640, 480, 800, 0, false ); 60 60 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 61 61 $this->assertEquals( false, $out ); 62 62 63 63 // portrait: resize 480x640 to fit 800w 64 $out = image_resize_dimensions( 480, 640, 800, 0, false);64 $out = image_resize_dimensions( 480, 640, 800, 0, false ); 65 65 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 66 66 $this->assertEquals( false, $out ); … … 69 69 function test_0x800_no_crop() { 70 70 // landscape: resize 640x480 to fit 800h 71 $out = image_resize_dimensions( 640, 480, 0, 800, false);71 $out = image_resize_dimensions( 640, 480, 0, 800, false ); 72 72 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 73 73 $this->assertEquals( false, $out ); 74 74 75 75 // portrait: resize 480x640 to fit 800h 76 $out = image_resize_dimensions( 480, 640, 0, 800, false);76 $out = image_resize_dimensions( 480, 640, 0, 800, false ); 77 77 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 78 78 $this->assertEquals( false, $out ); … … 83 83 function test_400x400_crop() { 84 84 // landscape: crop 640x480 to fit 400x400: 400x400 taken from a 480x480 crop at (80. 0) 85 $out = image_resize_dimensions( 640, 480, 400, 400, true);85 $out = image_resize_dimensions( 640, 480, 400, 400, true ); 86 86 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 87 $this->assertEquals( array( 0, 0, 80, 0, 400, 400, 480, 480), $out );87 $this->assertEquals( array( 0, 0, 80, 0, 400, 400, 480, 480 ), $out ); 88 88 89 89 // portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop at (0. 80) 90 $out = image_resize_dimensions( 480, 640, 400, 400, true);90 $out = image_resize_dimensions( 480, 640, 400, 400, true ); 91 91 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 92 $this->assertEquals( array( 0, 0, 0, 80, 400, 400, 480, 480), $out );92 $this->assertEquals( array( 0, 0, 0, 80, 400, 400, 480, 480 ), $out ); 93 93 } 94 94 95 95 function test_400x0_crop() { 96 96 // landscape: resize 640x480 to fit 400w: 400x300 97 $out = image_resize_dimensions( 640, 480, 400, 0, true);97 $out = image_resize_dimensions( 640, 480, 400, 0, true ); 98 98 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 99 $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480), $out );99 $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out ); 100 100 101 101 // portrait: resize 480x640 to fit 400w: 400x533 102 $out = image_resize_dimensions( 480, 640, 400, 0, true);102 $out = image_resize_dimensions( 480, 640, 400, 0, true ); 103 103 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 104 $this->assertEquals( array( 0, 0, 0, 0, 400, 533, 480, 640), $out );104 $this->assertEquals( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out ); 105 105 } 106 106 107 107 function test_0x400_crop() { 108 108 // landscape: resize 640x480 to fit 400h: 533x400 109 $out = image_resize_dimensions( 640, 480, 0, 400, true);109 $out = image_resize_dimensions( 640, 480, 0, 400, true ); 110 110 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 111 $this->assertEquals( array( 0, 0, 0, 0, 533, 400, 640, 480), $out );111 $this->assertEquals( array( 0, 0, 0, 0, 533, 400, 640, 480 ), $out ); 112 112 113 113 // portrait: resize 480x640 to fit 400h: 300x400 114 $out = image_resize_dimensions( 480, 640, 0, 400, true);114 $out = image_resize_dimensions( 480, 640, 0, 400, true ); 115 115 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 116 $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640), $out );116 $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); 117 117 } 118 118 119 119 function test_400x500_crop() { 120 120 // landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop at (80. 0) 121 $out = image_resize_dimensions( 640, 480, 400, 500, true);121 $out = image_resize_dimensions( 640, 480, 400, 500, true ); 122 122 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 123 $this->assertEquals( array( 0, 0, 120, 0, 400, 480, 400, 480), $out );123 $this->assertEquals( array( 0, 0, 120, 0, 400, 480, 400, 480 ), $out ); 124 124 125 125 // portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop at (0. 80) 126 $out = image_resize_dimensions( 480, 640, 400, 500, true);126 $out = image_resize_dimensions( 480, 640, 400, 500, true ); 127 127 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 128 $this->assertEquals( array( 0, 0, 0, 20, 400, 500, 480, 600), $out );128 $this->assertEquals( array( 0, 0, 0, 20, 400, 500, 480, 600 ), $out ); 129 129 } 130 130 131 131 function test_640x480() { 132 132 // crop 640x480 to fit 640x480 (no change) 133 $out = image_resize_dimensions( 640, 480, 640, 480, true);133 $out = image_resize_dimensions( 640, 480, 640, 480, true ); 134 134 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 135 $this->assertEquals( array( 0, 0, 0, 0, 640, 480, 640, 480), $out );135 $this->assertEquals( array( 0, 0, 0, 0, 640, 480, 640, 480 ), $out ); 136 136 137 137 // resize 640x480 to fit 640x480 (no change) 138 $out = image_resize_dimensions( 640, 480, 640, 480, false);138 $out = image_resize_dimensions( 640, 480, 640, 480, false ); 139 139 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 140 $this->assertEquals( array( 0, 0, 0, 0, 640, 480, 640, 480), $out );140 $this->assertEquals( array( 0, 0, 0, 0, 640, 480, 640, 480 ), $out ); 141 141 } 142 142 … … 147 147 // landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop 148 148 // src_x = 0 (left), src_y = 0 (top) 149 $out = image_resize_dimensions( 640, 480, 400, 500, array( 'left', 'top' ) );149 $out = image_resize_dimensions( 640, 480, 400, 500, array( 'left', 'top' ) ); 150 150 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 151 $this->assertEquals( array( 0, 0, 0, 0, 400, 480, 400, 480), $out );151 $this->assertEquals( array( 0, 0, 0, 0, 400, 480, 400, 480 ), $out ); 152 152 153 153 // portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop 154 154 // src_x = 0 (left), src_y = 0 (top) 155 $out = image_resize_dimensions( 480, 640, 400, 500, array( 'left', 'top' ) );155 $out = image_resize_dimensions( 480, 640, 400, 500, array( 'left', 'top' ) ); 156 156 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 157 $this->assertEquals( array( 0, 0, 0, 0, 400, 500, 480, 600), $out );157 $this->assertEquals( array( 0, 0, 0, 0, 400, 500, 480, 600 ), $out ); 158 158 159 159 // landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop 160 160 // src_x = 240 (left), src_y = 0 (due to landscape crop) 161 $out = image_resize_dimensions( 640, 480, 400, 500, array( 'right', 'bottom' ) );161 $out = image_resize_dimensions( 640, 480, 400, 500, array( 'right', 'bottom' ) ); 162 162 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 163 $this->assertEquals( array( 0, 0, 240, 0, 400, 480, 400, 480), $out );163 $this->assertEquals( array( 0, 0, 240, 0, 400, 480, 400, 480 ), $out ); 164 164 165 165 // portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop 166 166 // src_x = 0 (due to portrait crop), src_y = 40 (bottom) 167 $out = image_resize_dimensions( 480, 640, 400, 500, array( 'right', 'bottom' ) );167 $out = image_resize_dimensions( 480, 640, 400, 500, array( 'right', 'bottom' ) ); 168 168 // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h 169 $this->assertEquals( array( 0, 0, 0, 40, 400, 500, 480, 600), $out );169 $this->assertEquals( array( 0, 0, 0, 40, 400, 500, 480, 600 ), $out ); 170 170 } 171 171
Note: See TracChangeset
for help on using the changeset viewer.