-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Font Library: unregister font collection #54701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
fb475a2
remove font collection
matiasbenedetto a50a2de
add wp_unregister_font_collection function
matiasbenedetto 8b90373
format php
matiasbenedetto 2968267
fix function comment
matiasbenedetto 42a61c5
add tests for unregister_font_collection
matiasbenedetto 27102fa
removig unused variable
matiasbenedetto da35119
Merge branch 'trunk' into try/unregister-font-collection
matiasbenedetto 7830ff7
update wording on comments
matiasbenedetto 2d6dcd2
Merge branch 'try/unregister-font-collection' of github.com:WordPress…
matiasbenedetto b7c9113
keep track of unregistered font collection ids in an array
matiasbenedetto cb28b82
add tests to assure that get_font_collections returns an empty array …
matiasbenedetto eee0a8d
fix tests
matiasbenedetto e489991
test the initial empty value of the font library collections
matiasbenedetto 177aa58
format
matiasbenedetto 06a10ea
simplify unregistering of font collections and add _doing_it_wrong call
matiasbenedetto 4d16323
add translation domain
matiasbenedetto 6f2ba86
adding _doing_it_wrong if you are registering collections with the sa…
matiasbenedetto d9ee03a
updating tests
matiasbenedetto a07e9fb
replace 6.4.0 by 6.5.0 in comments
matiasbenedetto e9f7b44
update version
matiasbenedetto e864318
Merge branch 'trunk' into try/unregister-font-collection
matiasbenedetto 6ca8662
consolidate code as only one function to avoid code repetition
matiasbenedetto 5a2c1ff
create base test case
matiasbenedetto 83525bf
format php
matiasbenedetto a42fa3f
assertWPError
matiasbenedetto 771e760
check that collection was not unregistered by mistake
matiasbenedetto 5d38c57
calling parent test class mehtods
matiasbenedetto dcd9770
format php
matiasbenedetto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
61 changes: 61 additions & 0 deletions
61
phpunit/tests/fonts/font-library/wpFontLibrary/unregisterFontCollection.php
This file contains hidden or 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,61 @@ | ||
| <?php | ||
| /** | ||
| * Test WP_Font_Library::unregister_font_collection(). | ||
| * | ||
| * @package WordPress | ||
| * @subpackage Font Library | ||
| * | ||
| * @group fonts | ||
| * @group font-library | ||
| * | ||
| * @covers WP_Font_Library::unregister_font_collection | ||
| */ | ||
| class Tests_Fonts_WpFontLibrary_UnregisterFontCollection extends WP_UnitTestCase { | ||
|
|
||
| public function set_up() { | ||
| // Resets the private static property WP_Font_Library::$collections to empty array. | ||
| $reflection = new ReflectionClass( 'WP_Font_Library' ); | ||
| $property = $reflection->getProperty( 'collections' ); | ||
| $property->setAccessible( true ); | ||
| $property->setValue( array() ); | ||
|
|
||
| // Registers two mock font collections. | ||
| $config = array( | ||
| 'id' => 'mock-font-collection-1', | ||
| 'name' => 'Mock Collection to be unregistered', | ||
| 'description' => 'A mock font collection to be unregistered.', | ||
| 'src' => 'my-collection-data.json', | ||
| ); | ||
| WP_Font_Library::register_font_collection( $config ); | ||
|
|
||
| $config = array( | ||
| 'id' => 'mock-font-collection-2', | ||
| 'name' => 'Mock Collection', | ||
| 'description' => 'A mock font collection.', | ||
| 'src' => 'my-mock-data.json', | ||
| ); | ||
| WP_Font_Library::register_font_collection( $config ); | ||
matiasbenedetto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| public function test_should_unregister_font_collection() { | ||
| // Unregister mock font collection. | ||
| WP_Font_Library::unregister_font_collection( 'mock-font-collection-1' ); | ||
| $collections = WP_Font_Library::get_font_collections(); | ||
| $this->assertArrayNotHasKey( 'mock-font-collection-1', $collections, 'Font collection was not unregistered.' ); | ||
|
|
||
matiasbenedetto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Unregisters remaining mock font collection. | ||
| WP_Font_Library::unregister_font_collection( 'mock-font-collection-2' ); | ||
| $collections = WP_Font_Library::get_font_collections(); | ||
| $this->assertArrayNotHasKey( 'mock-font-collection-2', $collections, 'Mock font collection was not unregistered.' ); | ||
|
|
||
| // Checks that all font collections were unregistered. | ||
| $this->assertEmpty( $collections, 'Font collections were not unregistered.' ); | ||
| } | ||
|
|
||
| public function unregister_non_existing_collection() { | ||
| // Unregisters non existing font collection. | ||
| WP_Font_Library::unregister_font_collection( 'non-existing-collection' ); | ||
| $collections = WP_Font_Library::get_font_collections(); | ||
| $this->assertEmpty( $collections, 'Should not be registered collections.' ); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.