Make WordPress Core

Changeset 55322


Ignore:
Timestamp:
02/13/2023 07:35:13 PM (17 months ago)
Author:
SergeyBiryukov
Message:

Tests: Declare the $post_id property in wp_comments_personal_data_exporter() tests.

Use the same approach in wp_comments_personal_data_eraser() for consistency and to minimize the number of fixtures created in each individual test.

Follow-up to [55319], [55321].

Props hellofromTonya.
See #56793.

Location:
trunk/tests/phpunit/tests/comment
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/wpCommentsPersonalDataEraser.php

    r55319 r55322  
    99class Tests_Comment_wpCommentsPersonalDataEraser extends WP_UnitTestCase {
    1010
     11    protected static $post_id;
     12
     13    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     14        self::$post_id = $factory->post->create();
     15    }
     16
    1117    /**
    1218     * The `wp_comments_personal_data_eraser()` function should erase user's comments.
     
    1622    public function test_wp_comments_personal_data_eraser() {
    1723
    18         $post_id = self::factory()->post->create();
    1924        $user_id = self::factory()->user->create();
    2025
    2126        $args       = array(
    2227            'user_id'              => $user_id,
    23             'comment_post_ID'      => $post_id,
     28            'comment_post_ID'      => self::$post_id,
    2429            'comment_author'       => 'Comment Author',
    2530            'comment_author_email' => 'personal@local.host',
     
    9095    public function test_wp_comments_personal_data_eraser_non_empty_first_page_output() {
    9196
    92         $post_id = self::factory()->post->create();
    93         $args    = array(
    94             'comment_post_ID'      => $post_id,
     97        $args = array(
     98            'comment_post_ID'      => self::$post_id,
    9599            'comment_author'       => 'Comment Author',
    96100            'comment_author_email' => 'personal@local.host',
     
    121125    public function test_wp_comments_personal_data_eraser_empty_second_page_output() {
    122126
    123         $post_id = self::factory()->post->create();
    124         $args    = array(
    125             'comment_post_ID'      => $post_id,
     127        $args = array(
     128            'comment_post_ID'      => self::$post_id,
    126129            'comment_author'       => 'Comment Author',
    127130            'comment_author_email' => 'personal@local.host',
     
    152155    public function test_wp_anonymize_comment_filter_to_prevent_comment_anonymization() {
    153156
    154         $post_id    = self::factory()->post->create();
    155157        $args       = array(
    156             'comment_post_ID'      => $post_id,
     158            'comment_post_ID'      => self::$post_id,
    157159            'comment_author'       => 'Comment Author',
    158160            'comment_author_email' => 'personal@local.host',
     
    188190    public function test_wp_anonymize_comment_filter_to_prevent_comment_anonymization_with_custom_message() {
    189191
    190         $post_id    = self::factory()->post->create();
    191192        $args       = array(
    192             'comment_post_ID'      => $post_id,
     193            'comment_post_ID'      => self::$post_id,
    193194            'comment_author'       => 'Comment Author',
    194195            'comment_author_email' => 'personal@local.host',
  • trunk/tests/phpunit/tests/comment/wpCommentsPersonalDataExporter.php

    r55321 r55322  
    88 */
    99class Tests_Comment_wpCommentsPersonalDataExporter extends WP_UnitTestCase {
     10
     11    protected static $post_id;
     12
     13    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     14        self::$post_id = $factory->post->create();
     15    }
    1016
    1117    /**
Note: See TracChangeset for help on using the changeset viewer.