mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968]. See #52625. git-svn-id: https://develop.svn.wordpress.org/trunk@50969 602fd350-edb4-49c9-b593-d223f7449a82
74 lines
2.1 KiB
PHP
74 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* Test the `_wp_privacy_completed_request()` function.
|
|
*
|
|
* @package WordPress
|
|
* @subpackage UnitTests
|
|
* @since 4.9.6
|
|
*/
|
|
|
|
/**
|
|
* Tests_Privacy_wpPrivacyCompletedRequest class.
|
|
*
|
|
* @group privacy
|
|
* @covers ::_wp_privacy_completed_request
|
|
*
|
|
* @since 4.9.6
|
|
*/
|
|
class Tests_Privacy_wpPrivacyCompletedRequest extends WP_UnitTestCase {
|
|
/**
|
|
* Request ID
|
|
*
|
|
* @since 4.9.6
|
|
*
|
|
* @var int $request_id
|
|
*/
|
|
protected static $request_id;
|
|
|
|
/**
|
|
* Create fixtures.
|
|
*
|
|
* @param WP_UnitTest_Factory $factory Factory.
|
|
*/
|
|
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
|
|
self::$request_id = wp_create_user_request( 'requester@example.com', 'export_personal_data' );
|
|
}
|
|
|
|
/**
|
|
* The function should return error for invalid request ID.
|
|
*
|
|
* @ticket 43913
|
|
*/
|
|
public function test_wp_privacy_completed_request_should_return_error_for_invalid_request_id() {
|
|
$actual = _wp_privacy_completed_request( 0 );
|
|
$this->assertWPError( $actual );
|
|
$this->assertSame( 'privacy_request_error', $actual->get_error_code() );
|
|
|
|
$actual = _wp_privacy_completed_request( PHP_INT_MAX );
|
|
$this->assertWPError( $actual );
|
|
$this->assertSame( 'privacy_request_error', $actual->get_error_code() );
|
|
}
|
|
|
|
/**
|
|
* The function should mark a request as completed.
|
|
*
|
|
* @ticket 43913
|
|
*/
|
|
public function test_wp_privacy_completed_request_should_mark_request_completed() {
|
|
$this->assertSame( 'request-pending', get_post_status( self::$request_id ) );
|
|
$this->assertSame( self::$request_id, _wp_privacy_completed_request( self::$request_id ) );
|
|
$this->assertSame( 'request-completed', get_post_status( self::$request_id ) );
|
|
}
|
|
|
|
/**
|
|
* The function should log the request timestamp.
|
|
*
|
|
* @ticket 43913
|
|
*/
|
|
public function test_wp_privacy_completed_request_should_log_request_timestamp() {
|
|
$this->assertEmpty( get_post_meta( self::$request_id, '_wp_user_request_completed_timestamp', true ) );
|
|
$this->assertSame( self::$request_id, _wp_privacy_completed_request( self::$request_id ) );
|
|
$this->assertNotEmpty( get_post_meta( self::$request_id, '_wp_user_request_completed_timestamp', true ) );
|
|
}
|
|
}
|