{"id":17837041,"url":"https://github.com/olimorris/neotest-phpunit","last_synced_at":"2025-09-18T00:32:16.598Z","repository":{"id":42017117,"uuid":"510530986","full_name":"olimorris/neotest-phpunit","owner":"olimorris","description":"🧪 Neotest adapter for PHPUnit","archived":false,"fork":false,"pushed_at":"2024-05-05T09:31:40.000Z","size":65,"stargazers_count":36,"open_issues_count":3,"forks_count":25,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-07T19:12:22.189Z","etag":null,"topics":["neotest","neovim","neovim-plugin","nvim","php","phpunit"],"latest_commit_sha":null,"homepage":"","language":"Lua","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/olimorris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2022-07-04T23:44:47.000Z","updated_at":"2024-12-21T13:15:01.000Z","dependencies_parsed_at":"2024-02-24T13:24:29.781Z","dependency_job_id":"5768c58d-ce12-4b2a-87c0-7a1a8efaeada","html_url":"https://github.com/olimorris/neotest-phpunit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olimorris%2Fneotest-phpunit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olimorris%2Fneotest-phpunit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olimorris%2Fneotest-phpunit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olimorris%2Fneotest-phpunit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olimorris","download_url":"https://codeload.github.com/olimorris/neotest-phpunit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233432232,"owners_count":18675407,"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","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":["neotest","neovim","neovim-plugin","nvim","php","phpunit"],"created_at":"2024-10-27T20:45:13.041Z","updated_at":"2025-09-18T00:32:11.327Z","avatar_url":"https://github.com/olimorris.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# neotest-phpunit\n\n[![Tests](https://github.com/olimorris/neotest-phpunit/actions/workflows/ci.yml/badge.svg)](https://github.com/olimorris/neotest-phpunit/actions/workflows/ci.yml)\n\nThis plugin provides a [PHPUnit](https://phpunit.de) adapter for the [Neotest](https://github.com/nvim-neotest/neotest) framework.\n\n\u003cimg width=\"1502\" alt=\"Neotest and PHPUnit\" src=\"https://user-images.githubusercontent.com/9512444/177888651-c55f8613-686a-40d0-8753-ca802ee6c000.png\"\u003e\n\n## :package: Installation\n\nInstall with the package manager of your choice:\n\n**Lazy**\n\n```lua\n{\n  \"nvim-neotest/neotest\",\n  lazy = true,\n  dependencies = {\n    ...,\n    \"olimorris/neotest-phpunit\",\n  },\n  config = function()\n    require(\"neotest\").setup({\n      ...,\n      adapters = {\n        require(\"neotest-phpunit\")\n      },\n    }\n  end\n}\n```\n\n**Packer**\n\n```lua\nuse({\n  \"nvim-neotest/neotest\",\n  requires = {\n    ...,\n    \"olimorris/neotest-phpunit\",\n  },\n  config = function()\n    require(\"neotest\").setup({\n      ...,\n      adapters = {\n        require(\"neotest-phpunit\"),\n      }\n    })\n  end\n})\n```\n\n## :wrench: Configuration\n\n### Default configuration\n\n\u003e [!NOTE]\n\u003e You only need to the call the `setup` function if you wish to change any of the defaults.\n\n\u003cdetails\u003e\n  \u003csummary\u003eClick to see the default configuration\u003c/summary\u003e\n\n```lua\nadapters = {\n  require(\"neotest-phpunit\")({\n    phpunit_cmd = function()\n      return \"vendor/bin/phpunit\" -- for `dap` strategy then it must return string (table values will cause validation error)\n    end,\n    root_files = { \"composer.json\", \"phpunit.xml\", \".gitignore\" },\n    filter_dirs = { \".git\", \"node_modules\" },\n    env = {}, -- for example {XDEBUG_CONFIG = 'idekey=neotest'}\n    dap = nil, -- to configure `dap` strategy put single element from `dap.configurations.php`\n  }),\n}\n```\n\n\u003c/details\u003e\n\n### The test command\n\nThe command used to run tests can be changed via the `phpunit_cmd` option:\n\n```lua\nrequire(\"neotest-phpunit\")({\n  phpunit_cmd = function()\n    return \"vendor/bin/phpunit\"\n  end\n})\n```\n\n### Setting the root directory\n\nFor Neotest adapters to work, they need to define a project root whereby the process of discovering tests can take place. By default, the adapter looks for a `composer.json`, `phpunit.xml` or `.gitignore` file. These can be changed with:\n\n```lua\nrequire(\"neotest-phpunit\")({\n  root_files = { \"README.md\" }\n})\n```\n\nYou can even set `root_files` with a function which returns a table:\n\n```lua\nrequire(\"neotest-phpunit\")({\n  root_files = function() return { \"README.md\" } end\n})\n```\n\nIf there are projects you don't want discovered, you can instead set `root_ignore_files` to ignore any matching projects.\n\nFor example, if your project uses Pest and the appropriate [neotest adapter](https://github.com/V13Axel/neotest-pest), you'll need to set:\n\n```lua\nrequire(\"neotest-phpunit\")({\n    root_ignore_files = { \"tests/Pest.php\" }\n})\n```\n\n### Filtering directories\n\nBy default, the adapter will search test files in all dirs in the root with the exception of `node_modules` and `.git`. You can change this with:\n\n```lua\nrequire(\"neotest-phpunit\")({\n  filter_dirs = { \"vendor\" }\n})\n```\n\nYou can even set `filter_dirs` with a function which returns a table:\n\n```lua\nrequire(\"neotest-phpunit\")({\n  filter_dirs = function() return { \"vendor\" } end\n})\n```\n\n### Debugging\n\nThe plugin can also be used for debugging via a dap strategy.\n\nFirstly, install and configure [nvim-dap](https://github.com/mfussenegger/nvim-dap) with [vscode-php-debug](https://github.com/xdebug/vscode-php-debug). Then set the following dap configuration:\n\n```lua\ndap.configurations.php = {\n  {\n    log = true,\n    type = \"php\",\n    request = \"launch\",\n    name = \"Listen for XDebug\",\n    port = 9003,\n    stopOnEntry = false,\n    xdebugSettings = {\n      max_children = 512,\n      max_data = 1024,\n      max_depth = 4,\n    },\n    breakpoints = {\n      exception = {\n        Notice = false,\n        Warning = false,\n        Error = false,\n        Exception = false,\n        [\"*\"] = false,\n      },\n    },\n  }\n}\n```\n\nThen in the plugin's config, add:\n\n```lua\nrequire(\"neotest-phpunit\")({\n  env = {\n      XDEBUG_CONFIG = \"idekey=neotest\",\n  },\n  dap = dap.configurations.php[1],\n})\n```\n\n\u003e [!NOTE]\n\u003e If you run a test with the `dap` strategy from the summary window (by default by `d`) and see that the window content has been replaced by debugger content then consider setting `dap.defaults.fallback.switchbuf = \"useopen\"` or Neovim level [`switchbuf`](https://neovim.io/doc/user/options.html#'switchbuf')\n\n## :rocket: Usage\n\n#### Test single method\n\nTo test a single test, hover over the test and run `lua require(\"neotest\").run.run()`\n\n#### Test file\n\nTo test a file run `lua require(\"neotest\").run.run(vim.fn.expand(\"%\"))`\n\n#### Test directory\n\nTo test a directory run `lua require(\"neotest\").run.run(\"path/to/directory\")`\n\n#### Test suite\n\nTo test the full test suite run `lua require(\"neotest\").run.run({ suite = true })`\n\n## :gift: Contributing\n\nThis project is maintained by the Neovim PHP community. Please raise a PR if you are interested in adding new functionality or fixing any bugs. When submitting a bug, please include an example test that we can test against.\n\nTo trigger the tests for the adapter, run:\n\n```sh\n./scripts/test\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folimorris%2Fneotest-phpunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folimorris%2Fneotest-phpunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folimorris%2Fneotest-phpunit/lists"}