-
Notifications
You must be signed in to change notification settings - Fork 39
Ensure plugin detail sections are ordered consistently #283
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
Closed
meszarosrob
wants to merge
11
commits into
fairpm:main
from
meszarosrob:enhance-279-consistent-sections-plugin-details-modal
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
87011cf
Add function to order sections by a predefined order
meszarosrob 42b1e76
Order the section fetched from MetadataDocument
meszarosrob 803ed72
Add test for the order_sections_by_predefined_order
meszarosrob 4e7f98c
Add doc blocks for the test class
meszarosrob 62c3f5d
Move order_sections_by_predefined_order under the FAIR\Packages\Admin…
meszarosrob 1b971bc
Hook into default plugin api results to order the sections
meszarosrob eea689f
Update doc blocks of order_plugin_information_sections
meszarosrob e826e28
Update doc block to use imperative
meszarosrob b57277f
Rename and match data provider key with test method param
meszarosrob 9f8e91f
Merge subsequent conditions into one
meszarosrob 8c820f3
Update test class per sample test directions
meszarosrob 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
99 changes: 99 additions & 0 deletions
99
tests/phpunit/tests/Packages/Admin/OrderSectionsByPredefinedOrderTest.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,99 @@ | ||
| <?php | ||
| /** | ||
| * Tests for FAIR\Packages\Admin\order_sections_by_predefined_order(). | ||
| * | ||
| * @package FAIR | ||
| */ | ||
|
|
||
| use function FAIR\Packages\Admin\order_sections_by_predefined_order; | ||
|
|
||
| /** | ||
| * Tests for FAIR\Packages\Admin\order_sections_by_predefined_order(). | ||
| * | ||
| * @covers FAIR\Packages\Admin\order_sections_by_predefined_order | ||
| */ | ||
| class OrderSectionsByPredefinedOrderTest extends WP_UnitTestCase { | ||
|
|
||
| /** | ||
| * Test that sections are ordered in a predefined order. | ||
| * | ||
| * @dataProvider data_plugin_detail_sections | ||
| * | ||
| * @param array $sections Sections provided in arbitrary order, as if returned from MetadataDocument. | ||
| * @param array $expected_order The sections in order we expect them to be. | ||
| */ | ||
| public function test_should_return_sections_in_predefined_order( array $sections, array $expected_order ) { | ||
| $this->assertSame( | ||
| $expected_order, | ||
| order_sections_by_predefined_order( $sections ) | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Data provider. | ||
| */ | ||
| public static function data_plugin_detail_sections(): array { | ||
| return [ | ||
| 'expected sections' => [ | ||
| 'sections' => [ | ||
| 'faq' => '', | ||
| 'screenshots' => '', | ||
| 'changelog' => '', | ||
| 'description' => '', | ||
| 'security' => '', | ||
| 'reviews' => '', | ||
| 'other_notes' => '', | ||
| 'installation' => '', | ||
| ], | ||
| 'expected_order' => [ | ||
| 'description' => '', | ||
| 'installation' => '', | ||
| 'faq' => '', | ||
| 'screenshots' => '', | ||
| 'changelog' => '', | ||
| 'security' => '', | ||
| 'reviews' => '', | ||
| 'other_notes' => '', | ||
| ], | ||
| ], | ||
| 'unknown sections' => [ | ||
| 'sections' => [ | ||
| 'foo' => '', | ||
| 'bar' => '', | ||
| 'baz' => '', | ||
| ], | ||
| 'expected_order' => [ | ||
| 'foo' => '', | ||
| 'bar' => '', | ||
| 'baz' => '', | ||
| ], | ||
| ], | ||
| 'expected and unknown sections' => [ | ||
| 'sections' => [ | ||
| 'faq' => '', | ||
| 'foo' => '', | ||
| 'screenshots' => '', | ||
| 'changelog' => '', | ||
| 'bar' => '', | ||
| 'reviews' => '', | ||
| 'installation' => '', | ||
| 'security' => '', | ||
| ], | ||
| 'expected_order' => [ | ||
| 'installation' => '', | ||
| 'faq' => '', | ||
| 'screenshots' => '', | ||
| 'changelog' => '', | ||
| 'security' => '', | ||
| 'reviews' => '', | ||
| 'foo' => '', | ||
| 'bar' => '', | ||
| ], | ||
| ], | ||
| 'empty sections' => [ | ||
| 'sections' => [], | ||
| 'expected_order' => [], | ||
| ], | ||
| ]; | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
securityis not a standard section and would therefore be grouped inother_notesUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not something that is returned/used by WP.org; however, it is defined in the protocol https://github.com/fairpm/fair-protocol/blob/main/specification.md#sections, so I have included it.
My assumption (which might be totally wrong) was that if it's in the protocol, then eventually it might get used.
If somebody passes it today, it will be displayed in the tabs.