Changeset 42343 for trunk/tests/phpunit/tests/image/header.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/image/header.php
r41732 r42343 1 1 <?php 2 require_once( ABSPATH . 'wp-admin/custom-header.php' );2 require_once( ABSPATH . 'wp-admin/custom-header.php' ); 3 3 4 4 /** … … 17 17 global $_wp_theme_features; 18 18 19 $_wp_theme_features['custom-header'][0]['max-width'] = 1600;20 $_wp_theme_features['custom-header'][0]['width'] = 1200;21 $_wp_theme_features['custom-header'][0]['height'] = 230;22 $_wp_theme_features['custom-header'][0]['flex-width'] = false;19 $_wp_theme_features['custom-header'][0]['max-width'] = 1600; 20 $_wp_theme_features['custom-header'][0]['width'] = 1200; 21 $_wp_theme_features['custom-header'][0]['height'] = 230; 22 $_wp_theme_features['custom-header'][0]['flex-width'] = false; 23 23 $_wp_theme_features['custom-header'][0]['flex-height'] = false; 24 24 25 $dimensions = $this->custom_image_header->get_header_dimensions( array( 26 'width' => 1600, 27 'height' => 1200, 28 ) ); 25 $dimensions = $this->custom_image_header->get_header_dimensions( 26 array( 27 'width' => 1600, 28 'height' => 1200, 29 ) 30 ); 29 31 $this->assertEquals( 1200, $dimensions['dst_width'] ); 30 32 $this->assertEquals( 230, $dimensions['dst_height'] ); … … 36 38 37 39 unset( $_wp_theme_features['custom-header'][0]['max-width'] ); 38 $_wp_theme_features['custom-header'][0]['width'] = 1200;39 $_wp_theme_features['custom-header'][0]['height'] = 230;40 $_wp_theme_features['custom-header'][0]['flex-width'] = false;40 $_wp_theme_features['custom-header'][0]['width'] = 1200; 41 $_wp_theme_features['custom-header'][0]['height'] = 230; 42 $_wp_theme_features['custom-header'][0]['flex-width'] = false; 41 43 $_wp_theme_features['custom-header'][0]['flex-height'] = false; 42 44 43 $dimensions = $this->custom_image_header->get_header_dimensions( array( 44 'width' => 1600, 45 'height' => 1200, 46 ) ); 45 $dimensions = $this->custom_image_header->get_header_dimensions( 46 array( 47 'width' => 1600, 48 'height' => 1200, 49 ) 50 ); 47 51 $this->assertEquals( 1200, $dimensions['dst_width'] ); 48 52 $this->assertEquals( 230, $dimensions['dst_height'] ); … … 54 58 55 59 unset( $_wp_theme_features['custom-header'][0]['max-width'] ); 56 $_wp_theme_features['custom-header'][0]['width'] = 1200;57 $_wp_theme_features['custom-header'][0]['height'] = 230;58 $_wp_theme_features['custom-header'][0]['flex-width'] = false;60 $_wp_theme_features['custom-header'][0]['width'] = 1200; 61 $_wp_theme_features['custom-header'][0]['height'] = 230; 62 $_wp_theme_features['custom-header'][0]['flex-width'] = false; 59 63 $_wp_theme_features['custom-header'][0]['flex-height'] = true; 60 64 61 $dimensions = $this->custom_image_header->get_header_dimensions( array( 62 'width' => 1600, 63 'height' => 1200, 64 ) ); 65 $dimensions = $this->custom_image_header->get_header_dimensions( 66 array( 67 'width' => 1600, 68 'height' => 1200, 69 ) 70 ); 65 71 $this->assertEquals( 1200, $dimensions['dst_width'] ); 66 72 $this->assertEquals( 900, $dimensions['dst_height'] ); … … 72 78 73 79 unset( $_wp_theme_features['custom-header'][0]['max-width'] ); 74 $_wp_theme_features['custom-header'][0]['width'] = 1200;75 $_wp_theme_features['custom-header'][0]['height'] = 230;76 $_wp_theme_features['custom-header'][0]['flex-width'] = true;80 $_wp_theme_features['custom-header'][0]['width'] = 1200; 81 $_wp_theme_features['custom-header'][0]['height'] = 230; 82 $_wp_theme_features['custom-header'][0]['flex-width'] = true; 77 83 $_wp_theme_features['custom-header'][0]['flex-height'] = false; 78 84 79 $dimensions = $this->custom_image_header->get_header_dimensions( array( 80 'width' => 1600, 81 'height' => 1200, 82 ) ); 85 $dimensions = $this->custom_image_header->get_header_dimensions( 86 array( 87 'width' => 1600, 88 'height' => 1200, 89 ) 90 ); 83 91 $this->assertEquals( 1500, $dimensions['dst_width'] ); // max width 84 92 $this->assertEquals( 230, $dimensions['dst_height'] ); … … 89 97 global $_wp_theme_features; 90 98 91 $_wp_theme_features['custom-header'][0]['max-width'] = 1800;92 $_wp_theme_features['custom-header'][0]['width'] = 1200;93 $_wp_theme_features['custom-header'][0]['height'] = 230;94 $_wp_theme_features['custom-header'][0]['flex-width'] = true;99 $_wp_theme_features['custom-header'][0]['max-width'] = 1800; 100 $_wp_theme_features['custom-header'][0]['width'] = 1200; 101 $_wp_theme_features['custom-header'][0]['height'] = 230; 102 $_wp_theme_features['custom-header'][0]['flex-width'] = true; 95 103 $_wp_theme_features['custom-header'][0]['flex-height'] = true; 96 104 97 $dimensions = $this->custom_image_header->get_header_dimensions( array( 98 'width' => 1600, 99 'height' => 1200, 100 ) ); 105 $dimensions = $this->custom_image_header->get_header_dimensions( 106 array( 107 'width' => 1600, 108 'height' => 1200, 109 ) 110 ); 101 111 $this->assertEquals( 1600, $dimensions['dst_width'] ); 102 112 $this->assertEquals( 1200, $dimensions['dst_height'] ); … … 105 115 106 116 function test_create_attachment_object() { 107 $id = wp_insert_attachment( array( 108 'post_status' => 'publish', 109 'post_title' => 'foo.png', 110 'post_type' => 'post', 111 'guid' => 'http://localhost/foo.png' 112 ) ); 117 $id = wp_insert_attachment( 118 array( 119 'post_status' => 'publish', 120 'post_title' => 'foo.png', 121 'post_type' => 'post', 122 'guid' => 'http://localhost/foo.png', 123 ) 124 ); 113 125 114 126 $cropped = 'foo-cropped.png'; … … 122 134 123 135 function test_insert_cropped_attachment() { 124 $id = wp_insert_attachment( array( 125 'post_status' => 'publish', 126 'post_title' => 'foo.png', 127 'post_type' => 'post', 128 'guid' => 'http://localhost/foo.png' 129 ) ); 136 $id = wp_insert_attachment( 137 array( 138 'post_status' => 'publish', 139 'post_title' => 'foo.png', 140 'post_type' => 'post', 141 'guid' => 'http://localhost/foo.png', 142 ) 143 ); 130 144 131 145 $cropped = 'foo-cropped.png'; 132 $object = $this->custom_image_header->create_attachment_object( $cropped, $id );146 $object = $this->custom_image_header->create_attachment_object( $cropped, $id ); 133 147 134 148 $cropped_id = $this->custom_image_header->insert_attachment( $object, $cropped ); … … 142 156 */ 143 157 function test_check_get_previous_crop() { 144 $id = wp_insert_attachment( array( 145 'post_status' => 'publish', 146 'post_title' => 'foo.png', 147 'post_type' => 'post', 148 'guid' => 'http://localhost/foo.png' 149 ) ); 158 $id = wp_insert_attachment( 159 array( 160 'post_status' => 'publish', 161 'post_title' => 'foo.png', 162 'post_type' => 'post', 163 'guid' => 'http://localhost/foo.png', 164 ) 165 ); 150 166 151 167 // Create inital crop object. 152 168 $cropped_1 = 'foo-cropped-1.png'; 153 $object = $this->custom_image_header->create_attachment_object( $cropped_1, $id );169 $object = $this->custom_image_header->create_attachment_object( $cropped_1, $id ); 154 170 155 171 // Ensure no previous crop exists. … … 159 175 // Create the inital crop attachment and set it as the header. 160 176 $cropped_1_id = $this->custom_image_header->insert_attachment( $object, $cropped_1 ); 161 $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet();177 $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); 162 178 update_post_meta( $cropped_1_id, $key, time() ); 163 179 update_post_meta( $cropped_1_id, '_wp_attachment_is_custom_header', get_stylesheet() ); … … 165 181 // Create second crop. 166 182 $cropped_2 = 'foo-cropped-2.png'; 167 $object = $this->custom_image_header->create_attachment_object( $cropped_2, $id );183 $object = $this->custom_image_header->create_attachment_object( $cropped_2, $id ); 168 184 169 185 // Test that a previous crop is found.
Note: See TracChangeset
for help on using the changeset viewer.