Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ip2country
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
project
ip2country
Commits
605ea92a
Commit
605ea92a
authored
3 years ago
by
Tim Rohaly
Committed by
Tim Rohaly
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3277762
by TR: Ip2CountryResourceTest broken in D10 because hal was removed from core
parent
59fd967c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/Functional/Ip2CountryResourceTest.php
+19
-18
19 additions, 18 deletions
tests/src/Functional/Ip2CountryResourceTest.php
with
19 additions
and
18 deletions
tests/src/Functional/Ip2CountryResourceTest.php
+
19
−
18
View file @
605ea92a
...
...
@@ -3,6 +3,7 @@
namespace
Drupal\Tests\ip2country\Functional
;
use
Drupal\Component\Serialization\Json
;
use
Drupal\Core\Cache\CacheableMetadata
;
use
Drupal\Core\Url
;
use
Drupal\Tests\rest\Functional\CookieResourceTestTrait
;
use
Drupal\Tests\rest\Functional\ResourceTestBase
;
...
...
@@ -20,16 +21,6 @@ class Ip2CountryResourceTest extends ResourceTestBase {
*/
protected
$defaultTheme
=
'stark'
;
/**
* {@inheritdoc}
*/
protected
static
$format
=
'hal_json'
;
/**
* {@inheritdoc}
*/
protected
static
$mimeType
=
'application/hal+json'
;
/**
* {@inheritdoc}
*/
...
...
@@ -43,7 +34,7 @@ class Ip2CountryResourceTest extends ResourceTestBase {
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'
hal
'
,
'ip2country'
];
protected
static
$modules
=
[
'
rest
'
,
'ip2country'
];
/**
* {@inheritdoc}
...
...
@@ -62,7 +53,7 @@ class Ip2CountryResourceTest extends ResourceTestBase {
/**
* Makes REST API requests to lookup known-good IP addresses.
*/
public
function
testIpLookup
()
{
public
function
testIpLookup
()
:
void
{
// Real working IPs that are in the database.
$ip_array
=
[
'125.29.33.201'
=>
'JP'
,
...
...
@@ -86,9 +77,7 @@ class Ip2CountryResourceTest extends ResourceTestBase {
"The 'restful get ip_lookup' permission is required."
,
$response
,
[
'4xx-response'
,
'http_response'
],
[
'user.permissions'
],
FALSE
,
FALSE
[
'user.permissions'
]
);
// Create a user account that has the required permissions to read
...
...
@@ -129,7 +118,7 @@ class Ip2CountryResourceTest extends ResourceTestBase {
/**
* {@inheritdoc}
*/
protected
function
setUpAuthorization
(
$method
)
{
protected
function
setUpAuthorization
(
$method
)
:
void
{
switch
(
$method
)
{
case
'GET'
:
$this
->
grantPermissionsToTestedRole
([
'restful get ip_lookup'
]);
...
...
@@ -148,11 +137,23 @@ class Ip2CountryResourceTest extends ResourceTestBase {
/**
* {@inheritdoc}
*/
protected
function
getExpectedUnauthorizedAccessCacheability
()
{}
protected
function
getExpectedUnauthorizedAccessCacheability
()
{
return
(
new
CacheableMetadata
())
->
setCacheTags
([
'4xx-response'
,
'http_response'
])
->
setCacheContexts
([
'user.permissions'
]);
}
/**
* {@inheritdoc}
*/
protected
function
getExpectedUnauthorizedAccessMessage
(
$method
)
{}
protected
function
getExpectedUnauthorizedAccessMessage
(
$method
)
{
switch
(
$method
)
{
case
'GET'
:
return
"The 'restful get ip_lookup' permission is required."
;
default
:
return
parent
::
getExpectedUnauthorizedAccessMessage
(
$method
);
}
}
}
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