Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
project_browser
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
project_browser
Merge requests
!611
Read values from endpoint.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Read values from endpoint.
issue/project_browser-3485386:3485386-do-not-hardcode
into
2.0.x
Overview
1
Commits
10
Pipelines
11
Changes
4
All threads resolved!
Hide all comments
Merged
Fran Garcia-Linares
requested to merge
issue/project_browser-3485386:3485386-do-not-hardcode
into
2.0.x
5 months ago
Overview
1
Commits
10
Pipelines
11
Changes
4
All threads resolved!
Hide all comments
Expand
Closes
#3485386
0
0
Merge request reports
Compare
2.0.x
version 10
c222f0d1
5 months ago
version 9
efa254ed
5 months ago
version 8
31bd3afb
5 months ago
version 7
197cfaea
5 months ago
version 6
c3916c20
5 months ago
version 5
95e8672c
5 months ago
version 4
d269af6f
5 months ago
version 3
aed53f87
5 months ago
version 2
46a0c702
5 months ago
version 1
f7c47f6a
5 months ago
2.0.x (base)
and
latest version
latest version
c222f0d1
10 commits,
5 months ago
version 10
c222f0d1
10 commits,
5 months ago
version 9
efa254ed
9 commits,
5 months ago
version 8
31bd3afb
8 commits,
5 months ago
version 7
197cfaea
7 commits,
5 months ago
version 6
c3916c20
6 commits,
5 months ago
version 5
95e8672c
5 commits,
5 months ago
version 4
d269af6f
4 commits,
5 months ago
version 3
aed53f87
3 commits,
5 months ago
version 2
46a0c702
2 commits,
5 months ago
version 1
f7c47f6a
1 commit,
5 months ago
4 files
+
116
−
49
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
scripts/regenerate-drupalorg-jsonapi-fixture.php
+
34
−
15
Options
@@ -9,22 +9,41 @@ require_once __DIR__ . '/../tests/modules/project_browser_test/src/DrupalOrgClie
use
Drupal\project_browser_test
\DrupalOrgClientMiddleware
;
$path_to_fixture
=
DrupalOrgClientMiddleware
::
ENDPOINT_TO_FIXTURE_MAP
;
$endpoint_url
=
'https://www.drupal.org/jsonapi'
;
/**
* Generate the fixtures requested.
*
* @param array $map
* Map of path and destination file.
* @param string $endpoint_base_url
* Base URL of the endpoint.
* @param string $destination_folder
* Destination folder.
*/
function
generate_fixtures
(
$map
,
$endpoint_base_url
,
$destination_folder
)
{
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_USERAGENT
,
'Curl.ProjectBrowser'
);
foreach
(
$map
as
$jsonapi_path
=>
$fixture_file_name
)
{
// Wait between requests as otherwise they could be blocked.
sleep
(
1
);
curl_setopt
(
$ch
,
CURLOPT_URL
,
$endpoint_base_url
.
$jsonapi_path
);
$contents
=
curl_exec
(
$ch
);
if
(
$contents
)
{
file_put_contents
(
$destination_folder
.
$fixture_file_name
,
$contents
);
}
}
curl_close
(
$ch
);
}
// Begin script.
$destination_folder
=
__DIR__
.
'/../tests/fixtures/drupalorg_jsonapi/'
;
// Make sure the folder exists.
if
(
!
is_dir
(
$destination_folder
))
{
mkdir
(
rtrim
(
$destination_folder
,
'/'
));
}
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_USERAGENT
,
'Curl.ProjectBrowser'
);
foreach
(
$path_to_fixture
as
$jsonapi_path
=>
$fixture_file_name
)
{
// Wait between requests as otherwise they could be blocked.
sleep
(
1
);
curl_setopt
(
$ch
,
CURLOPT_URL
,
$endpoint_url
.
$jsonapi_path
);
$contents
=
curl_exec
(
$ch
);
if
(
$contents
)
{
file_put_contents
(
$destination_folder
.
$fixture_file_name
,
$contents
);
}
}
curl_close
(
$ch
);
// Generate the fixtures for both the json:api and non json:api paths.
generate_fixtures
(
DrupalOrgClientMiddleware
::
DRUPALORG_JSONAPI_ENDPOINT_TO_FIXTURE_MAP
,
'https://www.drupal.org/jsonapi'
,
$destination_folder
);
generate_fixtures
(
DrupalOrgClientMiddleware
::
DRUPALORG_ENDPOINT_TO_FIXTURE_MAP
,
'https://www.drupal.org'
,
$destination_folder
);
Loading