-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Font Library: Use data or src file to define font collection data (#5…
…7734) * Add ability to use data rather than a file to define font collection * format php * avoid returning data when getting the font collection config * fix rest endpoint get_font_collection --------- Co-authored-by: Matias Benedetto <[email protected]>
- Loading branch information
1 parent
940f0fe
commit 2762ec4
Showing
6 changed files
with
156 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
phpunit/tests/fonts/font-library/wpFontCollection/getConfig.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/** | ||
* Test WP_Font_Collection::get_config(). | ||
* | ||
* @package WordPress | ||
* @subpackage Font Library | ||
* | ||
* @group fonts | ||
* @group font-library | ||
* | ||
* @covers WP_Font_Collection::get_config | ||
*/ | ||
class Tests_Fonts_WpFontCollection_GetConfig extends WP_UnitTestCase { | ||
/** | ||
* @dataProvider data_should_get_config | ||
* | ||
* @param array $config Font collection config options. | ||
* @param array $expected_data Expected data. | ||
*/ | ||
public function test_should_get_config( $config, $expected_data ) { | ||
$collection = new WP_Font_Collection( $config ); | ||
$this->assertSame( $expected_data, $collection->get_config() ); | ||
} | ||
|
||
/** | ||
* Data provider. | ||
* | ||
* @return array[] | ||
*/ | ||
public function data_should_get_config() { | ||
$mock_file = wp_tempnam( 'my-collection-data-' ); | ||
file_put_contents( $mock_file, '{"this is mock data":true}' ); | ||
|
||
return array( | ||
'with a file' => array( | ||
'config' => array( | ||
'id' => 'my-collection', | ||
'name' => 'My Collection', | ||
'description' => 'My collection description', | ||
'src' => $mock_file, | ||
), | ||
'expected_data' => array( | ||
'id' => 'my-collection', | ||
'name' => 'My Collection', | ||
'description' => 'My collection description', | ||
), | ||
), | ||
'with a url' => array( | ||
'config' => array( | ||
'id' => 'my-collection-with-url', | ||
'name' => 'My Collection with URL', | ||
'description' => 'My collection description', | ||
'src' => 'https://localhost/fonts/mock-font-collection.json', | ||
), | ||
'expected_data' => array( | ||
'id' => 'my-collection-with-url', | ||
'name' => 'My Collection with URL', | ||
'description' => 'My collection description', | ||
), | ||
), | ||
'with data' => array( | ||
'config' => array( | ||
'id' => 'my-collection', | ||
'name' => 'My Collection', | ||
'description' => 'My collection description', | ||
'data' => array( 'this is mock data' => true ), | ||
), | ||
'expected_data' => array( | ||
'id' => 'my-collection', | ||
'name' => 'My Collection', | ||
'description' => 'My collection description', | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters