Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jsonapi_menu_items-3350524
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
jsonapi_menu_items-3350524
Commits
cce3a41d
Commit
cce3a41d
authored
2 years ago
by
Matthew Hallsworth
Browse files
Options
Downloads
Patches
Plain Diff
Add test to cover the fields filter option
parent
cf36da37
Branches
3350524-add-support-for
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/fixtures/fields-expected-items.json
+28
-0
28 additions, 0 deletions
tests/fixtures/fields-expected-items.json
tests/src/Functional/JsonapiMenuItemsTest.php
+24
-0
24 additions, 0 deletions
tests/src/Functional/JsonapiMenuItemsTest.php
with
52 additions
and
0 deletions
tests/fixtures/fields-expected-items.json
0 → 100644
+
28
−
0
View file @
cce3a41d
{
"data"
:
[
{
"type"
:
"menu_link_content--menu_link_content"
,
"id"
:
"jsonapi_menu_test.open"
,
"attributes"
:
{
"title"
:
"Home"
,
"url"
:
"%base_pathmenu_name_test"
}
},
{
"type"
:
"menu_link_content--menu_link_content"
,
"id"
:
"menu_link_content:%uuid"
,
"attributes"
:
{
"title"
:
"%title"
,
"url"
:
"%base_pathmenu_callback_title"
}
},
{
"type"
:
"menu_link_content--menu_link_content"
,
"id"
:
"jsonapi_menu_test.user.login"
,
"attributes"
:
{
"title"
:
"Login"
,
"url"
:
"%base_pathuser
\/
login"
}
}
]
}
This diff is collapsed.
Click to expand it.
tests/src/Functional/JsonapiMenuItemsTest.php
+
24
−
0
View file @
cce3a41d
...
...
@@ -126,6 +126,30 @@ class JsonapiMenuItemsTest extends BrowserTestBase {
self
::
assertCacheContext
(
$headers
,
'url.query_args:filter'
);
}
/**
* Tests the JSON:API Menu Items resource with the 'fields' filter.
*/
public
function
testParametersFields
()
{
$link_title
=
$this
->
randomMachineName
();
$content_link
=
$this
->
createMenuLink
(
$link_title
,
'jsonapi_menu_test.open'
);
$url
=
Url
::
fromRoute
(
'jsonapi_menu_items.menu'
,
[
'menu'
=>
'jsonapi-menu-items-test'
,
'filter'
=>
[
'fields'
=>
"title,url"
,
],
]);
[
$content
]
=
$this
->
getJsonApiMenuItemsResponse
(
$url
);
$this
->
assertCount
(
3
,
$content
[
'data'
]);
$expected_items
=
Json
::
decode
(
strtr
(
file_get_contents
(
dirname
(
__DIR__
,
2
)
.
'/fixtures/fields-expected-items.json'
),
[
'%uuid'
=>
$content_link
->
uuid
(),
'%title'
=>
$link_title
,
'%base_path'
=>
Url
::
fromRoute
(
'<front>'
)
->
toString
(),
]));
$this
->
assertEquals
(
$expected_items
[
'data'
],
$content
[
'data'
]);
}
/**
* Tests the JSON:API Menu Items resource with the 'parents' filter.
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment