diff --git a/lua/neotest-phpunit/init.lua b/lua/neotest-phpunit/init.lua index b6c1010..bf1f8e4 100644 --- a/lua/neotest-phpunit/init.lua +++ b/lua/neotest-phpunit/init.lua @@ -96,6 +96,10 @@ end ---@param file_path string Absolute file path ---@return neotest.Tree | nil function NeotestAdapter.discover_positions(path) + if not NeotestAdapter.is_test_file(path) then + return nil + end + local query = [[ ((class_declaration name: (name) @namespace.name (#match? @namespace.name "Test") diff --git a/lua/neotest-phpunit/utils.lua b/lua/neotest-phpunit/utils.lua index 847000a..ec9cf6f 100644 --- a/lua/neotest-phpunit/utils.lua +++ b/lua/neotest-phpunit/utils.lua @@ -60,9 +60,10 @@ local function make_outputs(test, output_file) local test_id = test_attr.file .. separator .. test_attr.line logger.info("PHPUnit id:", { test_id }) + local classname = test_attr.classname or test_attr.class local test_output = { status = "passed", - short = string.upper(test_attr.classname) .. "\n-> " .. "PASSED" .. " - " .. test_attr.name, + short = string.upper(classname) .. "\n-> " .. "PASSED" .. " - " .. test_attr.name, output_file = output_file, }