Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/image/header.php

    r41732 r42343  
    11<?php
    2 require_once( ABSPATH . 'wp-admin/custom-header.php');
     2require_once( ABSPATH . 'wp-admin/custom-header.php' );
    33
    44/**
     
    1717        global $_wp_theme_features;
    1818
    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;
    2323        $_wp_theme_features['custom-header'][0]['flex-height'] = false;
    2424
    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        );
    2931        $this->assertEquals( 1200, $dimensions['dst_width'] );
    3032        $this->assertEquals( 230, $dimensions['dst_height'] );
     
    3638
    3739        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;
    4143        $_wp_theme_features['custom-header'][0]['flex-height'] = false;
    4244
    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        );
    4751        $this->assertEquals( 1200, $dimensions['dst_width'] );
    4852        $this->assertEquals( 230, $dimensions['dst_height'] );
     
    5458
    5559        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;
    5963        $_wp_theme_features['custom-header'][0]['flex-height'] = true;
    6064
    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        );
    6571        $this->assertEquals( 1200, $dimensions['dst_width'] );
    6672        $this->assertEquals( 900, $dimensions['dst_height'] );
     
    7278
    7379        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;
    7783        $_wp_theme_features['custom-header'][0]['flex-height'] = false;
    7884
    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        );
    8391        $this->assertEquals( 1500, $dimensions['dst_width'] ); // max width
    8492        $this->assertEquals( 230, $dimensions['dst_height'] );
     
    8997        global $_wp_theme_features;
    9098
    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;
    95103        $_wp_theme_features['custom-header'][0]['flex-height'] = true;
    96104
    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        );
    101111        $this->assertEquals( 1600, $dimensions['dst_width'] );
    102112        $this->assertEquals( 1200, $dimensions['dst_height'] );
     
    105115
    106116    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        );
    113125
    114126        $cropped = 'foo-cropped.png';
     
    122134
    123135    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        );
    130144
    131145        $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 );
    133147
    134148        $cropped_id = $this->custom_image_header->insert_attachment( $object, $cropped );
     
    142156     */
    143157    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        );
    150166
    151167        // Create inital crop object.
    152168        $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 );
    154170
    155171        // Ensure no previous crop exists.
     
    159175        // Create the inital crop attachment and set it as the header.
    160176        $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();
    162178        update_post_meta( $cropped_1_id, $key, time() );
    163179        update_post_meta( $cropped_1_id, '_wp_attachment_is_custom_header', get_stylesheet() );
     
    165181        // Create second crop.
    166182        $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 );
    168184
    169185        // Test that a previous crop is found.
Note: See TracChangeset for help on using the changeset viewer.