Changeset 42987 for trunk/tests/phpunit/tests/comment.php
- Timestamp:
- 04/18/2018 10:54:23 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/comment.php
r42343 r42987 892 892 $this->assertSame( '1', $comment->comment_approved ); 893 893 } 894 895 /** 896 * Testing the `wp_comments_personal_data_exporter()` function. 897 * 898 * @ticket 43440 899 */ 900 public function test_wp_comments_personal_data_exporter() { 901 $args = array( 902 'comment_post_ID' => self::$post_id, 903 'comment_author' => 'Comment Author', 904 'comment_author_email' => 'personal@local.host', 905 'comment_author_url' => 'https://local.host/', 906 'comment_author_IP' => '192.168.0.1', 907 'comment_agent' => 'SOME_AGENT', 908 'comment_date' => '2018-03-28 20:05:00', 909 'comment_content' => 'Comment', 910 ); 911 912 $c = self::factory()->comment->create( $args ); 913 914 $actual = wp_comments_personal_data_exporter( $args['comment_author_email'] ); 915 $expected = $args; 916 917 $this->assertTrue( $actual['done'] ); 918 919 // Number of exported comments. 920 $this->assertSame( 1, count( $actual['data'] ) ); 921 922 // Number of exported comment properties. 923 $this->assertSame( 8, count( $actual['data'][0]['data'] ) ); 924 925 // Exported group. 926 $this->assertSame( 'comments', $actual['data'][0]['group_id'] ); 927 $this->assertSame( 'Comments', $actual['data'][0]['group_label'] ); 928 929 // Exported comment properties. 930 $this->assertSame( $expected['comment_author'], $actual['data'][0]['data'][0]['value'] ); 931 $this->assertSame( $expected['comment_author_email'], $actual['data'][0]['data'][1]['value'] ); 932 $this->assertSame( $expected['comment_author_url'], $actual['data'][0]['data'][2]['value'] ); 933 $this->assertSame( $expected['comment_author_IP'], $actual['data'][0]['data'][3]['value'] ); 934 $this->assertSame( $expected['comment_agent'], $actual['data'][0]['data'][4]['value'] ); 935 $this->assertSame( $expected['comment_date'], $actual['data'][0]['data'][5]['value'] ); 936 $this->assertSame( $expected['comment_content'], $actual['data'][0]['data'][6]['value'] ); 937 $this->assertSame( get_comment_link( $c ), $actual['data'][0]['data'][7]['value'] ); 938 } 939 940 /** 941 * Testing the `wp_comments_personal_data_exporter()` function for no comments found. 942 * 943 * @ticket 43440 944 */ 945 public function test_wp_comments_personal_data_exporter_no_comments_found() { 946 947 $actual = wp_comments_personal_data_exporter( 'nocommentsfound@local.host' ); 948 949 $expected = array( 950 'data' => array(), 951 'done' => true, 952 ); 953 954 $this->assertSame( $expected, $actual ); 955 } 956 957 /** 958 * Testing the `wp_comments_personal_data_exporter()` function for an empty comment property. 959 * 960 * @ticket 43440 961 */ 962 public function test_wp_comments_personal_data_exporter_empty_comment_prop() { 963 $args = array( 964 'comment_post_ID' => self::$post_id, 965 'comment_author' => 'Comment Author', 966 'comment_author_email' => 'personal@local.host', 967 'comment_author_url' => 'https://local.host/', 968 'comment_author_IP' => '192.168.0.1', 969 'comment_date' => '2018-03-28 20:05:00', 970 'comment_agent' => '', 971 'comment_content' => 'Comment', 972 ); 973 974 $c = self::factory()->comment->create( $args ); 975 976 $actual = wp_comments_personal_data_exporter( $args['comment_author_email'] ); 977 978 $this->assertTrue( $actual['done'] ); 979 980 // Number of exported comments. 981 $this->assertSame( 1, count( $actual['data'] ) ); 982 983 // Number of exported comment properties. 984 $this->assertSame( 7, count( $actual['data'][0]['data'] ) ); 985 } 986 987 /** 988 * Testing the `wp_comments_personal_data_exporter()` function with an empty second page. 989 * 990 * @ticket 43440 991 */ 992 public function test_wp_comments_personal_data_exporter_empty_second_page() { 993 $args = array( 994 'comment_post_ID' => self::$post_id, 995 'comment_author' => 'Comment Author', 996 'comment_author_email' => 'personal@local.host', 997 'comment_author_url' => 'https://local.host/', 998 'comment_author_IP' => '192.168.0.1', 999 'comment_date' => '2018-03-28 20:05:00', 1000 'comment_agent' => 'SOME_AGENT', 1001 'comment_content' => 'Comment', 1002 ); 1003 1004 $c = self::factory()->comment->create( $args ); 1005 1006 $actual = wp_comments_personal_data_exporter( $args['comment_author_email'], 2 ); 1007 1008 $this->assertTrue( $actual['done'] ); 1009 1010 // Number of exported comments. 1011 $this->assertSame( 0, count( $actual['data'] ) ); 1012 } 894 1013 }
Note: See TracChangeset
for help on using the changeset viewer.