diff --git a/lib/compat/wordpress-6.2/script-loader.php b/lib/compat/wordpress-6.2/script-loader.php
index 4e4ae3ef418a9b..6ad6b2b9ec78bd 100644
--- a/lib/compat/wordpress-6.2/script-loader.php
+++ b/lib/compat/wordpress-6.2/script-loader.php
@@ -131,7 +131,7 @@ function gutenberg_resolve_assets_override() {
* Generate font @font-face styles for the site editor iframe.
* Use the registered font families for printing.
*/
- if ( class_exists( 'WP_Web_Fonts' ) ) {
+ if ( class_exists( 'WP_Fonts' ) ) {
$wp_fonts = wp_fonts();
$registered = $wp_fonts->get_registered_font_families();
if ( ! empty( $registered ) ) {
diff --git a/lib/experimental/fonts-api/class-wp-fonts.php b/lib/experimental/fonts-api/class-wp-fonts.php
new file mode 100644
index 00000000000000..6a06de8f4c86a5
--- /dev/null
+++ b/lib/experimental/fonts-api/class-wp-fonts.php
@@ -0,0 +1,744 @@
+ 'local',
+ 'font-family' => '',
+ 'font-style' => 'normal',
+ 'font-weight' => '400',
+ 'font-display' => 'fallback',
+ );
+
+ /**
+ * Constructor.
+ *
+ * @since X.X.X
+ */
+ public function __construct() {
+ /**
+ * Filters the font variation's property defaults.
+ *
+ * @since X.X.X
+ *
+ * @param array $defaults {
+ * An array of required font properties and defaults.
+ *
+ * @type string $provider The provider ID. Default 'local'.
+ * @type string $font-family The font-family property. Default empty string.
+ * @type string $font-style The font-style property. Default 'normal'.
+ * @type string $font-weight The font-weight property. Default '400'.
+ * @type string $font-display The font-display property. Default 'fallback'.
+ * }
+ */
+ $this->variation_property_defaults = apply_filters( 'wp_font_variation_defaults', $this->variation_property_defaults );
+
+ /**
+ * Fires when the WP_Fonts instance is initialized.
+ *
+ * @since X.X.X
+ *
+ * @param WP_Fonts $wp_fonts WP_Fonts instance (passed by reference).
+ */
+ do_action_ref_array( 'wp_default_fonts', array( &$this ) );
+ }
+
+ /**
+ * Get the list of registered providers.
+ *
+ * @since X.X.X
+ *
+ * @return array $providers {
+ * An associative array of registered providers, keyed by their unique ID.
+ *
+ * @type string $provider_id => array {
+ * An associate array of provider's class name and fonts.
+ *
+ * @type string $class Fully qualified name of the provider's class.
+ * @type string[] $fonts An array of enqueued font handles for this provider.
+ * }
+ * }
+ */
+ public function get_providers() {
+ return $this->providers;
+ }
+
+ /**
+ * Register a provider.
+ *
+ * @since X.X.X
+ *
+ * @param string $provider_id The provider's unique ID.
+ * @param string $class The provider class name.
+ * @return bool True if successfully registered, else false.
+ */
+ public function register_provider( $provider_id, $class ) {
+ if ( empty( $provider_id ) || empty( $class ) || ! class_exists( $class ) ) {
+ return false;
+ }
+
+ $this->providers[ $provider_id ] = array(
+ 'class' => $class,
+ 'fonts' => array(),
+ );
+ return true;
+ }
+
+ /**
+ * Get the list of all registered font family handles.
+ *
+ * @since X.X.X
+ *
+ * @return string[]
+ */
+ public function get_registered_font_families() {
+ $font_families = array();
+ foreach ( $this->registered as $handle => $obj ) {
+ if ( $obj->extra['is_font_family'] ) {
+ $font_families[] = $handle;
+ }
+ }
+ return $font_families;
+ }
+
+ /**
+ * Get the list of all registered font families and their variations.
+ *
+ * @since X.X.X
+ *
+ * @return string[]
+ */
+ public function get_registered() {
+ return array_keys( $this->registered );
+ }
+
+ /**
+ * Get the list of enqueued font families and their variations.
+ *
+ * @since X.X.X
+ *
+ * @return array[]
+ */
+ public function get_enqueued() {
+ return $this->queue;
+ }
+
+ /**
+ * Registers a font family.
+ *
+ * @since X.X.X
+ *
+ * @param string $font_family Font family name to register.
+ * @return string|null Font family handle when registration successes. Null on failure.
+ */
+ public function add_font_family( $font_family ) {
+ $font_family_handle = WP_Fonts_Utils::convert_font_family_into_handle( $font_family );
+ if ( ! $font_family_handle ) {
+ return null;
+ }
+
+ if ( isset( $this->registered[ $font_family_handle ] ) ) {
+ return $font_family_handle;
+ }
+
+ $registered = $this->add( $font_family_handle, false );
+ if ( ! $registered ) {
+ return null;
+ }
+
+ $this->add_data( $font_family_handle, 'font-properties', array( 'font-family' => $font_family ) );
+ $this->add_data( $font_family_handle, 'is_font_family', true );
+
+ return $font_family_handle;
+ }
+
+ /**
+ * Removes a font family and all registered variations.
+ *
+ * @since X.X.X
+ *
+ * @param string $font_family_handle The font family to remove.
+ */
+ public function remove_font_family( $font_family_handle ) {
+ if ( ! isset( $this->registered[ $font_family_handle ] ) ) {
+ return;
+ }
+
+ $variations = $this->registered[ $font_family_handle ]->deps;
+
+ foreach ( $variations as $variation ) {
+ $this->remove( $variation );
+ }
+
+ $this->remove( $font_family_handle );
+ }
+
+ /**
+ * Add a variation to an existing family or register family if none exists.
+ *
+ * @since X.X.X
+ *
+ * @param string $font_family_handle The font family's handle for this variation.
+ * @param array $variation An array of variation properties to add.
+ * @param string $variation_handle Optional. The variation's handle. When none is provided, the
+ * handle will be dynamically generated.
+ * Default empty string.
+ * @return string|null Variation handle on success. Else null.
+ */
+ public function add_variation( $font_family_handle, array $variation, $variation_handle = '' ) {
+ if ( ! WP_Fonts_Utils::is_defined( $font_family_handle ) ) {
+ trigger_error( 'Font family handle must be a non-empty string.' );
+ return null;
+ }
+
+ // When there is a variation handle, check it.
+ if ( '' !== $variation_handle && ! WP_Fonts_Utils::is_defined( $variation_handle ) ) {
+ trigger_error( 'Variant handle must be a non-empty string.' );
+ return null;
+ }
+
+ // Register the font family when it does not yet exist.
+ if ( ! isset( $this->registered[ $font_family_handle ] ) ) {
+ if ( ! $this->add_font_family( $font_family_handle ) ) {
+ return null;
+ }
+ }
+
+ $variation = $this->validate_variation( $variation );
+
+ // Variation validation failed.
+ if ( ! $variation ) {
+ return null;
+ }
+
+ // When there's no variation handle, attempt to create one.
+ if ( '' === $variation_handle ) {
+ $variation_handle = WP_Fonts_Utils::convert_variation_into_handle( $font_family_handle, $variation );
+ if ( is_null( $variation_handle ) ) {
+ return null;
+ }
+ }
+
+ // Bail out if the variant is already registered.
+ if ( $this->is_variation_registered( $font_family_handle, $variation_handle ) ) {
+ return $variation_handle;
+ }
+
+ $variation_src = array_key_exists( 'src', $variation ) ? $variation['src'] : false;
+ $result = $this->add( $variation_handle, $variation_src );
+
+ // Bail out if the registration failed.
+ if ( ! $result ) {
+ return null;
+ }
+
+ $this->add_data( $variation_handle, 'font-properties', $variation );
+ $this->add_data( $variation_handle, 'is_font_family', false );
+
+ // Add the font variation as a dependency to the registered font family.
+ $this->add_dependency( $font_family_handle, $variation_handle );
+
+ $this->providers[ $variation['provider'] ]['fonts'][] = $variation_handle;
+
+ return $variation_handle;
+ }
+
+ /**
+ * Removes a variation.
+ *
+ * @since X.X.X
+ *
+ * @param string $font_family_handle The font family for this variation.
+ * @param string $variation_handle The variation's handle to remove.
+ */
+ public function remove_variation( $font_family_handle, $variation_handle ) {
+ if ( isset( $this->registered[ $variation_handle ] ) ) {
+ $this->remove( $variation_handle );
+ }
+
+ if ( ! $this->is_variation_registered( $font_family_handle, $variation_handle ) ) {
+ return;
+ }
+
+ // Remove the variation as a dependency from its font family.
+ $this->registered[ $font_family_handle ]->deps = array_values(
+ array_diff(
+ $this->registered[ $font_family_handle ]->deps,
+ array( $variation_handle )
+ )
+ );
+ }
+
+ /**
+ * Checks if the variation is registered.
+ *
+ * @since X.X.X
+ *
+ * @param string $font_family_handle The font family's handle for this variation.
+ * @param string $variation_handle Variation's handle.
+ * @return bool True when registered to the given font family. Else false.
+ */
+ private function is_variation_registered( $font_family_handle, $variation_handle ) {
+ if ( ! isset( $this->registered[ $font_family_handle ] ) ) {
+ return false;
+ }
+
+ return in_array( $variation_handle, $this->registered[ $font_family_handle ]->deps, true );
+ }
+
+ /**
+ * Adds a variation as a dependency to the given font family.
+ *
+ * @since X.X.X
+ *
+ * @param string $font_family_handle The font family's handle for this variation.
+ * @param string $variation_handle The variation's handle.
+ */
+ private function add_dependency( $font_family_handle, $variation_handle ) {
+ $this->registered[ $font_family_handle ]->deps[] = $variation_handle;
+ }
+
+ /**
+ * Validates and sanitizes a variation.
+ *
+ * @since X.X.X
+ *
+ * @param array $variation Variation properties to add.
+ * @return false|array Validated variation on success. Else, false.
+ */
+ private function validate_variation( $variation ) {
+ $variation = wp_parse_args( $variation, $this->variation_property_defaults );
+
+ // Check the font-family.
+ if ( empty( $variation['font-family'] ) || ! is_string( $variation['font-family'] ) ) {
+ trigger_error( 'Webfont font-family must be a non-empty string.' );
+ return false;
+ }
+
+ // Local fonts need a "src".
+ if ( 'local' === $variation['provider'] ) {
+ // Make sure that local fonts have 'src' defined.
+ if ( empty( $variation['src'] ) || ( ! is_string( $variation['src'] ) && ! is_array( $variation['src'] ) ) ) {
+ trigger_error( 'Webfont src must be a non-empty string or an array of strings.' );
+ return false;
+ }
+ } elseif ( ! isset( $this->providers[ $variation['provider'] ] ) ) {
+ trigger_error( sprintf( 'The provider "%s" is not registered', $variation['provider'] ) );
+ return false;
+ } elseif ( ! class_exists( $this->providers[ $variation['provider'] ]['class'] ) ) {
+ trigger_error( sprintf( 'The provider class "%s" does not exist', $variation['provider'] ) );
+ return false;
+ }
+
+ // Validate the 'src' property.
+ if ( ! empty( $variation['src'] ) ) {
+ foreach ( (array) $variation['src'] as $src ) {
+ if ( empty( $src ) || ! is_string( $src ) ) {
+ trigger_error( 'Each font src must be a non-empty string.' );
+ return false;
+ }
+ }
+ }
+
+ // Check the font-weight.
+ if ( ! is_string( $variation['font-weight'] ) && ! is_int( $variation['font-weight'] ) ) {
+ trigger_error( 'Webfont font-weight must be a properly formatted string or integer.' );
+ return false;
+ }
+
+ // Check the font-display.
+ if ( ! in_array( $variation['font-display'], array( 'auto', 'block', 'fallback', 'swap', 'optional' ), true ) ) {
+ $variation['font-display'] = 'fallback';
+ }
+
+ $valid_props = array(
+ 'ascent-override',
+ 'descent-override',
+ 'font-display',
+ 'font-family',
+ 'font-stretch',
+ 'font-style',
+ 'font-weight',
+ 'font-variant',
+ 'font-feature-settings',
+ 'font-variation-settings',
+ 'line-gap-override',
+ 'size-adjust',
+ 'src',
+ 'unicode-range',
+
+ // Exceptions.
+ 'provider',
+ );
+
+ foreach ( $variation as $prop => $value ) {
+ if ( ! in_array( $prop, $valid_props, true ) ) {
+ unset( $variation[ $prop ] );
+ }
+ }
+
+ return $variation;
+ }
+
+ /**
+ * Processes the items and dependencies.
+ *
+ * Processes the items passed to it or the queue, and their dependencies.
+ *
+ * @since X.X.X
+ *
+ * @param string|string[]|bool $handles Optional. Items to be processed: queue (false),
+ * single item (string), or multiple items (array of strings).
+ * Default false.
+ * @param int|false $group Optional. Group level: level (int), no group (false).
+ *
+ * @return array|string[] Array of font handles that have been processed.
+ * An empty array if none were processed.
+ */
+ public function do_items( $handles = false, $group = false ) {
+ $handles = $this->prepare_handles_for_printing( $handles );
+
+ if ( empty( $handles ) ) {
+ return $this->done;
+ }
+
+ $this->all_deps( $handles );
+ if ( empty( $this->to_do ) ) {
+ return $this->done;
+ }
+
+ $this->to_do_keyed_handles = array_flip( $this->to_do );
+
+ foreach ( $this->get_providers() as $provider_id => $provider ) {
+ // Alert and skip if the provider class does not exist.
+ if ( ! class_exists( $provider['class'] ) ) {
+ /* translators: %s is the provider name. */
+ trigger_error(
+ sprintf(
+ 'Class "%s" not found for "%s" font provider',
+ $provider['class'],
+ $provider_id
+ )
+ );
+ continue;
+ }
+
+ $this->do_item( $provider_id, $group );
+ }
+
+ $this->process_font_families_after_printing( $handles );
+
+ return $this->done;
+ }
+
+ /**
+ * Prepares the given handles for printing.
+ *
+ * @since X.X.X
+ *
+ * @param string|string[]|bool $handles Optional. Handles to prepare.
+ * Default false.
+ * @return array Array of handles.
+ */
+ private function prepare_handles_for_printing( $handles = false ) {
+ if ( false !== $handles ) {
+ $handles = $this->validate_handles( $handles );
+ // Bail out when invalid.
+ if ( empty( $handles ) ) {
+ return array();
+ }
+ }
+
+ // Use the enqueued queue.
+ if ( empty( $handles ) ) {
+ if ( empty( $this->queue ) ) {
+ return array();
+ }
+ $handles = $this->queue;
+ }
+
+ return $handles;
+ }
+
+ /**
+ * Validates handle(s) to ensure each is a non-empty string.
+ *
+ * @since X.X.X
+ *
+ * @param string|string[] $handles Handles to prepare.
+ * @return string[]|null Array of handles on success. Else null.
+ */
+ private function validate_handles( $handles ) {
+ // Validate each element is a non-empty string handle.
+ $handles = array_filter( (array) $handles, array( WP_Fonts_Utils::class, 'is_defined' ) );
+
+ if ( empty( $handles ) ) {
+ trigger_error( 'Handles must be a non-empty string or array of non-empty strings' );
+ return null;
+ }
+
+ return $handles;
+ }
+
+ /**
+ * Invokes each provider to process and print its styles.
+ *
+ * @since X.X.X
+ *
+ * @see WP_Dependencies::do_item()
+ *
+ * @param string $provider_id The provider to process.
+ * @param int|false $group Not used.
+ * @return bool
+ */
+ public function do_item( $provider_id, $group = false ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
+ // Bail out if the provider is not registered.
+ if ( ! isset( $this->providers[ $provider_id ] ) ) {
+ return false;
+ }
+
+ $font_handles = $this->get_enqueued_fonts_for_provider( $provider_id );
+ if ( empty( $font_handles ) ) {
+ return false;
+ }
+
+ $properties_by_font = $this->get_font_properties_for_provider( $font_handles );
+ if ( empty( $properties_by_font ) ) {
+ return false;
+ }
+
+ // Invoke provider to print its styles.
+ $provider = $this->get_provider_instance( $provider_id );
+ $provider->set_fonts( $properties_by_font );
+ $provider->print_styles();
+
+ // Clean up.
+ $this->update_queues_for_printed_fonts( $font_handles );
+
+ return true;
+ }
+
+ /**
+ * Retrieves a list of enqueued font variations for a provider.
+ *
+ * @since X.X.X
+ *
+ * @param string $provider_id The provider to process.
+ * @return array[] Webfonts organized by providers.
+ */
+ private function get_enqueued_fonts_for_provider( $provider_id ) {
+ $providers = $this->get_providers();
+
+ if ( empty( $providers[ $provider_id ] ) ) {
+ return array();
+ }
+
+ return array_intersect(
+ $providers[ $provider_id ]['fonts'],
+ $this->to_do
+ );
+ }
+
+ /**
+ * Gets a list of font properties for each of the given font handles.
+ *
+ * @since X.X.X
+ *
+ * @param array $font_handles Font handles to get properties.
+ * @return array A list of fonts with each font's properties.
+ */
+ private function get_font_properties_for_provider( array $font_handles ) {
+ $font_properties = array();
+
+ foreach ( $font_handles as $font_handle ) {
+ $properties = $this->get_data( $font_handle, 'font-properties' );
+ if ( ! $properties ) {
+ continue;
+ }
+ $font_properties[ $font_handle ] = $properties;
+ }
+
+ return $font_properties;
+ }
+
+ /**
+ * Gets the instance of the provider from the WP_Webfonts::$provider_instance store.
+ *
+ * @since X.X.X
+ *
+ * @param string $provider_id The provider to get.
+ * @return object Instance of the provider.
+ */
+ private function get_provider_instance( $provider_id ) {
+ if ( ! isset( $this->provider_instances[ $provider_id ] ) ) {
+ $this->provider_instances[ $provider_id ] = new $this->providers[ $provider_id ]['class']();
+ }
+ return $this->provider_instances[ $provider_id ];
+ }
+
+ /**
+ * Update queues for the given printed fonts.
+ *
+ * @since X.X.X
+ *
+ * @param array $font_handles Font handles to get properties.
+ */
+ private function update_queues_for_printed_fonts( array $font_handles ) {
+ foreach ( $font_handles as $font_handle ) {
+ $this->set_as_done( $font_handle );
+ $this->remove_from_to_do_queues( $font_handle );
+ }
+ }
+
+ /**
+ * Processes the font families after printing the variations.
+ *
+ * For each queued font family:
+ *
+ * a. if any of their variations were printed, the font family is added to the `done` list.
+ * b. removes each from the to_do queues.
+ *
+ * @since X.X.X
+ *
+ * @param array $handles Handles to process.
+ */
+ private function process_font_families_after_printing( array $handles ) {
+ foreach ( $handles as $handle ) {
+ if (
+ ! $this->get_data( $handle, 'is_font_family' ) ||
+ ! isset( $this->to_do_keyed_handles[ $handle ] )
+ ) {
+ continue;
+ }
+ $font_family = $this->registered[ $handle ];
+
+ // Add the font family to `done` list if any of its variations were printed.
+ if ( ! empty( $font_family->deps ) ) {
+ $processed = array_intersect( $font_family->deps, $this->done );
+ if ( ! empty( $processed ) ) {
+ $this->set_as_done( $handle );
+ }
+ }
+
+ $this->remove_from_to_do_queues( $handle );
+ }
+ }
+
+ /**
+ * Removes the handle from the `to_do` and `to_do_keyed_handles` lists.
+ *
+ * @since X.X.X
+ *
+ * @param string $handle Handle to remove.
+ */
+ private function remove_from_to_do_queues( $handle ) {
+ unset(
+ $this->to_do[ $this->to_do_keyed_handles[ $handle ] ],
+ $this->to_do_keyed_handles[ $handle ]
+ );
+ }
+
+ /**
+ * Sets the given handle to done by adding it to the `done` list.
+ *
+ * @since X.X.X
+ *
+ * @param string $handle Handle to set as done.
+ */
+ private function set_as_done( $handle ) {
+ if ( ! is_array( $this->done ) ) {
+ $this->done = array();
+ }
+ $this->done[] = $handle;
+ }
+
+ /**
+ * Converts the font family and its variations into theme.json structural format.
+ *
+ * @since X.X.X
+ *
+ * @param string $font_family_handle Font family to convert.
+ * @return array Webfonts in theme.json structural format.
+ */
+ public function to_theme_json( $font_family_handle ) {
+ if ( ! isset( $this->registered[ $font_family_handle ] ) ) {
+ return array();
+ }
+
+ $font_family_name = $this->registered[ $font_family_handle ]->extra['font-properties']['font-family'];
+ $theme_json_format = array(
+ 'fontFamily' => str_contains( $font_family_name, ' ' ) ? "'{$font_family_name}'" : $font_family_name,
+ 'name' => $font_family_name,
+ 'slug' => $font_family_handle,
+ 'fontFace' => array(),
+ );
+
+ foreach ( $this->registered[ $font_family_handle ]->deps as $variation_handle ) {
+ if ( ! isset( $this->registered[ $variation_handle ] ) ) {
+ continue;
+ }
+
+ $variation_obj = $this->registered[ $variation_handle ];
+ $variation_properties = array( 'origin' => 'gutenberg_wp_fonts_api' );
+ foreach ( $variation_obj->extra['font-properties'] as $property_name => $property_value ) {
+ $property_in_camelcase = lcfirst( str_replace( '-', '', ucwords( $property_name, '-' ) ) );
+ $variation_properties[ $property_in_camelcase ] = $property_value;
+ }
+ $theme_json_format['fontFace'][ $variation_obj->handle ] = $variation_properties;
+ }
+
+ return $theme_json_format;
+ }
+}
diff --git a/lib/experimental/fonts-api/class-wp-web-fonts.php b/lib/experimental/fonts-api/deprecations/class-wp-web-fonts.php
similarity index 96%
rename from lib/experimental/fonts-api/class-wp-web-fonts.php
rename to lib/experimental/fonts-api/deprecations/class-wp-web-fonts.php
index 83b0e29476b770..bdf06bb317e3a9 100644
--- a/lib/experimental/fonts-api/class-wp-web-fonts.php
+++ b/lib/experimental/fonts-api/deprecations/class-wp-web-fonts.php
@@ -14,60 +14,19 @@
/**
* Class WP_Web_Fonts
*
- * @since X.X.X
+ * @since GB 14.9.1
+ * @deprecated GB 15.1 Use WP_Fonts instead.
*/
class WP_Web_Fonts extends WP_Webfonts {
- /**
- * An array of registered providers.
- *
- * @since X.X.X
- *
- * @var array
- */
- private $providers = array();
-
- /**
- * The flipped $to_do array of web font handles.
- *
- * Used for a faster lookup of the web font handles.
- *
- * @since X.X.X
- *
- * @var string[]
- */
- private $to_do_keyed_handles;
-
- /**
- * Provider instance store, keyed by provider ID.
- *
- * @since X.X.X
- *
- * @var array
- */
- private $provider_instances = array();
-
- /**
- * Variation property defaults.
- *
- * @since X.X.X
- *
- * @var array
- */
- private $variation_property_defaults = array(
- 'provider' => 'local',
- 'font-family' => '',
- 'font-style' => 'normal',
- 'font-weight' => '400',
- 'font-display' => 'fallback',
- );
-
/**
* Constructor.
*
* @since X.X.X
*/
public function __construct() {
+ _deprecated_function( __METHOD__, 'GB 15.1', 'WP_Fonts' );
+
/**
* Filters the web font variation's property defaults.
*
diff --git a/lib/experimental/fonts-api/deprecations/class-wp-webfonts-provider.php b/lib/experimental/fonts-api/deprecations/class-wp-webfonts-provider.php
index b09c5496e6543f..5b7f5ece335b11 100644
--- a/lib/experimental/fonts-api/deprecations/class-wp-webfonts-provider.php
+++ b/lib/experimental/fonts-api/deprecations/class-wp-webfonts-provider.php
@@ -61,6 +61,6 @@ public function set_webfonts( array $fonts ) {
*/
public function set_fonts( array $fonts ) {
parent::set_fonts( $fonts );
- $this->webfonts = $this->fonts;;
+ $this->webfonts = $this->fonts;
}
}
diff --git a/lib/experimental/fonts-api/fonts-api.php b/lib/experimental/fonts-api/fonts-api.php
index 78307ba418406c..49b45392d3306a 100644
--- a/lib/experimental/fonts-api/fonts-api.php
+++ b/lib/experimental/fonts-api/fonts-api.php
@@ -13,15 +13,15 @@
*
* @since X.X.X
*
- * @global WP_Web_Fonts $wp_fonts
+ * @global WP_Fonts $wp_fonts
*
- * @return WP_Web_Fonts WP_Web_Fonts instance.
+ * @return WP_Fonts WP_Fonts instance.
*/
function wp_fonts() {
global $wp_fonts;
- if ( ! ( $wp_fonts instanceof WP_Web_Fonts ) ) {
- $wp_fonts = new WP_Web_Fonts();
+ if ( ! ( $wp_fonts instanceof WP_Fonts ) ) {
+ $wp_fonts = new WP_Fonts();
$wp_fonts->register_provider( 'local', 'WP_Fonts_Provider_Local' );
}
@@ -191,7 +191,7 @@ function wp_print_fonts( $handles = false ) {
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
- if ( ! ( $wp_fonts instanceof WP_Web_Fonts ) ) {
+ if ( ! ( $wp_fonts instanceof WP_Fonts ) ) {
if ( ! $handles ) {
return array(); // No need to instantiate if nothing is there.
}
diff --git a/lib/load.php b/lib/load.php
index e8d09183fee7a6..3ef152e6416e7f 100644
--- a/lib/load.php
+++ b/lib/load.php
@@ -104,7 +104,7 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/experimental/fonts-api/deprecations/class-wp-webfonts.php';
require __DIR__ . '/experimental/fonts-api/class-wp-fonts-utils.php';
require __DIR__ . '/experimental/fonts-api/register-fonts-from-theme-json.php';
-require __DIR__ . '/experimental/fonts-api/class-wp-web-fonts.php';
+require __DIR__ . '/experimental/fonts-api/class-wp-fonts.php';
require __DIR__ . '/experimental/fonts-api/class-wp-fonts-provider-local.php';
require __DIR__ . '/experimental/fonts-api/fonts-api.php';
diff --git a/phpunit/fonts-api/wp-fonts-testcase.php b/phpunit/fonts-api/wp-fonts-testcase.php
index 266325c422e991..e76a81590f9544 100644
--- a/phpunit/fonts-api/wp-fonts-testcase.php
+++ b/phpunit/fonts-api/wp-fonts-testcase.php
@@ -15,9 +15,9 @@ abstract class WP_Fonts_TestCase extends WP_UnitTestCase {
use WP_Fonts_Tests_Datasets;
/**
- * Original WP_Web_Fonts instance, before the tests.
+ * Original WP_Fonts instance, before the tests.
*
- * @var WP_Web_Fonts
+ * @var WP_Fonts
*/
private $old_wp_fonts;
@@ -56,7 +56,7 @@ public function tear_down() {
}
protected function set_up_mock( $method ) {
- $mock = $this->setup_object_mock( $method, WP_Web_Fonts::class );
+ $mock = $this->setup_object_mock( $method, WP_Fonts::class );
// Set the global.
$GLOBALS['wp_fonts'] = $mock;
@@ -81,7 +81,7 @@ protected function get_registered() {
}
protected function get_variations( $font_family, $wp_fonts = null ) {
- if ( ! ( $wp_fonts instanceof WP_Web_Fonts ) ) {
+ if ( ! ( $wp_fonts instanceof WP_Fonts ) ) {
$wp_fonts = wp_fonts();
}
@@ -96,7 +96,7 @@ protected function get_queued_before_register( $wp_fonts = null ) {
return $this->get_property_value( 'queued_before_register', WP_Dependencies::class, $wp_fonts );
}
- protected function get_reflection_property( $property_name, $class = 'WP_Web_Fonts' ) {
+ protected function get_reflection_property( $property_name, $class = 'WP_Fonts' ) {
$property = new ReflectionProperty( $class, $property_name );
$property->setAccessible( true );
@@ -135,7 +135,7 @@ protected function get_property_key( $class, $property_name ) {
* @return ReflectionMethod Instance of the method, ie to invoke it in the test.
*/
protected function get_reflection_method( $method_name ) {
- $method = new ReflectionMethod( WP_Web_Fonts::class, $method_name );
+ $method = new ReflectionMethod( WP_Fonts::class, $method_name );
$method->setAccessible( true );
return $method;
@@ -144,11 +144,11 @@ protected function get_reflection_method( $method_name ) {
/**
* Sets up multiple font family and variation mocks.
*
- * @param array $inputs Array of array( font-family => variations ) to setup.
- * @param WP_Web_Fonts $wp_fonts Instance of WP_Web_Fonts.
+ * @param array $inputs Array of array( font-family => variations ) to setup.
+ * @param WP_Fonts $wp_fonts Instance of WP_Fonts.
* @return stdClass[] Array of registered mocks.
*/
- protected function setup_registration_mocks( array $inputs, WP_Web_Fonts $wp_fonts ) {
+ protected function setup_registration_mocks( array $inputs, WP_Fonts $wp_fonts ) {
$mocks = array();
$build_mock = function ( $font_family, $is_font_family = false ) use ( &$mocks, $wp_fonts ) {
@@ -187,12 +187,12 @@ protected function setup_registration_mocks( array $inputs, WP_Web_Fonts $wp_fon
/**
* Register one or more font-family and its variations to set up a test.
*
- * @param string $font_family Font family to test.
- * @param array $variations Variations.
- * @param WP_Web_Fonts|null $wp_fonts Optional. Instance of the WP_Web_Fonts.
+ * @param string $font_family Font family to test.
+ * @param array $variations Variations.
+ * @param WP_Fonts|null $wp_fonts Optional. Instance of the WP_Fonts.
*/
protected function setup_register( $font_family, $variations, $wp_fonts = null ) {
- if ( ! ( $wp_fonts instanceof WP_Web_Fonts ) ) {
+ if ( ! ( $wp_fonts instanceof WP_Fonts ) ) {
$wp_fonts = wp_fonts();
}
@@ -207,18 +207,18 @@ protected function setup_register( $font_family, $variations, $wp_fonts = null )
}
/**
- * Sets up the WP_Web_Fonts::$provider property.
+ * Sets up the WP_Fonts::$provider property.
*
- * @param WP_Web_Fonts $wp_fonts Instance of WP_Web_Fonts.
+ * @param WP_Fonts $wp_fonts Instance of WP_Fonts.
* @param string|array $provider Provider ID when string. Else provider definition with 'id' and 'class' keys.
* @param array $font_handles Optional. Font handles for this provider.
*/
- protected function setup_provider_property_mock( WP_Web_Fonts $wp_fonts, $provider, array $font_handles = array() ) {
+ protected function setup_provider_property_mock( WP_Fonts $wp_fonts, $provider, array $font_handles = array() ) {
if ( is_string( $provider ) ) {
$provider = $this->get_provider_definitions( $provider );
}
- $property = $this->setup_property( WP_Web_Fonts::class, 'providers' );
+ $property = $this->setup_property( WP_Fonts::class, 'providers' );
$providers = $property->getValue( $wp_fonts );
if ( ! isset( $providers[ $provider['id'] ] ) ) {
diff --git a/phpunit/fonts-api/wp-fonts-tests-dataset.php b/phpunit/fonts-api/wp-fonts-tests-dataset.php
index 54a57c13daeeef..4640526c07138a 100644
--- a/phpunit/fonts-api/wp-fonts-tests-dataset.php
+++ b/phpunit/fonts-api/wp-fonts-tests-dataset.php
@@ -324,7 +324,7 @@ public function data_invalid_variation() {
),
),
'src: array of an empty string' => array(
- 'expected' => 'Each webfont src must be a non-empty string.',
+ 'expected' => 'Each font src must be a non-empty string.',
'font_family_handle' => 'lato',
'variation' => array(
'provider' => 'local',
@@ -334,7 +334,7 @@ public function data_invalid_variation() {
),
),
'src: array of a non-string' => array(
- 'expected' => 'Each webfont src must be a non-empty string.',
+ 'expected' => 'Each font src must be a non-empty string.',
'font_family_handle' => 'lato',
'variation' => array(
'provider' => 'local',
@@ -344,7 +344,7 @@ public function data_invalid_variation() {
),
),
'src: array with an empty string' => array(
- 'expected' => 'Each webfont src must be a non-empty string.',
+ 'expected' => 'Each font src must be a non-empty string.',
'font_family_handle' => 'lato',
'variation' => array(
'provider' => 'local',
@@ -358,7 +358,7 @@ public function data_invalid_variation() {
),
),
'src: array with a non-string' => array(
- 'expected' => 'Each webfont src must be a non-empty string.',
+ 'expected' => 'Each font src must be a non-empty string.',
'font_family_handle' => 'lato',
'variation' => array(
'provider' => 'local',
diff --git a/phpunit/fonts-api/wpDeregisterFontFamily-test.php b/phpunit/fonts-api/wpDeregisterFontFamily-test.php
index c55151e496977b..6ef73879f20320 100644
--- a/phpunit/fonts-api/wpDeregisterFontFamily-test.php
+++ b/phpunit/fonts-api/wpDeregisterFontFamily-test.php
@@ -12,12 +12,12 @@
* @group fontsapi
* @group remove_fonts
* @covers ::wp_deregister_font_family
- * @covers WP_Web_Fonts::remove_font_family
+ * @covers WP_Fonts::remove_font_family
*/
class Tests_Webfonts_WpDeregisterFontFamily extends WP_Fonts_TestCase {
/**
- * Unit test for registering a font-family that mocks WP_Web_Fonts.
+ * Unit test for registering a font-family that mocks WP_Fonts.
*
* @dataProvider data_font_family_handles
*
diff --git a/phpunit/fonts-api/wpEnqueueFonts-test.php b/phpunit/fonts-api/wpEnqueueFonts-test.php
index 57d37eb3945a03..43c1fd63a76104 100644
--- a/phpunit/fonts-api/wpEnqueueFonts-test.php
+++ b/phpunit/fonts-api/wpEnqueueFonts-test.php
@@ -11,17 +11,17 @@
/**
* @group fontsapi
* @covers ::wp_enqueue_fonts
- * @covers WP_Web_Fonts::enqueue
+ * @covers WP_Fonts::enqueue
*/
class Tests_Fonts_WpEnqueueFonts extends WP_Fonts_TestCase {
/**
- * Unit test for registering a font-family that mocks WP_Web_Fonts.
+ * Unit test for registering a font-family that mocks WP_Fonts.
*
* @dataProvider data_should_enqueue
*
* @param string[] $font_families Font families to test.
- * @param string[] $expected_handles Expected handles passed to WP_Web_Fonts::enqueue().
+ * @param string[] $expected_handles Expected handles passed to WP_Fonts::enqueue().
*/
public function test_unit_should_enqueue( $font_families, $expected_handles ) {
$mock = $this->set_up_mock( 'enqueue' );
@@ -40,7 +40,7 @@ public function test_unit_should_enqueue( $font_families, $expected_handles ) {
* @dataProvider data_should_enqueue
*
* @param string[] $font_families Font families to test.
- * @param string[] $expected_handles Expected handles passed to WP_Web_Fonts::enqueue().
+ * @param string[] $expected_handles Expected handles passed to WP_Fonts::enqueue().
*/
public function test_should_enqueue_after_registration( $font_families, $expected_handles ) {
// Register the font-families.
@@ -60,7 +60,7 @@ public function test_should_enqueue_after_registration( $font_families, $expecte
* @dataProvider data_should_enqueue
*
* @param string[] $font_families Font families to test.
- * @param string[] $expected_handles Expected handles passed to WP_Web_Fonts::enqueue().
+ * @param string[] $expected_handles Expected handles passed to WP_Fonts::enqueue().
*/
public function test_should_enqueue_before_registration( $font_families, $expected_handles ) {
wp_enqueue_fonts( $font_families );
diff --git a/phpunit/fonts-api/wpFonts-test.php b/phpunit/fonts-api/wpFonts-test.php
index f11bc803a7cc50..9a50dcb0fafc30 100644
--- a/phpunit/fonts-api/wpFonts-test.php
+++ b/phpunit/fonts-api/wpFonts-test.php
@@ -15,14 +15,14 @@
class Tests_Fonts_WpFonts extends WP_Fonts_TestCase {
public function test_returns_instance() {
- $this->assertInstanceOf( WP_Web_Fonts::class, wp_fonts() );
+ $this->assertInstanceOf( WP_Fonts::class, wp_fonts() );
}
public function test_global_set() {
global $wp_fonts;
$this->assertNull( $wp_fonts );
$instance = wp_fonts();
- $this->assertInstanceOf( WP_Web_Fonts::class, $wp_fonts );
+ $this->assertInstanceOf( WP_Fonts::class, $wp_fonts );
$this->assertSame( $instance, $wp_fonts );
}
diff --git a/phpunit/fonts-api/wpWebfonts/add-test.php b/phpunit/fonts-api/wpFonts/add-test.php
similarity index 60%
rename from phpunit/fonts-api/wpWebfonts/add-test.php
rename to phpunit/fonts-api/wpFonts/add-test.php
index 32147d6fd4a91a..8d88b6834d0cf6 100644
--- a/phpunit/fonts-api/wpWebfonts/add-test.php
+++ b/phpunit/fonts-api/wpFonts/add-test.php
@@ -1,6 +1,6 @@
assertTrue( $wp_webfonts->add( $handle, false ), 'Registering a handle should return true' );
- $this->assertCount( 1, $wp_webfonts->registered );
- $this->assertArrayHasKey( $handle, $wp_webfonts->registered, 'Font family handle should be in the registry after registration' );
+ $this->assertTrue( $wp_fonts->add( $handle, false ), 'Registering a handle should return true' );
+ $this->assertCount( 1, $wp_fonts->registered );
+ $this->assertArrayHasKey( $handle, $wp_fonts->registered, 'Font family handle should be in the registry after registration' );
}
diff --git a/phpunit/fonts-api/wpWebfonts/addFontFamily-test.php b/phpunit/fonts-api/wpFonts/addFontFamily-test.php
similarity index 75%
rename from phpunit/fonts-api/wpWebfonts/addFontFamily-test.php
rename to phpunit/fonts-api/wpFonts/addFontFamily-test.php
index 385e451acb0e64..85676b47c35e5e 100644
--- a/phpunit/fonts-api/wpWebfonts/addFontFamily-test.php
+++ b/phpunit/fonts-api/wpFonts/addFontFamily-test.php
@@ -1,6 +1,6 @@
add_font_family( $font_family );
+ $wp_fonts = new WP_Fonts();
+ $font_family_handle = $wp_fonts->add_font_family( $font_family );
$this->assertSame( $expected, $font_family_handle, 'Registering a font-family should return its handle' );
- $this->assertCount( 1, $wp_webfonts->registered );
- $this->assertArrayHasKey( $font_family_handle, $wp_webfonts->registered, 'Font family handle should be in the registry after registration' );
+ $this->assertCount( 1, $wp_fonts->registered );
+ $this->assertArrayHasKey( $font_family_handle, $wp_fonts->registered, 'Font family handle should be in the registry after registration' );
}
diff --git a/phpunit/fonts-api/wpWebfonts/addVariation-test.php b/phpunit/fonts-api/wpFonts/addVariation-test.php
similarity index 63%
rename from phpunit/fonts-api/wpWebfonts/addVariation-test.php
rename to phpunit/fonts-api/wpFonts/addVariation-test.php
index dd8d985a43660c..0f86c07ab0eaa8 100644
--- a/phpunit/fonts-api/wpWebfonts/addVariation-test.php
+++ b/phpunit/fonts-api/wpFonts/addVariation-test.php
@@ -1,6 +1,6 @@
add( $font_family_handle, false );
+ $wp_fonts = new WP_Fonts();
+ $wp_fonts->add( $font_family_handle, false );
- $variation_handle = $wp_webfonts->add_variation( $font_family_handle, $variation, $variation_handle );
+ $variation_handle = $wp_fonts->add_variation( $font_family_handle, $variation, $variation_handle );
$this->assertSame( $expected, $variation_handle, 'Registering a variation should return its handle' );
- $this->assertArrayHasKey( $variation_handle, $wp_webfonts->registered, 'Variation handle should be in the registry after registration' );
- $this->assertSame( array( $expected ), $this->get_variations( $font_family_handle, $wp_webfonts ), 'Variation should be registered to font family' );
+ $this->assertArrayHasKey( $variation_handle, $wp_fonts->registered, 'Variation handle should be in the registry after registration' );
+ $this->assertSame( array( $expected ), $this->get_variations( $font_family_handle, $wp_fonts ), 'Variation should be registered to font family' );
}
/**
@@ -41,14 +41,14 @@ public function test_should_register_variation_when_font_family_is_registered( $
* @param string $variation_handle Optional. The variation's handle.
*/
public function test_should_not_reregister_font_family( $expected, $font_family_handle, array $variation, $variation_handle = '' ) {
- $wp_webfonts = new WP_Web_Fonts();
- $wp_webfonts->add( $font_family_handle, false );
+ $wp_fonts = new WP_Fonts();
+ $wp_fonts->add( $font_family_handle, false );
- $variation_handle = $wp_webfonts->add_variation( $font_family_handle, $variation, $variation_handle );
+ $variation_handle = $wp_fonts->add_variation( $font_family_handle, $variation, $variation_handle );
// Font family should appear only once in the registered queue.
$expected = array( $font_family_handle, $variation_handle );
- $this->assertSame( $expected, array_keys( $wp_webfonts->registered ), 'Font family should not be re-registered after registering a variation' );
+ $this->assertSame( $expected, array_keys( $wp_fonts->registered ), 'Font family should not be re-registered after registering a variation' );
}
/**
@@ -60,20 +60,20 @@ public function test_should_not_reregister_font_family( $expected, $font_family_
* @param string $variation_handle Optional. The variation's handle.
*/
public function test_should_not_reregister_variation( $expected, $font_family_handle, array $variation, $variation_handle = '' ) {
- $wp_webfonts = new WP_Web_Fonts();
- $wp_webfonts->add( $font_family_handle, false );
+ $wp_fonts = new WP_Fonts();
+ $wp_fonts->add( $font_family_handle, false );
// Set up the test.
- $variation_handle = $wp_webfonts->add_variation( $font_family_handle, $variation, $variation_handle );
+ $variation_handle = $wp_fonts->add_variation( $font_family_handle, $variation, $variation_handle );
// Run the test.
- $variant_handle_on_reregister = $wp_webfonts->add_variation( $font_family_handle, $variation, $variation_handle );
+ $variant_handle_on_reregister = $wp_fonts->add_variation( $font_family_handle, $variation, $variation_handle );
$this->assertSame( $expected, $variant_handle_on_reregister, 'Variation should be registered to font family' );
$this->assertSame( $variation_handle, $variant_handle_on_reregister, 'Variation should return the previously registered variant handle' );
- $this->assertSame( array( $variation_handle ), $this->get_variations( $font_family_handle, $wp_webfonts ), 'Variation should only be registered once' );
+ $this->assertSame( array( $variation_handle ), $this->get_variations( $font_family_handle, $wp_fonts ), 'Variation should only be registered once' );
- $this->assertCount( 2, $wp_webfonts->registered );
- $this->assertArrayHasKey( $variation_handle, $wp_webfonts->registered, 'Variation handle should be in the registry after registration' );
+ $this->assertCount( 2, $wp_fonts->registered );
+ $this->assertArrayHasKey( $variation_handle, $wp_fonts->registered, 'Variation handle should be in the registry after registration' );
}
/**
@@ -85,16 +85,16 @@ public function test_should_not_reregister_variation( $expected, $font_family_ha
* @param string $variation_handle Optional. The variation's handle.
*/
public function test_should_register_font_family_and_variation( $expected, $font_family_handle, array $variation, $variation_handle = '' ) {
- $wp_webfonts = new WP_Web_Fonts();
+ $wp_fonts = new WP_Fonts();
- $variation_handle = $wp_webfonts->add_variation( $font_family_handle, $variation, $variation_handle );
+ $variation_handle = $wp_fonts->add_variation( $font_family_handle, $variation, $variation_handle );
$this->assertSame( $expected, $variation_handle, 'Variation should return its registered handle' );
// Extra checks to ensure both are registered.
- $this->assertCount( 2, $wp_webfonts->registered );
- $this->assertArrayHasKey( $font_family_handle, $wp_webfonts->registered, 'Font family handle should be in the registry after registration' );
- $this->assertArrayHasKey( $variation_handle, $wp_webfonts->registered, 'Variation handle should be in the registry after registration' );
- $this->assertSame( array( $variation_handle ), $this->get_variations( $font_family_handle, $wp_webfonts ), 'Variation should be registered to the font family' );
+ $this->assertCount( 2, $wp_fonts->registered );
+ $this->assertArrayHasKey( $font_family_handle, $wp_fonts->registered, 'Font family handle should be in the registry after registration' );
+ $this->assertArrayHasKey( $variation_handle, $wp_fonts->registered, 'Variation handle should be in the registry after registration' );
+ $this->assertSame( array( $variation_handle ), $this->get_variations( $font_family_handle, $wp_fonts ), 'Variation should be registered to the font family' );
}
/**
@@ -107,11 +107,11 @@ public function test_should_not_register_font_family_or_variant( $font_family_ha
$this->expectNotice();
$this->expectNoticeMessage( 'Font family handle must be a non-empty string.' );
- $wp_webfonts = new WP_Web_Fonts();
- $wp_webfonts->add_variation( $font_family_handle, $variation );
+ $wp_fonts = new WP_Fonts();
+ $wp_fonts->add_variation( $font_family_handle, $variation );
- $this->assertEmpty( $wp_webfonts->registered, 'Registered queue should be empty' );
- $this->assertEmpty( $this->get_variations( $font_family_handle, $wp_webfonts ), 'Variation should not be registered to the font family' );
+ $this->assertEmpty( $wp_fonts->registered, 'Registered queue should be empty' );
+ $this->assertEmpty( $this->get_variations( $font_family_handle, $wp_fonts ), 'Variation should not be registered to the font family' );
}
/**
@@ -126,8 +126,8 @@ public function test_should_not_register_variation_when_font_family_not_defined(
$this->expectNotice();
$this->expectNoticeMessage( $expected_message );
- $wp_webfonts = new WP_Web_Fonts();
- $this->assertNull( $wp_webfonts->add_variation( $font_family_handle, $variation ) );
+ $wp_fonts = new WP_Fonts();
+ $this->assertNull( $wp_fonts->add_variation( $font_family_handle, $variation ) );
}
/**
@@ -140,10 +140,10 @@ public function test_should_register_font_family_when_variant_fails_to_register(
$this->expectNotice();
$this->expectNoticeMessage( 'Variant handle could not be determined as font-weight and/or font-style are require' );
- $wp_webfonts = new WP_Web_Fonts();
- $wp_webfonts->add_variation( $font_family_handle, $variation );
+ $wp_fonts = new WP_Fonts();
+ $wp_fonts->add_variation( $font_family_handle, $variation );
- $this->assertCount( 1, $wp_webfonts->registered );
- $this->assertArrayHasKey( $font_family_handle, $wp_webfonts->registered );
+ $this->assertCount( 1, $wp_fonts->registered );
+ $this->assertArrayHasKey( $font_family_handle, $wp_fonts->registered );
}
}
diff --git a/phpunit/fonts-api/wpWebfonts/dequeue-test.php b/phpunit/fonts-api/wpFonts/dequeue-test.php
similarity index 54%
rename from phpunit/fonts-api/wpWebfonts/dequeue-test.php
rename to phpunit/fonts-api/wpFonts/dequeue-test.php
index 2e7af2d722b17b..e6ea2223657baa 100644
--- a/phpunit/fonts-api/wpWebfonts/dequeue-test.php
+++ b/phpunit/fonts-api/wpFonts/dequeue-test.php
@@ -1,6 +1,6 @@
dequeue( $handles );
- $this->assertEmpty( $this->get_queued_before_register( $wp_webfonts ), 'Prequeue should be empty' );
- $this->assertEmpty( $wp_webfonts->queue, 'Queue should be empty' );
+ $wp_fonts->dequeue( $handles );
+ $this->assertEmpty( $this->get_queued_before_register( $wp_fonts ), 'Prequeue should be empty' );
+ $this->assertEmpty( $wp_fonts->queue, 'Queue should be empty' );
}
/**
@@ -37,20 +37,20 @@ public function test_should_do_nothing_when_handles_not_queued( $handles ) {
* @param string|string[] $handles Handles to test.
*/
public function test_should_dequeue_from_queue( $handles ) {
- $wp_webfonts = new WP_Web_Fonts();
+ $wp_fonts = new WP_Fonts();
// Register and enqueue.
foreach ( $this->get_data_registry() as $handle => $variations ) {
- $this->setup_register( $handle, $variations, $wp_webfonts );
+ $this->setup_register( $handle, $variations, $wp_fonts );
}
- $wp_webfonts->enqueue( $handles );
+ $wp_fonts->enqueue( $handles );
// To make sure the handles are in the queue before dequeuing.
- $this->assertNotEmpty( $wp_webfonts->queue, 'Queue not be empty before dequeueing' );
+ $this->assertNotEmpty( $wp_fonts->queue, 'Queue not be empty before dequeueing' );
// Run the test.
- $wp_webfonts->dequeue( $handles );
- $this->assertEmpty( $wp_webfonts->queue, 'Queue should be empty after dequeueing' );
+ $wp_fonts->dequeue( $handles );
+ $this->assertEmpty( $wp_fonts->queue, 'Queue should be empty after dequeueing' );
}
/**
@@ -62,11 +62,11 @@ public function test_should_dequeue_from_queue( $handles ) {
* @param string|string[] $handles Handles to test.
*/
public function test_should_dequeue_from_prequeue( $handles ) {
- $wp_webfonts = new WP_Web_Fonts();
- $wp_webfonts->enqueue( $handles );
- $this->assertNotEmpty( $this->get_queued_before_register( $wp_webfonts ), 'Prequeue not be empty before dequeueing' );
+ $wp_fonts = new WP_Fonts();
+ $wp_fonts->enqueue( $handles );
+ $this->assertNotEmpty( $this->get_queued_before_register( $wp_fonts ), 'Prequeue not be empty before dequeueing' );
- $wp_webfonts->dequeue( $handles );
- $this->assertEmpty( $this->get_queued_before_register( $wp_webfonts ), 'Prequeue should be empty after dequeueing' );
+ $wp_fonts->dequeue( $handles );
+ $this->assertEmpty( $this->get_queued_before_register( $wp_fonts ), 'Prequeue should be empty after dequeueing' );
}
}
diff --git a/phpunit/fonts-api/wpWebfonts/doItem-test.php b/phpunit/fonts-api/wpFonts/doItem-test.php
similarity index 75%
rename from phpunit/fonts-api/wpWebfonts/doItem-test.php
rename to phpunit/fonts-api/wpFonts/doItem-test.php
index 85805a337c49da..602c8d74e1bae1 100644
--- a/phpunit/fonts-api/wpWebfonts/doItem-test.php
+++ b/phpunit/fonts-api/wpFonts/doItem-test.php
@@ -1,6 +1,6 @@
wp_webfonts = new WP_Web_Fonts;
+ $this->wp_fonts = new WP_Fonts;
}
public function test_should_return_false_when_provider_not_registered() {
- $this->assertFalse( $this->wp_webfonts->do_item( 'provider_not_registered' ) );
+ $this->assertFalse( $this->wp_fonts->do_item( 'provider_not_registered' ) );
}
/**
@@ -31,8 +31,8 @@ public function test_should_return_false_when_provider_not_registered() {
* @param array $provider Provider to mock.
*/
public function test_should_return_false_when_no_fonts_enqueued_for_provider( array $provider ) {
- $this->setup_provider_property_mock( $this->wp_webfonts, $provider );
- $this->assertFalse( $this->wp_webfonts->do_item( $provider['id'] ) );
+ $this->setup_provider_property_mock( $this->wp_fonts, $provider );
+ $this->assertFalse( $this->wp_fonts->do_item( $provider['id'] ) );
}
/**
@@ -50,7 +50,7 @@ public function data_provider_definitions() {
}
/**
- * Test the test set up to ensure the `Tests_Webfonts_WpWebfonts_DoItem_::setup_provider_property_mock()`
+ * Test the test set up to ensure the `Tests_Fonts_WpFonts_DoItem_::setup_provider_property_mock()`
* method works as expected.
*/
public function test_mocking_providers_property() {
@@ -62,34 +62,34 @@ public function test_mocking_providers_property() {
),
);
- $this->setup_provider_property_mock( $this->wp_webfonts, $this->get_provider_definitions( 'mock' ), $font_handles );
- $actual = $this->property['WP_Web_Fonts::$providers']->getValue( $this->wp_webfonts );
+ $this->setup_provider_property_mock( $this->wp_fonts, $this->get_provider_definitions( 'mock' ), $font_handles );
+ $actual = $this->property['WP_Fonts::$providers']->getValue( $this->wp_fonts );
$this->assertSame( $expected, $actual );
}
/**
- * Test the private method WP_Web_Fonts::get_enqueued_fonts_for_provider().
+ * Test the private method WP_Fonts::get_enqueued_fonts_for_provider().
*
* Why? This test validates the right fonts are returned for use within
- * WP_Web_Fonts::do_item().
+ * WP_Fonts::do_item().
*
* @dataProvider data_get_enqueued_fonts_for_provider
*
* @param array $font_handles Array of handles for the provider.
- * @param array $to_do Handles to set for the WP_Web_Fonts::$to_do property.
+ * @param array $to_do Handles to set for the WP_Fonts::$to_do property.
* @param array $expected Expected result.
*/
public function test_get_enqueued_fonts_for_provider( $font_handles, $to_do, $expected ) {
// Set up the `to_do` property.
- $this->wp_webfonts->to_do = $to_do;
+ $this->wp_fonts->to_do = $to_do;
// Open the method's visibility for testing.
$get_enqueued_fonts_for_provider = $this->get_reflection_method( 'get_enqueued_fonts_for_provider' );
- // Mock the WP_Web_Fonts::$property to set up the test.
- $this->setup_provider_property_mock( $this->wp_webfonts, $this->get_provider_definitions( 'mock' ), $font_handles );
+ // Mock the WP_Fonts::$property to set up the test.
+ $this->setup_provider_property_mock( $this->wp_fonts, $this->get_provider_definitions( 'mock' ), $font_handles );
- $actual = $get_enqueued_fonts_for_provider->invoke( $this->wp_webfonts, 'mock' );
+ $actual = $get_enqueued_fonts_for_provider->invoke( $this->wp_fonts, 'mock' );
$this->assertSameSets( $expected, $actual );
}
@@ -124,10 +124,10 @@ public function data_get_enqueued_fonts_for_provider() {
}
/**
- * Test the private method WP_Web_Fonts::get_font_properties_for_provider().
+ * Test the private method WP_Fonts::get_font_properties_for_provider().
*
* Why? This test validates the right font properties are returned for use within
- * WP_Web_Fonts::do_item().
+ * WP_Fonts::do_item().
*
* @dataProvider data_get_font_properties_for_provider
*
@@ -139,14 +139,14 @@ public function test_get_font_properties_for_provider( $font_handles, $expected
$fonts = $this->get_registered_fonts();
// Set all variations to 'mock' provider.
- // Mock the WP_Web_Fonts::$property to set up the test.
- $this->setup_provider_property_mock( $this->wp_webfonts, $this->get_provider_definitions( 'mock' ), $font_handles );
- $this->setup_registration_mocks( $fonts, $this->wp_webfonts );
+ // Mock the WP_Fonts::$property to set up the test.
+ $this->setup_provider_property_mock( $this->wp_fonts, $this->get_provider_definitions( 'mock' ), $font_handles );
+ $this->setup_registration_mocks( $fonts, $this->wp_fonts );
// Open the method's visibility for testing.
$method = $this->get_reflection_method( 'get_font_properties_for_provider' );
- $actual = $method->invoke( $this->wp_webfonts, $font_handles );
+ $actual = $method->invoke( $this->wp_fonts, $font_handles );
$this->assertSame( $expected, $actual );
}
@@ -193,13 +193,13 @@ public function test_should_trigger_provider_when_mocked( array $provider, array
$provider_mock->expects( $this->once() )->method( 'set_fonts' )->with( $this->identicalTo( $expected['set_fonts'] ) );
$provider_mock->expects( $this->once() )->method( 'print_styles' );
- // Set up the WP_Web_Fonts::$provider_instances property.
+ // Set up the WP_Fonts::$provider_instances property.
$provider_instances = $this->get_reflection_property( 'provider_instances' );
- $provider_instances->setValue( $this->wp_webfonts, array( $provider['id'] => $provider_mock ) );
+ $provider_instances->setValue( $this->wp_fonts, array( $provider['id'] => $provider_mock ) );
// Test the method successfully processes the provider.
$this->expectOutputString( '' );
- $this->assertTrue( $this->wp_webfonts->do_item( $provider['id'] ), 'WP_Web_Fonts::do_item() should return true' );
+ $this->assertTrue( $this->wp_fonts->do_item( $provider['id'] ), 'WP_Fonts::do_item() should return true' );
}
/**
@@ -216,7 +216,7 @@ public function test_should_print( array $provider, array $fonts, array $expecte
// Test the method successfully processes the provider.
$this->expectOutputString( $expected['printed_output'] );
- $this->assertTrue( $this->wp_webfonts->do_item( $provider['id'] ), 'WP_Web_Fonts::do_item() should return true' );
+ $this->assertTrue( $this->wp_fonts->do_item( $provider['id'] ), 'WP_Fonts::do_item() should return true' );
}
/**
@@ -234,7 +234,7 @@ public function data_print_enqueued_fonts() {
'provider' => $this->get_provider_definitions( 'mock' ),
'fonts' => $mock,
'expected' => array(
- 'set_fonts' => array_merge( $mock['font1'], $mock['font2'], $mock['font3'] ),
+ 'set_fonts' => array_merge( $mock['font1'], $mock['font2'], $mock['font3'] ),
'printed_output' => sprintf(
'%s; %s; %s; %s; %s; %s\n',
$font_faces['font1-300-normal'],
@@ -250,7 +250,7 @@ public function data_print_enqueued_fonts() {
'provider' => $this->get_provider_definitions( 'local' ),
'fonts' => $local,
'expected' => array(
- 'set_fonts' => array_merge( $local['merriweather'], $local['Source Serif Pro'] ),
+ 'set_fonts' => array_merge( $local['merriweather'], $local['Source Serif Pro'] ),
'printed_output' => sprintf(
"\n",
$font_faces['merriweather-200-900-normal'],
@@ -270,14 +270,14 @@ public function data_print_enqueued_fonts() {
* @param array $provider Define provider.
* @param array $fonts Fonts to register and enqueue.
* @param array $expected Not used.
- * @param array $to_do_queue Value to set in the WP_Web_Fonts::$to_do queue.
+ * @param array $to_do_queue Value to set in the WP_Fonts::$to_do queue.
*/
public function test_should_not_print_when_to_do_queue_empty( array $provider, array $fonts, $expected, $to_do_queue ) {
$this->setup_print_deps( $provider, $fonts, $to_do_queue );
// Test the method successfully processes the provider.
$this->expectOutputString( '' );
- $this->assertFalse( $this->wp_webfonts->do_item( $provider['id'] ), 'WP_Web_Fonts::do_item() should return false' );
+ $this->assertFalse( $this->wp_fonts->do_item( $provider['id'] ), 'WP_Fonts::do_item() should return false' );
}
/**
@@ -316,21 +316,21 @@ public function data_not_print_enqueued_fonts() {
*
* @param array $provider Provider id and class.
* @param array $fonts Fonts to register and enqueue.
- * @param array|null $to_do_queue Set the WP_Web_Fonts:$to_do queue.
+ * @param array|null $to_do_queue Set the WP_Fonts:$to_do queue.
*/
private function setup_print_deps( $provider, $fonts, $to_do_queue = null ) {
// Set up the fonts for WP_Dependencies:get_data().
- $mocks = $this->setup_registration_mocks( $fonts, $this->wp_webfonts );
+ $mocks = $this->setup_registration_mocks( $fonts, $this->wp_fonts );
$handles = array_keys( $mocks );
- $this->setup_provider_property_mock( $this->wp_webfonts, $provider, $handles );
+ $this->setup_provider_property_mock( $this->wp_fonts, $provider, $handles );
- // Set up the `WP_Web_Fonts::$to_do` and `WP_Web_Fonts::$to_do_keyed_handles` properties.
+ // Set up the `WP_Fonts::$to_do` and `WP_Fonts::$to_do_keyed_handles` properties.
if ( null === $to_do_queue ) {
$to_do_queue = $handles;
}
- $this->wp_webfonts->to_do = $to_do_queue;
- $to_do_keyed_handles = $this->get_reflection_property( 'to_do_keyed_handles' );
- $to_do_keyed_handles->setValue( $this->wp_webfonts, array_flip( $to_do_queue ) );
+ $this->wp_fonts->to_do = $to_do_queue;
+ $to_do_keyed_handles = $this->get_reflection_property( 'to_do_keyed_handles' );
+ $to_do_keyed_handles->setValue( $this->wp_fonts, array_flip( $to_do_queue ) );
}
}
diff --git a/phpunit/fonts-api/wpWebfonts/doItems-test.php b/phpunit/fonts-api/wpFonts/doItems-test.php
similarity index 79%
rename from phpunit/fonts-api/wpWebfonts/doItems-test.php
rename to phpunit/fonts-api/wpFonts/doItems-test.php
index 20a03c5d814fdf..20314f957014d9 100644
--- a/phpunit/fonts-api/wpWebfonts/doItems-test.php
+++ b/phpunit/fonts-api/wpFonts/doItems-test.php
@@ -1,6 +1,6 @@
wp_webfonts = new WP_Web_Fonts;
+ $this->wp_fonts = new WP_Fonts;
}
public function test_should_not_process_when_no_providers_registered() {
$this->setup_deps( array( 'enqueued' => 'font1' ) );
- $done = $this->wp_webfonts->do_items();
+ $done = $this->wp_fonts->do_items();
- $this->assertSame( array(), $done, 'WP_Web_Fonts::do_items() should return an empty array' );
- $this->assertSame( array(), $this->wp_webfonts->to_do, 'WP_Web_Fonts::$to_do should be an empty array' );
+ $this->assertSame( array(), $done, 'WP_Fonts::do_items() should return an empty array' );
+ $this->assertSame( array(), $this->wp_fonts->to_do, 'WP_Fonts::$to_do should be an empty array' );
}
/**
@@ -40,7 +40,7 @@ public function test_should_throw_notice_when_invalid_handles( $handles ) {
$this->expectNotice();
$this->expectNoticeMessage( 'Handles must be a non-empty string or array of non-empty strings' );
- $this->wp_webfonts->do_items( $handles );
+ $this->wp_fonts->do_items( $handles );
}
/**
@@ -60,7 +60,7 @@ public function data_invalid_handles() {
public function test_should_throw_notice_when_provider_class_not_found() {
$this->expectNotice();
- $this->expectNoticeMessage( 'Class "Provider_Does_Not_Exist" not found for "doesnotexist" web font provider' );
+ $this->expectNoticeMessage( 'Class "Provider_Does_Not_Exist" not found for "doesnotexist" font provider' );
$setup = array(
'provider' => array(
@@ -86,7 +86,7 @@ public function test_should_throw_notice_when_provider_class_not_found() {
);
$this->setup_deps( $setup );
- $this->wp_webfonts->do_items();
+ $this->wp_fonts->do_items();
}
/**
@@ -100,7 +100,7 @@ public function test_should_print_mocked_enqueued( $setup, $expected_done, $expe
$this->setup_deps( $setup );
$this->expectOutputString( $expected_output );
- $actual_done = $this->wp_webfonts->do_items();
+ $actual_done = $this->wp_fonts->do_items();
$this->assertSameSets( $expected_done, $actual_done, 'Printed handles should match' );
}
@@ -118,7 +118,7 @@ public function test_should_print_enqueued( $setup, $expected_done, $expected_ou
$this->setup_integrated_deps( $setup );
$this->expectOutputString( $expected_output, 'Printed @font-face styles should match' );
- $actual_done = $this->wp_webfonts->do_items();
+ $actual_done = $this->wp_fonts->do_items();
$this->assertSameSets( $expected_done, $actual_done, 'Printed handles should match' );
}
@@ -134,12 +134,12 @@ public function test_should_print_enqueued( $setup, $expected_done, $expected_ou
*/
public function test_should_print_handles_when_not_enqueued( $setup, $expected_done, $expected_output ) {
$this->setup_integrated_deps( $setup, false );
- // Do not enqueue. Instead, pass the handles to WP_Web_Fonts::do_items().
+ // Do not enqueue. Instead, pass the handles to WP_Fonts::do_items().
$handles = $setup['enqueued'];
- $this->assertEmpty( $this->wp_webfonts->queue, 'No fonts should be enqueued' );
+ $this->assertEmpty( $this->wp_fonts->queue, 'No fonts should be enqueued' );
$this->expectOutputString( $expected_output );
- $actual_done = $this->wp_webfonts->do_items( $handles );
+ $actual_done = $this->wp_fonts->do_items( $handles );
$this->assertSameSets( $expected_done, $actual_done, 'Printed handles should match' );
}
@@ -161,17 +161,17 @@ private function setup_deps( array $setup ) {
if ( ! empty( $setup['provider'] ) ) {
foreach ( $setup['provider'] as $provider_id => $provider ) {
- $this->setup_provider_property_mock( $this->wp_webfonts, $provider, $setup['provider_handles'][ $provider_id ] );
+ $this->setup_provider_property_mock( $this->wp_fonts, $provider, $setup['provider_handles'][ $provider_id ] );
}
}
if ( ! empty( $setup['registered'] ) ) {
- $this->setup_registration_mocks( $setup['registered'], $this->wp_webfonts );
+ $this->setup_registration_mocks( $setup['registered'], $this->wp_fonts );
}
if ( ! empty( $setup['enqueued'] ) ) {
$queue = $this->get_reflection_property( 'queue' );
- $queue->setValue( $this->wp_webfonts, $setup['enqueued'] );
+ $queue->setValue( $this->wp_fonts, $setup['enqueued'] );
}
}
@@ -183,14 +183,14 @@ private function setup_deps( array $setup ) {
*/
private function setup_integrated_deps( array $setup, $enqueue = true ) {
foreach ( $setup['provider'] as $provider ) {
- $this->wp_webfonts->register_provider( $provider['id'], $provider['class'] );
+ $this->wp_fonts->register_provider( $provider['id'], $provider['class'] );
}
foreach ( $setup['registered'] as $handle => $variations ) {
- $this->setup_register( $handle, $variations, $this->wp_webfonts );
+ $this->setup_register( $handle, $variations, $this->wp_fonts );
}
if ( $enqueue ) {
- $this->wp_webfonts->enqueue( $setup['enqueued'] );
+ $this->wp_fonts->enqueue( $setup['enqueued'] );
}
}
}
diff --git a/phpunit/fonts-api/wpWebfonts/enqueue-test.php b/phpunit/fonts-api/wpFonts/enqueue-test.php
similarity index 57%
rename from phpunit/fonts-api/wpWebfonts/enqueue-test.php
rename to phpunit/fonts-api/wpFonts/enqueue-test.php
index dcfa67b3b85742..34380febfef5df 100644
--- a/phpunit/fonts-api/wpWebfonts/enqueue-test.php
+++ b/phpunit/fonts-api/wpFonts/enqueue-test.php
@@ -1,6 +1,6 @@
enqueue( $handles );
+ $wp_fonts = new WP_Fonts();
+ $wp_fonts->enqueue( $handles );
- $this->assertSame( $expected, $this->get_queued_before_register( $wp_webfonts ), 'Handles should be added to before registered queue' );
- $this->assertEmpty( $wp_webfonts->queue, 'Handles should not be added to the enqueue queue when not registered' );
+ $this->assertSame( $expected, $this->get_queued_before_register( $wp_fonts ), 'Handles should be added to before registered queue' );
+ $this->assertEmpty( $wp_fonts->queue, 'Handles should not be added to the enqueue queue when not registered' );
}
/**
@@ -40,14 +40,14 @@ public function test_should_prequeue_when_not_registered( $handles, $not_used, $
* @param array $expected Expected queue.
*/
public function test_should_enqueue_when_registered( $handles, array $expected ) {
- $wp_webfonts = new WP_Web_Fonts();
+ $wp_fonts = new WP_Fonts();
foreach ( $this->get_data_registry() as $font_family => $variations ) {
- $this->setup_register( $font_family, $variations, $wp_webfonts );
+ $this->setup_register( $font_family, $variations, $wp_fonts );
}
- $wp_webfonts->enqueue( $handles );
+ $wp_fonts->enqueue( $handles );
- $this->assertEmpty( $this->get_queued_before_register( $wp_webfonts ), '"queued_before_register" queue should be empty' );
- $this->assertSame( $expected, $wp_webfonts->queue, 'Queue should contain the given handles' );
+ $this->assertEmpty( $this->get_queued_before_register( $wp_fonts ), '"queued_before_register" queue should be empty' );
+ $this->assertSame( $expected, $wp_fonts->queue, 'Queue should contain the given handles' );
}
}
diff --git a/phpunit/fonts-api/wpWebfonts/getEnqueued-test.php b/phpunit/fonts-api/wpFonts/getEnqueued-test.php
similarity index 63%
rename from phpunit/fonts-api/wpWebfonts/getEnqueued-test.php
rename to phpunit/fonts-api/wpFonts/getEnqueued-test.php
index e6d32249f9f47a..68a509f3c35ccb 100644
--- a/phpunit/fonts-api/wpWebfonts/getEnqueued-test.php
+++ b/phpunit/fonts-api/wpFonts/getEnqueued-test.php
@@ -1,6 +1,6 @@
assertEmpty( $wp_webfonts->get_enqueued() );
+ $wp_fonts = new WP_Fonts();
+ $this->assertEmpty( $wp_fonts->get_enqueued() );
}
/**
@@ -28,10 +28,10 @@ public function test_should_return_empty_when_non_enqueued() {
* @param array $expected Expected queue.
*/
public function test_should_return_queue_when_property_has_font_families( $not_used, array $expected ) {
- $wp_webfonts = new WP_Web_Fonts();
- $wp_webfonts->queue = $expected;
+ $wp_fonts = new WP_Fonts();
+ $wp_fonts->queue = $expected;
- $this->assertSame( $expected, $wp_webfonts->get_enqueued() );
+ $this->assertSame( $expected, $wp_fonts->get_enqueued() );
}
/**
@@ -44,14 +44,14 @@ public function test_should_return_queue_when_property_has_font_families( $not_u
* @param array $expected Expected queue.
*/
public function test_should_return_queue_when_font_families_registered_and_enqueued( $font_family, array $expected ) {
- $wp_webfonts = new WP_Web_Fonts();
+ $wp_fonts = new WP_Fonts();
// Register and enqueue.
foreach ( $this->get_data_registry() as $handle => $variations ) {
- $this->setup_register( $handle, $variations, $wp_webfonts );
+ $this->setup_register( $handle, $variations, $wp_fonts );
}
- $wp_webfonts->enqueue( $font_family );
+ $wp_fonts->enqueue( $font_family );
- $this->assertSame( $expected, $wp_webfonts->get_enqueued() );
+ $this->assertSame( $expected, $wp_fonts->get_enqueued() );
}
}
diff --git a/phpunit/fonts-api/wpWebfonts/getProviders-test.php b/phpunit/fonts-api/wpFonts/getProviders-test.php
similarity index 65%
rename from phpunit/fonts-api/wpWebfonts/getProviders-test.php
rename to phpunit/fonts-api/wpFonts/getProviders-test.php
index 879bab4113df59..ed73921a31aea4 100644
--- a/phpunit/fonts-api/wpWebfonts/getProviders-test.php
+++ b/phpunit/fonts-api/wpFonts/getProviders-test.php
@@ -1,6 +1,6 @@
wp_webfonts = new WP_Web_Fonts();
+ $this->wp_fonts = new WP_Fonts();
- $this->providers_property = new ReflectionProperty( WP_Web_Fonts::class, 'providers' );
+ $this->providers_property = new ReflectionProperty( WP_Fonts::class, 'providers' );
$this->providers_property->setAccessible( true );
}
public function test_should_be_empty() {
- $actual = $this->wp_webfonts->get_providers();
+ $actual = $this->wp_fonts->get_providers();
$this->assertIsArray( $actual, 'Should return an empty array' );
$this->assertEmpty( $actual, 'Should return an empty array when no providers are registered' );
}
@@ -39,11 +39,11 @@ public function test_should_be_empty() {
*/
public function test_get_providers( array $providers, array $expected ) {
$this->setup_providers( $providers );
- $this->assertSame( $expected, $this->wp_webfonts->get_providers() );
+ $this->assertSame( $expected, $this->wp_fonts->get_providers() );
}
/**
- * Sets up the given providers and stores them in the `WP_Web_Fonts::providers` property.
+ * Sets up the given providers and stores them in the `WP_Fonts::providers` property.
*
* @param array $providers Array of providers to set up.
*/
@@ -57,6 +57,6 @@ private function setup_providers( array $providers ) {
);
}
- $this->providers_property->setValue( $this->wp_webfonts, $data );
+ $this->providers_property->setValue( $this->wp_fonts, $data );
}
}
diff --git a/phpunit/fonts-api/wpWebfonts/getRegistered-test.php b/phpunit/fonts-api/wpFonts/getRegistered-test.php
similarity index 75%
rename from phpunit/fonts-api/wpWebfonts/getRegistered-test.php
rename to phpunit/fonts-api/wpFonts/getRegistered-test.php
index efad00748dc49a..365a97733f3cfa 100644
--- a/phpunit/fonts-api/wpWebfonts/getRegistered-test.php
+++ b/phpunit/fonts-api/wpFonts/getRegistered-test.php
@@ -1,6 +1,6 @@
assertEmpty( $wp_webfonts->get_registered() );
+ $wp_fonts = new WP_Fonts();
+ $this->assertEmpty( $wp_fonts->get_registered() );
}
/**
@@ -28,11 +28,11 @@ public function test_should_return_empty_when_none_registered() {
* @param array $inputs Font family(ies) and variations to register.
*/
public function test_should_return_queue_when_mocking_registered_property( array $inputs ) {
- $wp_webfonts = new WP_Web_Fonts();
- $mocks = $this->setup_registration_mocks( $inputs, $wp_webfonts );
- $expected = array_keys( $mocks );
+ $wp_fonts = new WP_Fonts();
+ $mocks = $this->setup_registration_mocks( $inputs, $wp_fonts );
+ $expected = array_keys( $mocks );
- $this->assertSame( $expected, $wp_webfonts->get_registered() );
+ $this->assertSame( $expected, $wp_fonts->get_registered() );
}
/**
@@ -78,13 +78,13 @@ public function data_get_registered() {
* @param array $expected Expected results.
*/
public function test_should_return_queue_when_items_are_registered( $font_family, array $inputs, array $expected ) {
- $wp_webfonts = new WP_Web_Fonts();
+ $wp_fonts = new WP_Fonts();
// Register before testing.
foreach ( $inputs as $handle => $variations ) {
- $this->setup_register( $handle, $variations, $wp_webfonts );
+ $this->setup_register( $handle, $variations, $wp_fonts );
}
- $this->assertSame( $expected, $wp_webfonts->get_registered() );
+ $this->assertSame( $expected, $wp_fonts->get_registered() );
}
}
diff --git a/phpunit/fonts-api/wpWebfonts/query-test.php b/phpunit/fonts-api/wpFonts/query-test.php
similarity index 67%
rename from phpunit/fonts-api/wpWebfonts/query-test.php
rename to phpunit/fonts-api/wpFonts/query-test.php
index faae2af93e32b8..c64d88cf9fa867 100644
--- a/phpunit/fonts-api/wpWebfonts/query-test.php
+++ b/phpunit/fonts-api/wpFonts/query-test.php
@@ -1,6 +1,6 @@
wp_webfonts = new WP_Web_Fonts();
+ $this->wp_fonts = new WP_Fonts();
}
/**
@@ -28,7 +28,7 @@ public function set_up() {
* @param string $query_handle Handle to test.
*/
public function test_should_fail_when_handles_not_registered( $query_handle ) {
- $this->assertFalse( $this->wp_webfonts->query( $query_handle, 'registered' ) );
+ $this->assertFalse( $this->wp_fonts->query( $query_handle, 'registered' ) );
}
/**
@@ -38,7 +38,7 @@ public function test_should_fail_when_handles_not_registered( $query_handle ) {
* @param string $query_handle Handle to test.
*/
public function test_should_fail_when_handles_not_registered_or_enqueued( $query_handle ) {
- $this->assertFalse( $this->wp_webfonts->query( $query_handle, 'queue' ) );
+ $this->assertFalse( $this->wp_fonts->query( $query_handle, 'queue' ) );
}
/**
@@ -49,7 +49,7 @@ public function test_should_fail_when_handles_not_registered_or_enqueued( $query
public function test_registered_query_should_succeed_when_registered( $query_handle ) {
$this->setup_registry();
- $actual = $this->wp_webfonts->query( $query_handle, 'registered' );
+ $actual = $this->wp_fonts->query( $query_handle, 'registered' );
$this->assertInstanceOf( '_WP_Dependency', $actual, 'Query should return an instance of _WP_Dependency' );
$this->assertSame( $query_handle, $actual->handle, 'Query object handle should match the given handle to query' );
}
@@ -61,9 +61,9 @@ public function test_registered_query_should_succeed_when_registered( $query_han
*/
public function test_enqueued_query_should_succeed_when_registered_and_enqueued( $query_handle ) {
$this->setup_registry();
- $this->wp_webfonts->enqueue( $query_handle );
+ $this->wp_fonts->enqueue( $query_handle );
- $this->assertTrue( $this->wp_webfonts->query( $query_handle, 'enqueued' ) );
+ $this->assertTrue( $this->wp_fonts->query( $query_handle, 'enqueued' ) );
}
/**
@@ -72,9 +72,9 @@ public function test_enqueued_query_should_succeed_when_registered_and_enqueued(
* @param string $query_handle Handle to test.
*/
public function test_enqueued_query_should_fail_when_not_registered_but_enqueued( $query_handle ) {
- $this->wp_webfonts->enqueue( $query_handle );
+ $this->wp_fonts->enqueue( $query_handle );
- $this->assertFalse( $this->wp_webfonts->query( $query_handle, 'enqueued' ) );
+ $this->assertFalse( $this->wp_fonts->query( $query_handle, 'enqueued' ) );
}
/**
@@ -104,13 +104,13 @@ public function data_valid_query() {
}
public function test_done_query_should_fail_when_no_variations() {
- $this->wp_webfonts->register_provider( 'local', WP_Fonts_Provider_Local::class );
+ $this->wp_fonts->register_provider( 'local', WP_Fonts_Provider_Local::class );
$this->setup_registry();
- $this->wp_webfonts->enqueue( 'lato' );
+ $this->wp_fonts->enqueue( 'lato' );
- $this->wp_webfonts->do_items( 'lato' );
+ $this->wp_fonts->do_items( 'lato' );
- $this->assertFalse( $this->wp_webfonts->query( 'lato', 'done' ) );
+ $this->assertFalse( $this->wp_fonts->query( 'lato', 'done' ) );
}
/**
@@ -119,16 +119,16 @@ public function test_done_query_should_fail_when_no_variations() {
* @param string $query_handle Handle to test.
*/
public function test_done_query_should_succeed_when_registered_and_enqueued( $query_handle ) {
- $this->wp_webfonts->register_provider( 'local', WP_Fonts_Provider_Local::class );
+ $this->wp_fonts->register_provider( 'local', WP_Fonts_Provider_Local::class );
$this->setup_registry();
- $this->wp_webfonts->enqueue( $query_handle );
+ $this->wp_fonts->enqueue( $query_handle );
- // Process the web fonts while ignoring all the printed output.
+ // Process the fonts while ignoring all the printed output.
$this->expectOutputRegex( '`.`' );
- $this->wp_webfonts->do_items( $query_handle );
+ $this->wp_fonts->do_items( $query_handle );
$this->getActualOutput();
- $this->assertTrue( $this->wp_webfonts->query( $query_handle, 'done' ) );
+ $this->assertTrue( $this->wp_fonts->query( $query_handle, 'done' ) );
}
/**
@@ -145,7 +145,7 @@ public function data_done_query() {
private function setup_registry() {
foreach ( $this->get_registered_local_fonts() as $handle => $variations ) {
- $this->setup_register( $handle, $variations, $this->wp_webfonts );
+ $this->setup_register( $handle, $variations, $this->wp_fonts );
}
}
}
diff --git a/phpunit/fonts-api/wpWebfonts/registerProvider-test.php b/phpunit/fonts-api/wpFonts/registerProvider-test.php
similarity index 64%
rename from phpunit/fonts-api/wpWebfonts/registerProvider-test.php
rename to phpunit/fonts-api/wpFonts/registerProvider-test.php
index f33273fef03622..e4c9454c19ca1c 100644
--- a/phpunit/fonts-api/wpWebfonts/registerProvider-test.php
+++ b/phpunit/fonts-api/wpFonts/registerProvider-test.php
@@ -1,6 +1,6 @@
assertTrue( $wp_webfonts->register_provider( $provider_id, $class ), 'WP_Web_Fonts::register_provider() should return true' );
- $this->assertSame( $expected, $wp_webfonts->get_providers(), 'Provider "' . $provider_id . '" should be registered in providers queue' );
+ $wp_fonts = new WP_Fonts();
+ $this->assertTrue( $wp_fonts->register_provider( $provider_id, $class ), 'WP_Fonts::register_provider() should return true' );
+ $this->assertSame( $expected, $wp_fonts->get_providers(), 'Provider "' . $provider_id . '" should be registered in providers queue' );
}
/**
@@ -59,10 +59,10 @@ public function data_register_providers() {
}
public function test_should_register_mutliple_providers() {
- $wp_webfonts = new WP_Web_Fonts();
- $providers = $this->get_provider_definitions();
+ $wp_fonts = new WP_Fonts();
+ $providers = $this->get_provider_definitions();
foreach ( $providers as $provider ) {
- $this->assertTrue( $wp_webfonts->register_provider( $provider['id'], $provider['class'] ), 'WP_Web_Fonts::register_provider() should return true for provider ' . $provider['id'] );
+ $this->assertTrue( $wp_fonts->register_provider( $provider['id'], $provider['class'] ), 'WP_Fonts::register_provider() should return true for provider ' . $provider['id'] );
}
$expected = array(
@@ -76,7 +76,7 @@ public function test_should_register_mutliple_providers() {
),
);
- $this->assertSame( $expected, $wp_webfonts->get_providers(), 'Both local and mock providers should be registered' );
+ $this->assertSame( $expected, $wp_fonts->get_providers(), 'Both local and mock providers should be registered' );
}
/**
@@ -86,10 +86,10 @@ public function test_should_register_mutliple_providers() {
* @param string $class Provider class name.
*/
public function test_should_not_register( $provider_id, $class ) {
- $wp_webfonts = new WP_Web_Fonts();
+ $wp_fonts = new WP_Fonts();
- $this->assertFalse( $wp_webfonts->register_provider( $provider_id, $class ), 'WP_Web_Fonts::register_provider() should return false' );
- $this->assertArrayNotHasKey( $provider_id, $wp_webfonts->get_providers(), 'Both local and mock providers should be registered' );
+ $this->assertFalse( $wp_fonts->register_provider( $provider_id, $class ), 'WP_Fonts::register_provider() should return false' );
+ $this->assertArrayNotHasKey( $provider_id, $wp_fonts->get_providers(), 'Both local and mock providers should be registered' );
}
/**
diff --git a/phpunit/fonts-api/wpWebfonts/remove-test.php b/phpunit/fonts-api/wpFonts/remove-test.php
similarity index 78%
rename from phpunit/fonts-api/wpWebfonts/remove-test.php
rename to phpunit/fonts-api/wpFonts/remove-test.php
index 21eecb6a03ce2c..6da419a988e853 100644
--- a/phpunit/fonts-api/wpWebfonts/remove-test.php
+++ b/phpunit/fonts-api/wpFonts/remove-test.php
@@ -1,6 +1,6 @@
remove( array( 'handle-1', 'handle2' ) );
+ $wp_fonts->remove( array( 'handle-1', 'handle2' ) );
- $this->assertEmpty( $wp_webfonts->registered );
+ $this->assertEmpty( $wp_fonts->registered );
}
/**
@@ -30,12 +30,12 @@ public function test_should_not_remove_when_none_registered() {
* @param array $expected Expected handles are running test.
*/
public function test_should_remove_when_registered( array $handles, array $expected ) {
- $wp_webfonts = new WP_Web_Fonts();
- $wp_webfonts->registered = $this->generate_registered_queue();
+ $wp_fonts = new WP_Fonts();
+ $wp_fonts->registered = $this->generate_registered_queue();
- $wp_webfonts->remove( $handles );
+ $wp_fonts->remove( $handles );
- $this->assertSameSets( $expected, array_keys( $wp_webfonts->registered ), 'Registered queue should match after removing handles' );
+ $this->assertSameSets( $expected, array_keys( $wp_fonts->registered ), 'Registered queue should match after removing handles' );
}
/**
diff --git a/phpunit/fonts-api/wpWebfonts/removeFontFamily-test.php b/phpunit/fonts-api/wpFonts/removeFontFamily-test.php
similarity index 51%
rename from phpunit/fonts-api/wpWebfonts/removeFontFamily-test.php
rename to phpunit/fonts-api/wpFonts/removeFontFamily-test.php
index e04955bf650e52..b04882e04acdde 100644
--- a/phpunit/fonts-api/wpWebfonts/removeFontFamily-test.php
+++ b/phpunit/fonts-api/wpFonts/removeFontFamily-test.php
@@ -1,6 +1,6 @@
setup_registration_mocks( $inputs, $wp_webfonts );
+ $wp_fonts = new WP_Fonts();
+ $this->setup_registration_mocks( $inputs, $wp_fonts );
// Test the before state, just to make sure.
- $this->assertArrayHasKey( $font_family, $wp_webfonts->registered, 'Registered queue should contain the font family before remove' );
- $this->assertSame( $registered_handles, array_keys( $wp_webfonts->registered ), 'Font family and variations should be registered before remove' );
+ $this->assertArrayHasKey( $font_family, $wp_fonts->registered, 'Registered queue should contain the font family before remove' );
+ $this->assertSame( $registered_handles, array_keys( $wp_fonts->registered ), 'Font family and variations should be registered before remove' );
- $wp_webfonts->remove_font_family( $font_family );
+ $wp_fonts->remove_font_family( $font_family );
- $this->assertArrayNotHasKey( $font_family, $wp_webfonts->registered, 'Registered queue should not contain the font family' );
- $this->assertSame( $expected, array_keys( $wp_webfonts->registered ), 'Registered queue should match after removing font family' );
+ $this->assertArrayNotHasKey( $font_family, $wp_fonts->registered, 'Registered queue should not contain the font family' );
+ $this->assertSame( $expected, array_keys( $wp_fonts->registered ), 'Registered queue should match after removing font family' );
}
/**
@@ -45,14 +45,14 @@ public function test_should_dequeue_when_mocks_registered( $font_family, array $
* @param array $expected Array of expected handles.
*/
public function test_should_bail_out_when_not_registered( $font_family, array $inputs, array $registered_handles, array $expected ) {
- $wp_webfonts = new WP_Web_Fonts();
+ $wp_fonts = new WP_Fonts();
unset( $inputs[ $font_family ] );
- $this->setup_registration_mocks( $inputs, $wp_webfonts );
+ $this->setup_registration_mocks( $inputs, $wp_fonts );
- $wp_webfonts->remove_font_family( $font_family );
+ $wp_fonts->remove_font_family( $font_family );
- $this->assertArrayNotHasKey( $font_family, $wp_webfonts->registered, 'Registered queue should not contain the font family' );
- $this->assertSame( $expected, array_keys( $wp_webfonts->registered ), 'Registered queue should match after removing font family' );
+ $this->assertArrayNotHasKey( $font_family, $wp_fonts->registered, 'Registered queue should not contain the font family' );
+ $this->assertSame( $expected, array_keys( $wp_fonts->registered ), 'Registered queue should match after removing font family' );
}
/**
@@ -66,24 +66,24 @@ public function test_should_bail_out_when_not_registered( $font_family, array $i
* @param array $expected Array of expected handles.
*/
public function test_should_deregister_when_registered( $font_family, array $inputs, array $registered_handles, array $expected ) {
- $wp_webfonts = new WP_Web_Fonts();
+ $wp_fonts = new WP_Fonts();
// Register all font families and their variations.
foreach ( $inputs as $input_font_family => $variations ) {
- $handle = $wp_webfonts->add_font_family( $input_font_family );
+ $handle = $wp_fonts->add_font_family( $input_font_family );
foreach ( $variations as $variation_handle => $variation ) {
if ( ! is_string( $variation_handle ) ) {
$variation_handle = '';
}
- $wp_webfonts->add_variation( $handle, $variation, $variation_handle );
+ $wp_fonts->add_variation( $handle, $variation, $variation_handle );
}
}
// Test the before state, just to make sure.
- $this->assertArrayHasKey( $font_family, $wp_webfonts->registered, 'Registered queue should contain the font family before remove' );
- $this->assertSame( $registered_handles, array_keys( $wp_webfonts->registered ), 'Font family and variations should be registered before remove' );
+ $this->assertArrayHasKey( $font_family, $wp_fonts->registered, 'Registered queue should contain the font family before remove' );
+ $this->assertSame( $registered_handles, array_keys( $wp_fonts->registered ), 'Font family and variations should be registered before remove' );
- $wp_webfonts->remove_font_family( $font_family );
+ $wp_fonts->remove_font_family( $font_family );
- $this->assertArrayNotHasKey( $font_family, $wp_webfonts->registered, 'Registered queue should not contain the font family' );
- $this->assertSame( $expected, array_keys( $wp_webfonts->registered ), 'Registered queue should match after removing font family' );
+ $this->assertArrayNotHasKey( $font_family, $wp_fonts->registered, 'Registered queue should not contain the font family' );
+ $this->assertSame( $expected, array_keys( $wp_fonts->registered ), 'Registered queue should match after removing font family' );
}
}
diff --git a/phpunit/fonts-api/wpWebfonts/removeVariation-test.php b/phpunit/fonts-api/wpFonts/removeVariation-test.php
similarity index 57%
rename from phpunit/fonts-api/wpWebfonts/removeVariation-test.php
rename to phpunit/fonts-api/wpFonts/removeVariation-test.php
index 067ce6ce3f224c..71e898a4ba45af 100644
--- a/phpunit/fonts-api/wpWebfonts/removeVariation-test.php
+++ b/phpunit/fonts-api/wpFonts/removeVariation-test.php
@@ -1,6 +1,6 @@
wp_webfonts = new WP_Web_Fonts();
+ $this->wp_fonts = new WP_Fonts();
$this->fonts_to_register = $this->get_registered_local_fonts();
}
/**
* Sets up the unit test by mocking the WP_Dependencies object using stdClass and
- * registering each font family directly to the WP_Web_Fonts::$registered property
+ * registering each font family directly to the WP_Fonts::$registered property
* and its variations to the mocked $deps property.
*/
private function setup_unit_test() {
- $this->setup_registration_mocks( $this->fonts_to_register, $this->wp_webfonts );
+ $this->setup_registration_mocks( $this->fonts_to_register, $this->wp_fonts );
}
/**
* Sets up the integration test by properly registering each font family and its variations
- * by using the WP_Web_Fonts::add() and WP_Web_Fonts::add_variation() methods.
+ * by using the WP_Fonts::add() and WP_Fonts::add_variation() methods.
*/
private function setup_integration_test() {
foreach ( $this->fonts_to_register as $font_family_handle => $variations ) {
- $this->setup_register( $font_family_handle, $variations, $this->wp_webfonts );
+ $this->setup_register( $font_family_handle, $variations, $this->wp_fonts );
}
}
@@ -53,8 +53,8 @@ private function setup_integration_test() {
public function test_mocked_setup( $font_family_handle, $variation_handle ) {
$this->setup_unit_test();
- $this->assertArrayHasKey( $variation_handle, $this->wp_webfonts->registered, 'Variation should be in the registered queue before remval' );
- $this->assertContains( $variation_handle, $this->wp_webfonts->registered[ $font_family_handle ]->deps, 'Variation should be in its font family deps before removal' );
+ $this->assertArrayHasKey( $variation_handle, $this->wp_fonts->registered, 'Variation should be in the registered queue before remval' );
+ $this->assertContains( $variation_handle, $this->wp_fonts->registered[ $font_family_handle ]->deps, 'Variation should be in its font family deps before removal' );
}
/**
@@ -70,13 +70,13 @@ public function test_unit_should_do_nothing_when_variation_and_font_family_not_r
// Set up the test.
unset( $this->fonts_to_register[ $font_family ] );
$this->setup_unit_test();
- $registered_queue = $this->wp_webfonts->registered;
+ $registered_queue = $this->wp_fonts->registered;
// Run the tests.
- $this->wp_webfonts->remove_variation( $font_family_handle, $variation_handle );
- $this->assertArrayNotHasKey( $font_family_handle, $this->wp_webfonts->registered, 'Font family should not be registered' );
- $this->assertArrayNotHasKey( $variation_handle, $this->wp_webfonts->registered, 'Variant should not be registered' );
- $this->assertSame( $registered_queue, $this->wp_webfonts->registered, 'Registered queue should not have changed' );
+ $this->wp_fonts->remove_variation( $font_family_handle, $variation_handle );
+ $this->assertArrayNotHasKey( $font_family_handle, $this->wp_fonts->registered, 'Font family should not be registered' );
+ $this->assertArrayNotHasKey( $variation_handle, $this->wp_fonts->registered, 'Variant should not be registered' );
+ $this->assertSame( $registered_queue, $this->wp_fonts->registered, 'Registered queue should not have changed' );
}
/**
@@ -92,13 +92,13 @@ public function test_should_do_nothing_when_variation_and_font_family_not_regist
// Set up the test.
unset( $this->fonts_to_register[ $font_family ] );
$this->setup_integration_test();
- $registered_queue = $this->wp_webfonts->get_registered();
+ $registered_queue = $this->wp_fonts->get_registered();
// Run the tests.
- $this->wp_webfonts->remove_variation( $font_family_handle, $variation_handle );
- $this->assertArrayNotHasKey( $font_family_handle, $this->wp_webfonts->registered, 'Font family should not be registered' );
- $this->assertArrayNotHasKey( $variation_handle, $this->wp_webfonts->registered, 'Variant should not be registered' );
- $this->assertSameSets( $registered_queue, $this->wp_webfonts->get_registered(), 'Registered queue should not have changed' );
+ $this->wp_fonts->remove_variation( $font_family_handle, $variation_handle );
+ $this->assertArrayNotHasKey( $font_family_handle, $this->wp_fonts->registered, 'Font family should not be registered' );
+ $this->assertArrayNotHasKey( $variation_handle, $this->wp_fonts->registered, 'Variant should not be registered' );
+ $this->assertSameSets( $registered_queue, $this->wp_fonts->get_registered(), 'Registered queue should not have changed' );
}
/**
@@ -136,10 +136,10 @@ public function test_unit_should_only_remove_from_font_family_deps_when_variatio
$this->setup_remove_variation_from_registered( $variation_handle );
// Run the tests.
- $this->wp_webfonts->remove_variation( $font_family_handle, $variation_handle );
- $this->assertArrayNotHasKey( $variation_handle, $this->wp_webfonts->registered, 'Variant should not be registered' );
- $this->assertNotContains( $variation_handle, $this->wp_webfonts->registered[ $font_family_handle ]->deps, 'Variation should not be its font family deps' );
- $this->assertSameSets( $expected['font_family_deps'], array_values( $this->wp_webfonts->registered[ $font_family_handle ]->deps ), 'Only the tested variation handle should be removed from font family deps' );
+ $this->wp_fonts->remove_variation( $font_family_handle, $variation_handle );
+ $this->assertArrayNotHasKey( $variation_handle, $this->wp_fonts->registered, 'Variant should not be registered' );
+ $this->assertNotContains( $variation_handle, $this->wp_fonts->registered[ $font_family_handle ]->deps, 'Variation should not be its font family deps' );
+ $this->assertSameSets( $expected['font_family_deps'], array_values( $this->wp_fonts->registered[ $font_family_handle ]->deps ), 'Only the tested variation handle should be removed from font family deps' );
}
/**
@@ -157,10 +157,10 @@ public function test_should_only_remove_from_font_family_deps_when_variation_not
$this->setup_remove_variation_from_registered( $variation_handle );
// Run the tests.
- $this->wp_webfonts->remove_variation( $font_family_handle, $variation_handle );
- $this->assertArrayNotHasKey( $variation_handle, $this->wp_webfonts->registered, 'Variant should not be registered' );
- $this->assertNotContains( $variation_handle, $this->wp_webfonts->registered[ $font_family_handle ]->deps, 'Variation should not be its font family deps' );
- $this->assertSameSets( $expected['font_family_deps'], array_values( $this->wp_webfonts->registered[ $font_family_handle ]->deps ), 'Only the tested variation handle should be removed from font family deps' );
+ $this->wp_fonts->remove_variation( $font_family_handle, $variation_handle );
+ $this->assertArrayNotHasKey( $variation_handle, $this->wp_fonts->registered, 'Variant should not be registered' );
+ $this->assertNotContains( $variation_handle, $this->wp_fonts->registered[ $font_family_handle ]->deps, 'Variation should not be its font family deps' );
+ $this->assertSameSets( $expected['font_family_deps'], array_values( $this->wp_fonts->registered[ $font_family_handle ]->deps ), 'Only the tested variation handle should be removed from font family deps' );
}
/**
@@ -177,12 +177,12 @@ public function test_unit_should_remove_variation_from_registered_queue_though_f
$this->setup_unit_test();
$this->setup_remove_from_font_family_deps( $font_family_handle, $variation_handle );
- $this->assertArrayNotHasKey( $variation_handle, array_flip( $this->wp_webfonts->registered[ $font_family_handle ]->deps ), 'Variation should not be in its font family deps before removal' );
+ $this->assertArrayNotHasKey( $variation_handle, array_flip( $this->wp_fonts->registered[ $font_family_handle ]->deps ), 'Variation should not be in its font family deps before removal' );
- $this->wp_webfonts->remove_variation( $font_family_handle, $variation_handle );
+ $this->wp_fonts->remove_variation( $font_family_handle, $variation_handle );
- $this->assertNotContains( $variation_handle, $this->wp_webfonts->registered[ $font_family_handle ]->deps, 'Variation should not be its font family deps' );
- $this->assertSameSets( $expected['font_family_deps'], array_values( $this->wp_webfonts->registered[ $font_family_handle ]->deps ), 'Only the tested variation handle should be removed from font family deps' );
+ $this->assertNotContains( $variation_handle, $this->wp_fonts->registered[ $font_family_handle ]->deps, 'Variation should not be its font family deps' );
+ $this->assertSameSets( $expected['font_family_deps'], array_values( $this->wp_fonts->registered[ $font_family_handle ]->deps ), 'Only the tested variation handle should be removed from font family deps' );
}
/**
@@ -199,12 +199,12 @@ public function test_should_remove_variation_from_registered_queue_though_font_f
$this->setup_integration_test();
$this->setup_remove_from_font_family_deps( $font_family_handle, $variation_handle );
- $this->assertArrayNotHasKey( $variation_handle, array_flip( $this->wp_webfonts->registered[ $font_family_handle ]->deps ), 'Variation should not be in its font family deps before removal' );
+ $this->assertArrayNotHasKey( $variation_handle, array_flip( $this->wp_fonts->registered[ $font_family_handle ]->deps ), 'Variation should not be in its font family deps before removal' );
- $this->wp_webfonts->remove_variation( $font_family_handle, $variation_handle );
+ $this->wp_fonts->remove_variation( $font_family_handle, $variation_handle );
- $this->assertNotContains( $variation_handle, $this->wp_webfonts->registered[ $font_family_handle ]->deps, 'Variation should not be its font family deps' );
- $this->assertSameSets( $expected['font_family_deps'], array_values( $this->wp_webfonts->registered[ $font_family_handle ]->deps ), 'Only the tested variation handle should be removed from font family deps' );
+ $this->assertNotContains( $variation_handle, $this->wp_fonts->registered[ $font_family_handle ]->deps, 'Variation should not be its font family deps' );
+ $this->assertSameSets( $expected['font_family_deps'], array_values( $this->wp_fonts->registered[ $font_family_handle ]->deps ), 'Only the tested variation handle should be removed from font family deps' );
}
/**
@@ -220,13 +220,13 @@ public function test_unit_should_remove_variation_from_queue_and_font_family_dep
// Set up the test.
$this->setup_unit_test();
- $this->assertArrayHasKey( $variation_handle, array_flip( $this->wp_webfonts->registered[ $font_family_handle ]->deps ), 'Variation should be in its font family deps before removal' );
+ $this->assertArrayHasKey( $variation_handle, array_flip( $this->wp_fonts->registered[ $font_family_handle ]->deps ), 'Variation should be in its font family deps before removal' );
- $this->wp_webfonts->remove_variation( $font_family_handle, $variation_handle );
+ $this->wp_fonts->remove_variation( $font_family_handle, $variation_handle );
- $this->assertArrayNotHasKey( $variation_handle, $this->wp_webfonts->registered, 'Variation should be not be in registered queue' );
- $this->assertNotContains( $variation_handle, $this->wp_webfonts->registered[ $font_family_handle ]->deps, 'Variation should not be its font family deps' );
- $this->assertSameSets( $expected['font_family_deps'], array_values( $this->wp_webfonts->registered[ $font_family_handle ]->deps ), 'Only the tested variation handle should be removed from font family deps' );
+ $this->assertArrayNotHasKey( $variation_handle, $this->wp_fonts->registered, 'Variation should be not be in registered queue' );
+ $this->assertNotContains( $variation_handle, $this->wp_fonts->registered[ $font_family_handle ]->deps, 'Variation should not be its font family deps' );
+ $this->assertSameSets( $expected['font_family_deps'], array_values( $this->wp_fonts->registered[ $font_family_handle ]->deps ), 'Only the tested variation handle should be removed from font family deps' );
}
/**
@@ -242,13 +242,13 @@ public function test_should_remove_variation_from_queue_and_font_family_deps( $f
// Set up the test.
$this->setup_integration_test();
- $this->assertArrayHasKey( $variation_handle, array_flip( $this->wp_webfonts->registered[ $font_family_handle ]->deps ), 'Variation should be in its font family deps before removal' );
+ $this->assertArrayHasKey( $variation_handle, array_flip( $this->wp_fonts->registered[ $font_family_handle ]->deps ), 'Variation should be in its font family deps before removal' );
- $this->wp_webfonts->remove_variation( $font_family_handle, $variation_handle );
+ $this->wp_fonts->remove_variation( $font_family_handle, $variation_handle );
- $this->assertArrayNotHasKey( $variation_handle, $this->wp_webfonts->registered, 'Variation should be not be in registered queue' );
- $this->assertNotContains( $variation_handle, $this->wp_webfonts->registered[ $font_family_handle ]->deps, 'Variation should not be its font family deps' );
- $this->assertSameSets( $expected['font_family_deps'], array_values( $this->wp_webfonts->registered[ $font_family_handle ]->deps ), 'Only the tested variation handle should be removed from font family deps' );
+ $this->assertArrayNotHasKey( $variation_handle, $this->wp_fonts->registered, 'Variation should be not be in registered queue' );
+ $this->assertNotContains( $variation_handle, $this->wp_fonts->registered[ $font_family_handle ]->deps, 'Variation should not be its font family deps' );
+ $this->assertSameSets( $expected['font_family_deps'], array_values( $this->wp_fonts->registered[ $font_family_handle ]->deps ), 'Only the tested variation handle should be removed from font family deps' );
}
/**
@@ -258,21 +258,21 @@ public function test_should_remove_variation_from_queue_and_font_family_deps( $f
* @param string $variation_handle The variation handle to remove.
*/
private function setup_remove_from_font_family_deps( $font_family_handle, $variation_handle ) {
- foreach ( $this->wp_webfonts->registered[ $font_family_handle ]->deps as $index => $vhandle ) {
+ foreach ( $this->wp_fonts->registered[ $font_family_handle ]->deps as $index => $vhandle ) {
if ( $variation_handle !== $vhandle ) {
continue;
}
- unset( $this->wp_webfonts->registered[ $font_family_handle ]->deps[ $index ] );
+ unset( $this->wp_fonts->registered[ $font_family_handle ]->deps[ $index ] );
break;
}
}
/**
- * Removes the variation from the WP_Web_Fonts::$registered queue.
+ * Removes the variation from the WP_Fonts::$registered queue.
*
* @param string $variation_handle The variation handle to remove.
*/
private function setup_remove_variation_from_registered( $variation_handle ) {
- unset( $this->wp_webfonts->registered[ $variation_handle ] );
+ unset( $this->wp_fonts->registered[ $variation_handle ] );
}
}
diff --git a/phpunit/fonts-api/wpPrintFonts-test.php b/phpunit/fonts-api/wpPrintFonts-test.php
index a263e1b781357b..932af8e990b31f 100644
--- a/phpunit/fonts-api/wpPrintFonts-test.php
+++ b/phpunit/fonts-api/wpPrintFonts-test.php
@@ -108,9 +108,9 @@ public function test_should_print_handles_when_not_enqueued( $setup, $expected_d
/**
* Sets up the dependencies for integration test.
*
- * @param array $setup Dependencies to set up.
- * @param WP_Web_Fonts $wp_fonts Instance of WP_Web_Fonts.
- * @param bool $enqueue Whether to enqueue. Default true.
+ * @param array $setup Dependencies to set up.
+ * @param WP_Fonts $wp_fonts Instance of WP_Fonts.
+ * @param bool $enqueue Whether to enqueue. Default true.
*/
private function setup_integrated_deps( array $setup, $wp_fonts, $enqueue = true ) {
foreach ( $setup['provider'] as $provider ) {
diff --git a/phpunit/fonts-api/wpRegisterFonts-test.php b/phpunit/fonts-api/wpRegisterFonts-test.php
index f51ffa7caddfd6..47fa896fd79d72 100644
--- a/phpunit/fonts-api/wpRegisterFonts-test.php
+++ b/phpunit/fonts-api/wpRegisterFonts-test.php
@@ -11,8 +11,8 @@
/**
* @group fontsapi
* @covers ::wp_register_fonts
- * @covers WP_Web_Fonts::add
- * @covers WP_Web_Fonts::add_variation
+ * @covers WP_Fonts::add
+ * @covers WP_Fonts::add_variation
*/
class Tests_Fonts_WpRegisterFonts extends WP_Fonts_TestCase {