Repository navigation
Expand file tree
/
Copy pathblueprint.json
More file actions
80 lines (80 loc) · 4.88 KB
/
Copy pathblueprint.json
File metadata and controls
80 lines (80 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"landingPage": "/wp-admin/",
"preferredVersions": {
"php": "8.3",
"wp": "6.9"
},
"features": {
"networking": true
},
"steps": [
{
"step": "login"
},
{
"step": "setSiteOptions",
"options": {
"blogname": "HM REST Ability",
"permalink_structure": "/%postname%/"
}
},
{
"step": "installPlugin",
"pluginData": {
"resource": "url",
"url": "https://github.com/WordPress/mcp-adapter/releases/download/v0.7.0/mcp-adapter.zip"
}
},
{
"step": "activatePlugin",
"pluginPath": "mcp-adapter/mcp-adapter.php"
},
{
"step": "defineWpConfigConsts",
"consts": {
"WP_DEBUG": true,
"WP_DEBUG_LOG": "/wordpress/wp-content/plugins/hm-rest-ability/.playground-debug.log",
"SCRIPT_DEBUG": true
}
},
{
"step": "writeFile",
"path": "/wordpress/wp-content/mu-plugins/test-application-passwords.php",
"data": "<?php\n/**\n * Test-only: makes application passwords usable in Playground.\n *\n * WordPress only offers them over SSL or on localhost, and Playground serves\n * over http://127.0.0.1.\n */\n\ndefine( 'HM_TEST_APP_PASSWORDS', true );\n\nadd_filter( 'wp_is_application_passwords_available', '__return_true' );\n"
},
{
"step": "writeFile",
"path": "/wordpress/wp-content/mu-plugins/test-bulk-routes.php",
"data": "<?php\n/**\n * Test-only: registers 1,500 extra REST routes when a request carries the\n * X-HM-Bulk-Routes header, to stand in for a site running many plugins.\n */\n\nadd_action( 'rest_api_init', function () {\n\tif ( empty( $_SERVER['HTTP_X_HM_BULK_ROUTES'] ) ) {\n\t\treturn;\n\t}\n\n\tfor ( $i = 0; $i < 1500; $i++ ) {\n\t\tregister_rest_route( 'bulk-test/v1', \"/module-$i/(?P<id>[\\\\d]+)\", [\n\t\t\t'methods' => 'GET',\n\t\t\t'callback' => '__return_empty_array',\n\t\t\t'permission_callback' => '__return_true',\n\t\t] );\n\t}\n} );\n"
},
{
"step": "writeFile",
"path": "/wordpress/wp-content/mu-plugins/test-case-study-post-type.php",
"data": "<?php\n/**\n * Test-only: a custom post type on its own REST namespace, so the e2e suite\n * can prove URL lookup covers more than core's post and page routes.\n */\n\nadd_action( 'init', function () {\n\tregister_post_type( 'case_study', [\n\t\t'label' => 'Case studies',\n\t\t'public' => true,\n\t\t'show_in_rest' => true,\n\t\t'rest_base' => 'case-studies',\n\t\t'rest_namespace' => 'acme/v1',\n\t\t'rewrite' => [ 'slug' => 'work' ],\n\t\t'supports' => [ 'title', 'editor' ],\n\t] );\n} );\n"
},
{
"step": "writeFile",
"path": "/wordpress/wp-content/mu-plugins/test-object-route.php",
"data": "<?php\n/**\n * Test-only: a REST route whose callback returns a WP_Post object, which\n * response_to_data() passes through unchanged.\n */\n\nadd_action( 'rest_api_init', function () {\n\tregister_rest_route( 'object-test/v1', '/post', [\n\t\t'methods' => 'GET',\n\t\t'callback' => function () {\n\t\t\treturn new WP_REST_Response( new WP_Post( (object) [ 'ID' => 1, 'post_title' => 'Object fixture' ] ) );\n\t\t},\n\t\t'permission_callback' => '__return_true',\n\t] );\n} );\n"
},
{
"step": "writeFile",
"path": "/wordpress/wp-content/mu-plugins/test-plugin-settings-route.php",
"data": "<?php\n/**\n * Test-only: a plugin settings route gated on manage_options. It saves\n * nothing, so a test can call it freely.\n */\n\nadd_action( 'rest_api_init', function () {\n\tregister_rest_route( 'settings-test/v1', '/options', [\n\t\t'methods' => 'POST',\n\t\t'callback' => fn() => [ 'saved' => true ],\n\t\t'permission_callback' => fn() => current_user_can( 'manage_options' ),\n\t] );\n} );\n"
},
{
"step": "activatePlugin",
"pluginPath": "hm-rest-ability/hm-rest-ability.php",
"pluginName": "HM REST Ability"
},
{
"step": "runPHP",
"code": "<?php\nrequire_once '/wordpress/wp-load.php';\n\n$accounts = [];\n\nforeach ( [ 'admin' => null, 'subscriber' => 'subscriber' ] as $login => $role ) {\n\tif ( $role === null ) {\n\t\t$user = get_user_by( 'login', $login );\n\t} else {\n\t\t$user_id = wp_insert_user( [\n\t\t\t'user_login' => $login,\n\t\t\t'user_pass' => wp_generate_password( 20 ),\n\t\t\t'user_email' => $login . '@example.com',\n\t\t\t'role' => $role,\n\t\t] );\n\t\t$user = get_user_by( 'id', $user_id );\n\t}\n\n\tlist( $password ) = WP_Application_Passwords::create_new_application_password(\n\t\t$user->ID,\n\t\t[ 'name' => 'e2e-tests' ]\n\t);\n\n\t$accounts[ $login ] = [ 'user' => $user->user_login, 'password' => $password ];\n}\n\nfile_put_contents(\n\t'/wordpress/wp-content/plugins/hm-rest-ability/.playground-credentials.json',\n\tjson_encode( $accounts )\n);"
},
{
"step": "runPHP",
"code": "<?php\nrequire_once '/wordpress/wp-load.php';\n\n// Pick up the permalink structure and the test post type's rewrite rules.\nflush_rewrite_rules();"
}
]
}