Changeset 55016 for trunk/tests/phpunit/includes/abstract-testcase.php
- Timestamp:
- 12/25/2022 01:10:42 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/abstract-testcase.php
r54865 r55016 683 683 * @since 6.1.0 Added the `$replacement`, `$version`, and `$message` parameters. 684 684 * 685 * @param string $function 686 * @param string $replacement The function that should have been called.687 * @param string $version The version of WordPress that deprecated the function.688 * @param string $message Optional. A message regarding the change.689 */ 690 public function deprecated_function_run( $function , $replacement, $version, $message = '' ) {691 if ( ! isset( $this->caught_deprecated[ $function ] ) ) {685 * @param string $function_name The deprecated function. 686 * @param string $replacement The function that should have been called. 687 * @param string $version The version of WordPress that deprecated the function. 688 * @param string $message Optional. A message regarding the change. 689 */ 690 public function deprecated_function_run( $function_name, $replacement, $version, $message = '' ) { 691 if ( ! isset( $this->caught_deprecated[ $function_name ] ) ) { 692 692 switch ( current_action() ) { 693 693 case 'deprecated_function_run': … … 695 695 $message = sprintf( 696 696 'Function %1$s is deprecated since version %2$s! Use %3$s instead.', 697 $function ,697 $function_name, 698 698 $version, 699 699 $replacement … … 702 702 $message = sprintf( 703 703 'Function %1$s is deprecated since version %2$s with no alternative available.', 704 $function ,704 $function_name, 705 705 $version 706 706 ); … … 712 712 $message = sprintf( 713 713 'Function %1$s was called with an argument that is deprecated since version %2$s! %3$s', 714 $function ,714 $function_name, 715 715 $version, 716 716 $replacement … … 719 719 $message = sprintf( 720 720 'Function %1$s was called with an argument that is deprecated since version %2$s with no alternative available.', 721 $function ,721 $function_name, 722 722 $version 723 723 ); … … 729 729 $message = sprintf( 730 730 'File %1$s is deprecated since version %2$s! Use %3$s instead.', 731 $function ,731 $function_name, 732 732 $version, 733 733 $replacement … … 736 736 $message = sprintf( 737 737 'File %1$s is deprecated since version %2$s with no alternative available.', 738 $function ,738 $function_name, 739 739 $version 740 740 ) . ' ' . $message; … … 746 746 $message = sprintf( 747 747 'Hook %1$s is deprecated since version %2$s! Use %3$s instead.', 748 $function ,748 $function_name, 749 749 $version, 750 750 $replacement … … 753 753 $message = sprintf( 754 754 'Hook %1$s is deprecated since version %2$s with no alternative available.', 755 $function ,755 $function_name, 756 756 $version 757 757 ) . ' ' . $message; … … 760 760 } 761 761 762 $this->caught_deprecated[ $function ] = $message;762 $this->caught_deprecated[ $function_name ] = $message; 763 763 } 764 764 } … … 770 770 * @since 6.1.0 Added the `$message` and `$version` parameters. 771 771 * 772 * @param string $function The function to add.773 * @param string $message A message explaining what has been done incorrectly.774 * @param string $version The version of WordPress where the message was added.775 */ 776 public function doing_it_wrong_run( $function , $message, $version ) {777 if ( ! isset( $this->caught_doing_it_wrong[ $function ] ) ) {772 * @param string $function_name The function to add. 773 * @param string $message A message explaining what has been done incorrectly. 774 * @param string $version The version of WordPress where the message was added. 775 */ 776 public function doing_it_wrong_run( $function_name, $message, $version ) { 777 if ( ! isset( $this->caught_doing_it_wrong[ $function_name ] ) ) { 778 778 if ( $version ) { 779 779 $message .= ' ' . sprintf( '(This message was added in version %s.)', $version ); 780 780 } 781 781 782 $this->caught_doing_it_wrong[ $function ] = $message;782 $this->caught_doing_it_wrong[ $function_name ] = $message; 783 783 } 784 784 } … … 838 838 * @since 5.9.0 Added the `$message` parameter. 839 839 * 840 * @param object $ objectThe object to check.840 * @param object $actual The object to check. 841 841 * @param array $fields The fields to check. 842 842 * @param string $message Optional. Message to display when the assertion fails. 843 843 */ 844 public function assertEqualFields( $ object, $fields, $message = '' ) {845 $this->assertIsObject( $ object, $message . ' Passed $objectis not an object.' );844 public function assertEqualFields( $actual, $fields, $message = '' ) { 845 $this->assertIsObject( $actual, $message . ' Passed $actual is not an object.' ); 846 846 $this->assertIsArray( $fields, $message . ' Passed $fields is not an array.' ); 847 847 $this->assertNotEmpty( $fields, $message . ' Fields array is empty.' ); 848 848 849 849 foreach ( $fields as $field_name => $field_value ) { 850 $this->assertObjectHasAttribute( $field_name, $ object, $message . " Property $field_name does not exist on the object." );851 $this->assertSame( $field_value, $ object->$field_name, $message . " Value of property $field_name is not $field_value." );850 $this->assertObjectHasAttribute( $field_name, $actual, $message . " Property $field_name does not exist on the object." ); 851 $this->assertSame( $field_value, $actual->$field_name, $message . " Value of property $field_name is not $field_value." ); 852 852 } 853 853 } … … 1013 1013 * @since 5.9.0 Added the `$message` parameter. 1014 1014 * 1015 * @param array $a rrayArray to check.1015 * @param array $actual Array to check. 1016 1016 * @param string $message Optional. Message to display when the assertion fails. 1017 1017 */ 1018 public function assertNonEmptyMultidimensionalArray( $a rray, $message = '' ) {1019 $this->assertIsArray( $a rray, $message . ' Value under test is not an array.' );1020 $this->assertNotEmpty( $a rray, $message . ' Array is empty.' );1021 1022 foreach ( $a rrayas $sub_array ) {1018 public function assertNonEmptyMultidimensionalArray( $actual, $message = '' ) { 1019 $this->assertIsArray( $actual, $message . ' Value under test is not an array.' ); 1020 $this->assertNotEmpty( $actual, $message . ' Array is empty.' ); 1021 1022 foreach ( $actual as $sub_array ) { 1023 1023 $this->assertIsArray( $sub_array, $message . ' Subitem of the array is not an array.' ); 1024 1024 $this->assertNotEmpty( $sub_array, $message . ' Subitem of the array is empty.' );
Note: See TracChangeset
for help on using the changeset viewer.