Skip to content

Commit

Permalink
Mock our pantheon_upload_dir global so we can test against it
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzsequence committed Feb 8, 2024
1 parent 1ee5a46 commit bb57dfc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/phpunit/test-fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,30 @@
* Main Mu Plugin Test Case
*/
class Test_Fonts extends WP_UnitTestCase {
protected $_original_pantheon_upload_dir;

public function setUp(): void {
parent::setUp();
remove_all_filters( 'font_dir' );
remove_all_filters( 'pantheon_modify_fonts_dir' );

// Mock the global variable before each test
global $_pantheon_upload_dir;
$this->_original_pantheon_upload_dir = $_pantheon_upload_dir; // Backup original global if needed

// Manually set the global variable to a mocked value
$_pantheon_upload_dir = [
'basedir' => WP_CONTENT_DIR . '/uploads',
'baseurl' => 'http://example.org/wp-content/uploads',
];
}

public function tearDown(): void {
// Restore original global state after each test if necessary
global $_pantheon_upload_dir;
$_pantheon_upload_dir = $this->_original_pantheon_upload_dir;

parent::tearDown();
}

/**
Expand Down

0 comments on commit bb57dfc

Please sign in to comment.