Skip to content

Commit

Permalink
Cleaning up after testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pbking committed Mar 14, 2024
1 parent 136a9f8 commit 7d6a572
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/test-theme-fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,24 @@ public function test_copy_activated_fonts_to_theme() {
$this->assertEquals( 'file:./assets/fonts/open-sans-normal-400.ttf', $theme_data_after['typography']['fontFamilies']['theme'][1]['fontFace'][0]['src'] );
$this->assertTrue( file_exists( get_stylesheet_directory() . '/assets/fonts/open-sans-normal-400.ttf' ) );

$this->remove_test_theme( $test_theme_slug );
}

private function remove_test_theme( $theme_slug ) {
//TODO: Activate the default theme
//Delete the test theme
delete_theme( $test_theme_slug );
}

private function create_blank_theme() {

$test_theme_slug = 'create-block-theme-test-blank-theme-' . rand();
$request = new WP_REST_Request( 'POST', '/create-block-theme/v1/create-blank' );
$test_theme_slug = 'cbttesttheme';

delete_theme( $test_theme_slug );

$request = new WP_REST_Request( 'POST', '/create-block-theme/v1/create-blank' );
$request->set_param( 'name', $test_theme_slug );
$request->set_param( 'description', '' );
$request->set_param( 'uri', '' );
$request->set_param( 'author', '' );
$request->set_param( 'author_uri', '' );
$request->set_param( 'tags_custom', '' );
$request->set_param( 'subfolder', '' );

rest_do_request( $request );

return $test_theme_slug;
Expand All @@ -86,6 +85,9 @@ private function activate_font() {
$font_test_source = __DIR__ . '/data/fonts/OpenSans-Regular.ttf';
$font_test_destination = $font_dir['path'] . '/open-sans-normal-400.ttf';

if ( ! file_exists( $font_dir['path'] ) ) {
mkdir( $font_dir['path'] );
}
copy( $font_test_source, $font_test_destination );

$settings = array();
Expand Down

0 comments on commit 7d6a572

Please sign in to comment.