WordPress.org

Make WordPress Core

Ticket #37523: 37523.diff

File 37523.diff, 3.1 KB (added by Frank Klein, 4 years ago)
  • new file tests/phpunit/includes/class-basic-object.php

    diff --git tests/phpunit/includes/class-basic-object.php tests/phpunit/includes/class-basic-object.php
    new file mode 100644
    index 0000000..569ec54
    - +  
     1<?php
     2/**
     3 * Unit Tests: Basic_Object class
     4 *
     5 * @package WordPress
     6 * @subpackage UnitTests
     7 * @since 4.6.0
     8 */
     9
     10/**
     11 * Class used to test accessing methods and properties.
     12 *
     13 * @since 4.0.0
     14 */
     15class Basic_Object {
     16        private $foo = 'bar';
     17
     18        public function __get( $name ) {
     19                return $this->$name;
     20        }
     21
     22        public function __set( $name, $value ) {
     23                return $this->$name = $value;
     24        }
     25
     26        public function __isset( $name ) {
     27                return isset( $this->$name );
     28        }
     29
     30        public function __unset( $name ) {
     31                unset( $this->$name );
     32        }
     33
     34        public function __call( $name, $arguments ) {
     35                return call_user_func_array( array( $this, $name ), $arguments );
     36        }
     37
     38        private function callMe() {
     39                return 'maybe';
     40        }
     41}
  • new file tests/phpunit/includes/class-basic-subclass.php

    diff --git tests/phpunit/includes/class-basic-subclass.php tests/phpunit/includes/class-basic-subclass.php
    new file mode 100644
    index 0000000..2108c09
    - +  
     1<?php
     2/**
     3 * Unit Tests: Basic_Subclass class
     4 *
     5 * @package WordPress
     6 * @subpackage UnitTests
     7 * @since 4.6.0
     8 */
     9
     10/**
     11 * Class used to test accessing methods and properties.
     12 *
     13 * @since 4.0.0
     14 */
     15class Basic_Subclass extends Basic_Object {}
  • tests/phpunit/includes/functions.php

    diff --git tests/phpunit/includes/functions.php tests/phpunit/includes/functions.php
    index 370d837..be95192 100644
    function _delete_all_posts() { 
    5858        }
    5959}
    6060
    61 class Basic_Object {
    62         private $foo = 'bar';
    63 
    64         public function __get( $name ) {
    65                 return $this->$name;
    66         }
    67 
    68         public function __set( $name, $value ) {
    69                 return $this->$name = $value;
    70         }
    71 
    72         public function __isset( $name ) {
    73                 return isset( $this->$name );
    74         }
    75 
    76         public function __unset( $name ) {
    77                 unset( $this->$name );
    78         }
    79 
    80         public function __call( $name, $arguments ) {
    81                 return call_user_func_array( array( $this, $name ), $arguments );
    82         }
    83 
    84         private function callMe() {
    85                 return 'maybe';
    86         }
    87 }
    88 
    89 class Basic_Subclass extends Basic_Object {}
    90 
    9161function _wp_die_handler( $message, $title = '', $args = array() ) {
    9262        if ( !$GLOBALS['_wp_die_disabled'] ) {
    9363                _wp_die_handler_txt( $message, $title, $args);
    function _upload_dir_no_subdir( $uploads ) { 
    147117
    148118/**
    149119 * Helper used with the `upload_dir` filter to set https upload URL.
    150  */ 
     120 */
    151121function _upload_dir_https( $uploads ) {
    152122        $uploads['url'] = str_replace( 'http://', 'https://', $uploads['url'] );
    153123        $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
  • tests/phpunit/tests/basic.php

    diff --git tests/phpunit/tests/basic.php tests/phpunit/tests/basic.php
    index f68fbeb..1225ae3 100644
     
    11<?php
     2
     3require_once dirname( dirname( __FILE__ ) ) . '/includes/class-basic-object.php';
     4require_once dirname( dirname( __FILE__ ) ) . '/includes/class-basic-subclass.php';
     5
    26/**
    37 * just make sure the test framework is working
    48 *