{"id":25874399,"url":"https://github.com/formewp/forme-crosswise","last_synced_at":"2026-02-16T04:35:16.171Z","repository":{"id":65316134,"uuid":"589510448","full_name":"formewp/forme-crosswise","owner":"formewp","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-11T08:40:06.000Z","size":71,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-04T10:28:24.625Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/formewp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-01-16T09:42:29.000Z","updated_at":"2025-02-11T08:40:10.000Z","dependencies_parsed_at":"2025-02-11T09:42:10.879Z","dependency_job_id":"c614783d-65cb-44f8-a697-a9b0c5297006","html_url":"https://github.com/formewp/forme-crosswise","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/formewp/forme-crosswise","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formewp%2Fforme-crosswise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formewp%2Fforme-crosswise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formewp%2Fforme-crosswise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formewp%2Fforme-crosswise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/formewp","download_url":"https://codeload.github.com/formewp/forme-crosswise/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formewp%2Fforme-crosswise/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278254470,"owners_count":25956598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-02T09:20:14.365Z","updated_at":"2025-10-04T01:41:26.716Z","avatar_url":"https://github.com/formewp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Forme Crosswise\n\nAdds End To End helper routes to a [Forme Framework](https://github.com/formewp/forme-framework) project.\n\n## Overview\n\nCrosswise provides a set of protected endpoints that are only available in testing environments. These endpoints help facilitate common testing operations like user creation, database migrations, and running arbitrary PHP code from your front end during end to end tests.\n\nCrosswise is inspired by and derived from [laracasts/cypress](https://github.com/laracasts/cypress).\n\n## Installation\n\n```bash\ncomposer require forme/crosswise --dev\n```\n\n## Available Endpoints\n\nAll endpoints are prefixed with `/__e2e__` and are only accessible when `WP_ENV=testing`.\n\n### Create (`POST /__e2e__/create`)\nCreates a new model instance with the given attributes.\n```json\n{\n    \"model\": \"App\\\\Models\\\\Post\",\n    \"attributes\": {\n        \"title\": \"Test Post\",\n        \"content\": \"Test Content\"\n    }\n}\n```\n\n### Login (`POST /__e2e__/login`)\nCreates and/or logs in a user. Returns the user object.\n```json\n{\n    \"id\": 1,              // optional - specific user ID\n    \"role\": \"subscriber\"  // optional - defaults to \"subscriber\"\n}\n```\n\n### Current User (`GET /__e2e__/current-user`)\nReturns the currently logged-in user.\n\n### Migrate (`GET /__e2e__/migrate`)\nRuns all pending database migrations.\n\n### Rollback (`GET /__e2e__/rollback`)\nRolls back all database migrations.\n\n### Run PHP (`POST /__e2e__/run-php`)\nExecutes arbitrary PHP code and returns the result.\n```json\n{\n    \"command\": \"App\\\\Models\\\\Post::count()\"\n}\n```\n\n## Security\n\nAll endpoints are protected by Forme's `TestOnlyMiddleware` which ensures they can only be accessed when `WP_ENV=testing`. The Rollback endpoint has an additional redundant check to make double sure of this.\n\nIt goes without saying that you should _never_ install or enable Crosswise in production environments.\n\n## Usage Examples\n\n```js\n// basic usage\nawait axios.post('/__e2e__/login', {\n    role: 'administrator'\n});\n\nawait axios.post('/__e2e__/create', {\n    model: 'App\\\\Models\\\\Post',\n    attributes: {\n        title: 'Test Post',\n        status: 'publish'\n    }\n});\n```\n\n```ts\n// Cypress command example\n/**\n * create a model instance\n *\n * @example cy.create('App\\\\Models\\\\Post', { title: 'Test Post', status: 'publish'});\n */\nCypress.Commands.add('create', (model: string, attributes: { [key: string]: any } = {}) =\u003e {\n    let requestBody = { model, attributes };\n    return cy.request({\n        method: 'POST',\n        url: '/__e2e__/create',\n        body: { ...requestBody },\n        log: false,\n    }).\n        then(({ body }) =\u003e {\n            Cypress.log({\n                name: 'create',\n                message: model + ' created successfully',\n                consoleProps: () =\u003e ({ result: body }),\n            });\n        }).\n        its('body', { log: false });\n});\n\n// then use it in your tests\ncy.create('App\\\\Models\\\\Post', { title: 'Test Post', status: 'publish' });\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fformewp%2Fforme-crosswise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fformewp%2Fforme-crosswise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fformewp%2Fforme-crosswise/lists"}