Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions tests/phpunit/tests/functions/wpPrivacyExportsDir.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* Tests for the wp_privacy_exports_dir function.
*
* @group functions.php
*
* @covers ::wp_privacy_exports_dir
*/
class Tests_Functions_wpPrivacyExportsDir extends WP_UnitTestCase {

/**
* @ticket 59710
*/
public function test_wp_privacy_exports_dir() {

$this->assertEquals( '/var/www/src/wp-content/uploads/wp-personal-data-exports/', wp_privacy_exports_dir() );
Comment on lines +15 to +16

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deriving the directory at runtime should allow the tests to run in other setups.

Suggested change
$this->assertEquals( '/var/www/src/wp-content/uploads/wp-personal-data-exports/', wp_privacy_exports_dir() );
$upload_dir = wp_upload_dir();
$expected = trailingslashit( $upload_dir['basedir'] ) . 'wp-personal-data-exports/';
$this->assertSame( $expected, wp_privacy_exports_dir() );

}

/**
* @ticket 59710
*/
public function test_wp_privacy_exports_dir_filtered() {

add_filter( 'wp_privacy_exports_dir', array( $this, 'filter_wp_privacy_exports_dir' ) );

$expected_dir = '/wp-personal-data-exports-dir/';
$actual_dir = wp_privacy_exports_dir();
$this->assertEquals( $expected_dir, $actual_dir );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->assertEquals( $expected_dir, $actual_dir );
$this->assertSame( $expected_dir, $actual_dir );


remove_filter( 'wp_privacy_exports_dir', array( $this, 'filter_wp_privacy_exports_dir' ) );
}

/**
* Filter for test
*
* @param string $dir
*/
public function filter_wp_privacy_exports_dir( $dir ) {

return '/wp-personal-data-exports-dir/';
}
}
Loading