Changeset 51478
- Timestamp:
- 07/22/2021 05:14:44 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/abstract-testcase.php
r51419 r51478 670 670 * Asserts that two values are equal, with whitespace differences discarded. 671 671 * 672 * @since UT (3.7.0) 673 * @since 5.9.0 Added the `$message` parameter. 674 * 672 675 * @param string $expected The expected value. 673 676 * @param string $actual The actual value. 674 */ 675 public function assertDiscardWhitespace( $expected, $actual ) { 676 $this->assertEquals( preg_replace( '/\s*/', '', $expected ), preg_replace( '/\s*/', '', $actual ) ); 677 * @param string $message Optional. Message to display when the assertion fails. 678 */ 679 public function assertDiscardWhitespace( $expected, $actual, $message = '' ) { 680 $this->assertEquals( preg_replace( '/\s*/', '', $expected ), preg_replace( '/\s*/', '', $actual, $message ) ); 677 681 } 678 682 … … 682 686 * @since 5.6.0 683 687 * @since 5.8.0 Added support for nested arrays. 688 * @since 5.9.0 Added the `$message` parameter. 684 689 * 685 690 * @param string|array $expected The expected value. 686 691 * @param string|array $actual The actual value. 687 */ 688 public function assertSameIgnoreEOL( $expected, $actual ) { 692 * @param string $message Optional. Message to display when the assertion fails. 693 */ 694 public function assertSameIgnoreEOL( $expected, $actual, $message = '' ) { 689 695 $expected = map_deep( 690 696 $expected, … … 701 707 ); 702 708 703 $this->assertSame( $expected, $actual );709 $this->assertSame( $expected, $actual, $message ); 704 710 } 705 711 … … 709 715 * @since 5.4.0 710 716 * @since 5.6.0 Turned into an alias for `::assertSameIgnoreEOL()`. 717 * @since 5.9.0 Added the `$message` parameter. 711 718 * 712 719 * @param string $expected The expected value. 713 720 * @param string $actual The actual value. 714 */ 715 public function assertEqualsIgnoreEOL( $expected, $actual ) { 716 $this->assertSameIgnoreEOL( $expected, $actual ); 721 * @param string $message Optional. Message to display when the assertion fails. 722 */ 723 public function assertEqualsIgnoreEOL( $expected, $actual, $message = '' ) { 724 $this->assertSameIgnoreEOL( $expected, $actual, $message ); 717 725 } 718 726 … … 721 729 * 722 730 * @since 5.6.0 723 * 724 * @param array $expected Expected array. 725 * @param array $actual Array to check. 726 */ 727 public function assertSameSets( $expected, $actual ) { 731 * @since 5.9.0 Added the `$message` parameter. 732 * 733 * @param array $expected Expected array. 734 * @param array $actual Array to check. 735 * @param string $message Optional. Message to display when the assertion fails. 736 */ 737 public function assertSameSets( $expected, $actual, $message = '' ) { 728 738 sort( $expected ); 729 739 sort( $actual ); 730 $this->assertSame( $expected, $actual );740 $this->assertSame( $expected, $actual, $message ); 731 741 } 732 742 … … 735 745 * 736 746 * @since 3.5.0 737 * 738 * @param array $expected Expected array. 739 * @param array $actual Array to check. 740 */ 741 public function assertEqualSets( $expected, $actual ) { 747 * @since 5.9.0 Added the `$message` parameter. 748 * 749 * @param array $expected Expected array. 750 * @param array $actual Array to check. 751 * @param string $message Optional. Message to display when the assertion fails. 752 */ 753 public function assertEqualSets( $expected, $actual, $message = '' ) { 742 754 sort( $expected ); 743 755 sort( $actual ); 744 $this->assertEquals( $expected, $actual );756 $this->assertEquals( $expected, $actual, $message ); 745 757 } 746 758 … … 749 761 * 750 762 * @since 5.6.0 751 * 752 * @param array $expected Expected array. 753 * @param array $actual Array to check. 754 */ 755 public function assertSameSetsWithIndex( $expected, $actual ) { 763 * @since 5.9.0 Added the `$message` parameter. 764 * 765 * @param array $expected Expected array. 766 * @param array $actual Array to check. 767 * @param string $message Optional. Message to display when the assertion fails. 768 */ 769 public function assertSameSetsWithIndex( $expected, $actual, $message = '' ) { 756 770 ksort( $expected ); 757 771 ksort( $actual ); 758 $this->assertSame( $expected, $actual );772 $this->assertSame( $expected, $actual, $message ); 759 773 } 760 774 … … 763 777 * 764 778 * @since 4.1.0 765 * 766 * @param array $expected Expected array. 767 * @param array $actual Array to check. 768 */ 769 public function assertEqualSetsWithIndex( $expected, $actual ) { 779 * @since 5.9.0 Added the `$message` parameter. 780 * 781 * @param array $expected Expected array. 782 * @param array $actual Array to check. 783 * @param string $message Optional. Message to display when the assertion fails. 784 */ 785 public function assertEqualSetsWithIndex( $expected, $actual, $message = '' ) { 770 786 ksort( $expected ); 771 787 ksort( $actual ); 772 $this->assertEquals( $expected, $actual );788 $this->assertEquals( $expected, $actual, $message ); 773 789 } 774 790 … … 777 793 * 778 794 * @since 4.8.0 779 * 780 * @param array $array Array to check. 781 */ 782 public function assertNonEmptyMultidimensionalArray( $array ) { 783 $this->assertIsArray( $array ); 784 $this->assertNotEmpty( $array ); 795 * @since 5.9.0 Added the `$message` parameter. 796 * 797 * @param array $array Array to check. 798 * @param string $message Optional. Message to display when the assertion fails. 799 */ 800 public function assertNonEmptyMultidimensionalArray( $array, $message = '' ) { 801 $this->assertIsArray( $array, $message . ' Value under test is not an array.' ); 802 $this->assertNotEmpty( $array, $message . ' Array is empty.' ); 785 803 786 804 foreach ( $array as $sub_array ) { 787 $this->assertIsArray( $sub_array );788 $this->assertNotEmpty( $sub_array );805 $this->assertIsArray( $sub_array, $message . ' Subitem of the array is not an array.' ); 806 $this->assertNotEmpty( $sub_array, $message . ' Subitem of the array is empty.' ); 789 807 } 790 808 }
Note: See TracChangeset
for help on using the changeset viewer.