WordPress.org

Make WordPress Core

Ticket #42277: 42277.diff

File 42277.diff, 3.8 KB (added by Frank Klein, 3 years ago)
  • tests/phpunit/includes/class-basic-object.php

    diff --git tests/phpunit/includes/class-basic-object.php tests/phpunit/includes/class-basic-object.php
    index a85a9f6596..da8bede8c6 100644
     
    77 * @since 4.7.0
    88 */
    99
     10trigger_error( __FILE__ . ' is deprecated since version 4.9.2 with no alternative available.' );
     11
    1012/**
    1113 * Class used to test accessing methods and properties
    1214 *
  • tests/phpunit/includes/class-basic-subclass.php

    diff --git tests/phpunit/includes/class-basic-subclass.php tests/phpunit/includes/class-basic-subclass.php
    index deb922d681..a7e05d750a 100644
     
    77 * @since 4.7.0
    88 */
    99
     10trigger_error( __FILE__ . ' is deprecated since version 4.9.2 with no alternative available.' );
     11
    1012/**
    1113 * Class used to test accessing methods and properties.
    1214 *
  • tests/phpunit/includes/functions.php

    diff --git tests/phpunit/includes/functions.php tests/phpunit/includes/functions.php
    index 928fcd912f..42a6f43006 100644
     
    11<?php
    22
    3 require_once dirname( __FILE__ ) . '/class-basic-object.php';
    4 require_once dirname( __FILE__ ) . '/class-basic-subclass.php';
    5 
    63/**
    74 * Resets various `$_SERVER` variables that can get altered during tests.
    85 */
  • tests/phpunit/tests/basic.php

    diff --git tests/phpunit/tests/basic.php tests/phpunit/tests/basic.php
    index 0d145f638d..7d9d0ba932 100644
    class Tests_Basic extends WP_UnitTestCase { 
    3939                $this->assertRegExp( '~^=?\d+\.\d+\.\d+$~', $node, "package.json's node version cannot be a range." );
    4040        }
    4141
    42         // two tests for a lame bug in PHPUnit that broke the $GLOBALS reference
    43         function test_globals() {
    44                 global $test_foo;
    45                 $test_foo = array('foo', 'bar', 'baz');
    46 
    47                 function test_globals_foo() {
    48                         unset($GLOBALS['test_foo'][1]);
    49                 }
    50 
    51                 test_globals_foo();
    52 
    53                 $this->assertEquals($test_foo, array(0=>'foo', 2=>'baz'));
    54                 $this->assertEquals($test_foo, $GLOBALS['test_foo']);
    55         }
    56 
    57         function test_globals_bar() {
    58                 global $test_bar;
    59                 $test_bar = array('a', 'b', 'c');
    60                 $this->assertEquals($test_bar, $GLOBALS['test_bar']);
    61         }
    62 
    6342        // test some helper utility functions
    6443
    6544        function test_strip_ws() {
    EOF; 
    10584EOF;
    10685                $this->assertEquals($expected, mask_input_value($in));
    10786        }
    108 
    109         /**
    110          * @ticket 17884
    111          */
    112         function test_setting_nonexistent_arrays() {
    113                 $page = 1;
    114                 $field = 'settings';
    115 
    116                 $empty_array[$page][$field] = 'foo';
    117 
    118                 // Assertion not strictly needed; we mainly want to show that a notice is not thrown.
    119                 unset( $empty_array[$page]['bar']['baz'] );
    120                 $this->assertFalse( isset( $empty_array[ $page ]['bar']['baz'] ) );
    121         }
    122 
    123         function test_magic_getter() {
    124                 $basic = new Basic_Object();
    125 
    126                 $this->assertEquals( 'bar', $basic->foo );
    127         }
    128 
    129         function test_subclass_magic_getter() {
    130                 $basic = new Basic_Subclass();
    131 
    132                 $this->assertEquals( 'bar', $basic->foo );
    133         }
    134 
    135         function test_call_method() {
    136                 $basic = new Basic_Object();
    137 
    138                 $this->assertEquals( 'maybe', $basic->callMe() );
    139         }
    140 
    141         function test_subclass_call_method() {
    142                 $basic = new Basic_Subclass();
    143 
    144                 $this->assertEquals( 'maybe', $basic->callMe() );
    145         }
    146 
    147         function test_subclass_isset() {
    148                 $basic = new Basic_Subclass();
    149 
    150                 $this->assertTrue( isset( $basic->foo ) );
    151         }
    152 
    153         function test_subclass_unset() {
    154                 $basic = new Basic_Subclass();
    155 
    156                 unset( $basic->foo );
    157 
    158                 $this->assertFalse( isset( $basic->foo ) );
    159         }
    160 
    161         function test_switch_order() {
    162                 $return = $this->_switch_order_helper( 1 );
    163                 $this->assertEquals( 'match', $return );
    164         }
    165 
    166         function _switch_order_helper( $var ) {
    167                 $return = 'no match';
    168                 switch ( $var ) {
    169                 default:
    170                         break;
    171                 case 1:
    172                         $return = 'match';
    173                         break;
    174                 }
    175 
    176                 return $return;
    177         }
    17887}