Skip to content

Commit

Permalink
WP_Fonts_Library: split tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hellofromtonya committed Aug 16, 2023
1 parent b9d87ad commit bd91b81
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 55 deletions.
52 changes: 0 additions & 52 deletions phpunit/fonts-library/class-wp-fonts-library-test.php

This file was deleted.

7 changes: 4 additions & 3 deletions phpunit/fonts-library/wpFontFamily/uninstall-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public function test_should_return_error_when_font_not_found() {

// Test.
$actual = $font->uninstall();
$this->assertInstanceOf( WP_Error::class, $actual, 'WP_Error instance should have been returned' );
$this->assertWPError( $actual, 'WP_Error should have been returned' );
$this->assertSame(
array( 'font_family_not_found' => array( 'The font family could not be found.' ) ),
$actual->errors
$actual->errors,
'WP_Error should have "fonts_must_have_same_slug" error'
);
}

Expand All @@ -42,7 +43,7 @@ public function test_should_return_error_when_not_able_to_uninstall( $failure_to

// Test.
$actual = $font->uninstall();
$this->assertInstanceOf( WP_Error::class, $actual, 'WP_Error instance should be returned' );
$this->assertWPError( $actual, 'WP_Error should be returned' );
$this->assertSame(
array( 'font_family_not_deleted' => array( 'The font family could not be deleted.' ) ),
$actual->errors,
Expand Down
18 changes: 18 additions & 0 deletions phpunit/fonts-library/wpFontsLibrary/getFontsDir-test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Test WP_Fonts_Library::get_fonts_dir().
*
* @package WordPress
* @subpackage Fonts Library
*
* @group fonts
* @group fonts-library
*
* @covers WP_Fonts_Library::get_fonts_dir
*/
class Tests_Fonts_WpFontsLibrary_GetFontsDir extends WP_UnitTestCase {

public function test_get_fonts_dir() {
$this->assertStringEndsWith( '/wp-content/uploads/fonts', WP_Fonts_Library::get_fonts_dir() );
}
}
30 changes: 30 additions & 0 deletions phpunit/fonts-library/wpFontsLibrary/setUploadDir-test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Test WP_Fonts_Library::set_upload_dir().
*
* @package WordPress
* @subpackage Fonts Library
*
* @group fonts
* @group fonts-library
*
* @covers WP_Fonts_Library::set_upload_dir
*/
class Tests_Fonts_WpFontsLibrary_SetUploadDir extends WP_UnitTestCase {

public function test_should_set_fonts_upload_dir() {
$defaults = array(
'subdir' => '/abc',
'basedir' => '/var/www/html/wp-content/uploads',
'baseurl' => 'http://example.com/wp-content/uploads',
);
$expected = array(
'subdir' => '/fonts',
'basedir' => '/var/www/html/wp-content/uploads',
'baseurl' => 'http://example.com/wp-content/uploads',
'path' => '/var/www/html/wp-content/uploads/fonts',
'url' => 'http://example.com/wp-content/uploads/fonts',
);
$this->assertSame( $expected, WP_Fonts_Library::set_upload_dir( $defaults ) );
}
}

0 comments on commit bd91b81

Please sign in to comment.