@wp-tester/config 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/config-file.d.ts +6 -0
  2. package/dist/config-file.d.ts.map +1 -0
  3. package/dist/config-file.js +44 -0
  4. package/dist/config-file.js.map +1 -0
  5. package/dist/config.d.ts +0 -56
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +39 -346
  8. package/dist/config.js.map +1 -1
  9. package/dist/environment-resolver.d.ts +26 -0
  10. package/dist/environment-resolver.d.ts.map +1 -0
  11. package/dist/environment-resolver.js +131 -0
  12. package/dist/environment-resolver.js.map +1 -0
  13. package/dist/index.d.ts +8 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +7 -2
  16. package/dist/index.js.map +1 -1
  17. package/dist/options/ci.d.ts +10 -0
  18. package/dist/options/ci.d.ts.map +1 -0
  19. package/dist/options/ci.js +429 -0
  20. package/dist/options/ci.js.map +1 -0
  21. package/dist/options/index.d.ts +7 -0
  22. package/dist/options/index.d.ts.map +1 -1
  23. package/dist/options/index.js +5 -0
  24. package/dist/options/index.js.map +1 -1
  25. package/dist/options/phpunit-detect.d.ts +13 -26
  26. package/dist/options/phpunit-detect.d.ts.map +1 -1
  27. package/dist/options/phpunit-detect.js +51 -32
  28. package/dist/options/phpunit-detect.js.map +1 -1
  29. package/dist/options/phpunit.d.ts.map +1 -1
  30. package/dist/options/phpunit.js +7 -11
  31. package/dist/options/phpunit.js.map +1 -1
  32. package/dist/options/project-root.js +1 -1
  33. package/dist/options/project-root.js.map +1 -1
  34. package/dist/options/project-type.js +1 -1
  35. package/dist/options/project-type.js.map +1 -1
  36. package/dist/options/smoke-tests.js +1 -1
  37. package/dist/options/smoke-tests.js.map +1 -1
  38. package/dist/path-mappers.d.ts +7 -7
  39. package/dist/path-mappers.d.ts.map +1 -1
  40. package/dist/path-mappers.js +10 -10
  41. package/dist/path-mappers.js.map +1 -1
  42. package/dist/path-utils.d.ts +62 -0
  43. package/dist/path-utils.d.ts.map +1 -0
  44. package/dist/path-utils.js +141 -0
  45. package/dist/path-utils.js.map +1 -0
  46. package/dist/resolved-types.d.ts +31 -9
  47. package/dist/resolved-types.d.ts.map +1 -1
  48. package/dist/schema.json +3 -5
  49. package/dist/test-resolver.d.ts +18 -0
  50. package/dist/test-resolver.d.ts.map +1 -0
  51. package/dist/test-resolver.js +107 -0
  52. package/dist/test-resolver.js.map +1 -0
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/dist/wp-tester-config.d.ts +4 -2
  55. package/dist/wp-tester-config.d.ts.map +1 -1
  56. package/package.json +1 -1
  57. package/dist/phpunit.d.ts +0 -12
  58. package/dist/phpunit.d.ts.map +0 -1
  59. package/dist/phpunit.js +0 -58
  60. package/dist/phpunit.js.map +0 -1
@@ -0,0 +1,141 @@
1
+ import { existsSync, statSync } from "fs";
2
+ import { join, dirname, resolve, isAbsolute } from "path";
3
+ import { fileURLToPath } from "url";
4
+ import { hostToVfs } from './path-mappers.js';
5
+ /**
6
+ * Get the actual working directory, accounting for tools like tsx that may change process.cwd()
7
+ * When running via npx or tsx, INIT_CWD contains the original directory where the command was invoked
8
+ */
9
+ export function getWorkingDirectory() {
10
+ return process.env.INIT_CWD || process.cwd();
11
+ }
12
+ /**
13
+ * Resolve a path to an absolute path.
14
+ * If the path is already absolute, return it as-is.
15
+ * Otherwise, resolve it relative to the base directory.
16
+ *
17
+ * @param path - Path to resolve (relative or absolute)
18
+ * @param baseDir - Base directory to resolve relative paths from
19
+ * @returns Absolute path
20
+ */
21
+ export function resolveAbsolute(path, baseDir) {
22
+ return isAbsolute(path) ? path : resolve(baseDir, path);
23
+ }
24
+ export function configPath() {
25
+ return join(getWorkingDirectory(), "wp-tester.json");
26
+ }
27
+ export function getSchemaPath(importMetaUrl) {
28
+ // For ESM in production (built files) - use import.meta.url from this module
29
+ // This works when the package is installed via npm or run via npx
30
+ const metaUrl = importMetaUrl || import.meta.url;
31
+ if (metaUrl) {
32
+ const currentDir = dirname(fileURLToPath(metaUrl));
33
+ const schemaPath = join(currentDir, "schema.json");
34
+ if (existsSync(schemaPath)) {
35
+ return schemaPath;
36
+ }
37
+ }
38
+ // For CommonJS (built files)
39
+ if (typeof __dirname !== "undefined") {
40
+ return join(__dirname, "schema.json");
41
+ }
42
+ // For dev mode: try to find the config package
43
+ // Could be in monorepo (packages/config) or installed (node_modules)
44
+ const candidates = [
45
+ // Monorepo from root
46
+ join(process.cwd(), "packages/config/src/schema.json"),
47
+ // Monorepo from a package directory
48
+ join(process.cwd(), "../config/src/schema.json"),
49
+ // Installed package
50
+ join(process.cwd(), "node_modules/@wp-tester/config/dist/schema.json"),
51
+ ];
52
+ for (const candidate of candidates) {
53
+ if (existsSync(candidate)) {
54
+ return candidate;
55
+ }
56
+ }
57
+ // Last resort
58
+ return candidates[candidates.length - 1];
59
+ }
60
+ /**
61
+ * Get the absolute config file path.
62
+ *
63
+ * @param config - Path to config file (relative or absolute)
64
+ * @returns Absolute path to the config file
65
+ */
66
+ export function getConfigPath(config) {
67
+ // Expand tilde (~) to home directory
68
+ if (config.startsWith('~/') || config === '~') {
69
+ const homeDir = process.env.HOME || process.env.USERPROFILE;
70
+ if (!homeDir) {
71
+ throw new Error('Unable to resolve home directory');
72
+ }
73
+ config = config === '~' ? homeDir : join(homeDir, config.slice(2));
74
+ }
75
+ return isAbsolute(config) ? config : resolve(getWorkingDirectory(), config);
76
+ }
77
+ /**
78
+ * Normalize a config path to ensure it points to a file, not a directory.
79
+ * If the path is a directory, appends 'wp-tester.json' to it.
80
+ * Used by readConfigFile, resolveConfig, and the test watcher to handle
81
+ * directory paths passed via --config flag.
82
+ *
83
+ * @param configPath - Path to config file or directory (relative or absolute)
84
+ * @returns Absolute path to the config file
85
+ */
86
+ export function normalizeConfigPath(configPath) {
87
+ const absolutePath = getConfigPath(configPath);
88
+ // Check if path is a directory (synchronous)
89
+ try {
90
+ const stats = statSync(absolutePath);
91
+ if (stats.isDirectory()) {
92
+ return join(absolutePath, 'wp-tester.json');
93
+ }
94
+ }
95
+ catch {
96
+ // If stat fails, assume it's a file path
97
+ }
98
+ return absolutePath;
99
+ }
100
+ /**
101
+ * Get the config file directory path.
102
+ *
103
+ * @param configPath - Path to config file
104
+ * @returns Directory path where the config file is located
105
+ */
106
+ export function getConfigDir(configPath) {
107
+ return dirname(getConfigPath(configPath));
108
+ }
109
+ /**
110
+ * Get the project root directory path.
111
+ *
112
+ * Returns config.projectHostPath if specified (resolved relative to config file or as absolute),
113
+ * otherwise returns the config file's directory.
114
+ *
115
+ * @param config - Config object
116
+ * @param configPath - Optional path to config file (needed to resolve relative projectHostPath)
117
+ * @returns Absolute path to the project root directory
118
+ */
119
+ export function getProjectDir(config, configPath) {
120
+ // Get base directory: config file location or cwd
121
+ const baseDir = configPath ? getConfigDir(configPath) : getWorkingDirectory();
122
+ // If projectHostPath is specified, resolve it relative to base directory
123
+ if (config.projectHostPath) {
124
+ return resolveAbsolute(config.projectHostPath, baseDir);
125
+ }
126
+ // No projectHostPath specified, return base directory
127
+ return baseDir;
128
+ }
129
+ /**
130
+ * Convert a host path to a ResolvedPath using the project path mapping
131
+ * @param hostPath - Absolute path on host
132
+ * @param projectPath - Project path mapping
133
+ * @returns ResolvedPath with both host and VFS paths
134
+ */
135
+ export function toResolvedPath(hostPath, projectPath) {
136
+ return {
137
+ hostPath,
138
+ vfsPath: hostToVfs(hostPath, projectPath),
139
+ };
140
+ }
141
+ //# sourceMappingURL=path-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../src/path-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,KAA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IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,yCAAyC;IAC3C,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB;IAC7C,OAAO,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAsB,EACtB,UAAmB;IAEnB,kDAAkD;IAClD,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,mBAAmB,EAAE,CAAC;IAE9E,yEAAyE;IACzE,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3B,OAAO,eAAe,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,sDAAsD;IACtD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB,EAAE,WAAyB;IACxE,OAAO;QACL,QAAQ;QACR,OAAO,EAAE,SAAS,CAAC,QAAQ,EAAE,WAAW,CAAC;KAC1C,CAAC;AACJ,CAAC"}
@@ -1,5 +1,12 @@
1
1
  import type { BlueprintV1Declaration } from "@wp-playground/blueprints";
2
- import type { Mount, PHPUnitConfig, Tests, Environment, WPTesterConfig, TestMode, ProjectType, BaseReporterOptions, JsonReporterOptions } from "./wp-tester-config.js";
2
+ import type { Mount, Tests, Environment, WPTesterConfig, TestMode, ProjectType, BaseReporterOptions } from "./wp-tester-config.js";
3
+ /**
4
+ * Resolved JSON reporter options with required outputFile.
5
+ */
6
+ export interface ResolvedJsonReporterOptions extends BaseReporterOptions {
7
+ /** Absolute path where the JSON report file will be written */
8
+ outputFile: string;
9
+ }
3
10
  /**
4
11
  * Resolved reporters configuration.
5
12
  * Supports boolean shorthand for default reporter (true = enable with defaults).
@@ -7,15 +14,23 @@ import type { Mount, PHPUnitConfig, Tests, Environment, WPTesterConfig, TestMode
7
14
  export interface ResolvedReporters {
8
15
  /** Default reporter options (supports boolean shorthand: true = enable with defaults) */
9
16
  default?: boolean | BaseReporterOptions;
10
- /** JSON reporter options */
11
- json?: JsonReporterOptions;
17
+ /** JSON reporter options with resolved outputFile path */
18
+ json?: ResolvedJsonReporterOptions;
12
19
  }
13
20
  /**
14
- * Resolved PHPUnit configuration with absolute paths and required testMode.
21
+ * Resolved PHPUnit configuration with resolved paths and required testMode.
15
22
  */
16
- export interface ResolvedPHPUnitConfig extends Omit<PHPUnitConfig, 'testMode'> {
23
+ export interface ResolvedPHPUnitConfig {
24
+ /** Path to PHPUnit executable with host and VFS paths */
25
+ phpunitPath: ResolvedPath;
26
+ /** Path to PHPUnit configuration file with host and VFS paths */
27
+ configPath: ResolvedPath;
28
+ /** Path to PHPUnit bootstrap file with host and VFS paths */
29
+ bootstrapPath?: ResolvedPath;
17
30
  /** Test mode (always defined after resolution, defaults to "unit") */
18
31
  testMode: TestMode;
32
+ /** Additional arguments to pass to PHPUnit */
33
+ phpunitArgs?: string[];
19
34
  }
20
35
  /**
21
36
  * Resolved test configuration with resolved PHPUnit config.
@@ -25,6 +40,15 @@ export interface ResolvedTests extends Omit<Tests, 'phpunit'> {
25
40
  /** Allow the test suite to pass when no tests are executed */
26
41
  passWithNoTests?: boolean;
27
42
  }
43
+ /**
44
+ * Resolved path type with a host and VFS path.
45
+ */
46
+ export interface ResolvedPath {
47
+ /** Absolute path on host system */
48
+ hostPath: string;
49
+ /** Absolute path in VFS */
50
+ vfsPath: string;
51
+ }
28
52
  /**
29
53
  * Resolved blueprint with guaranteed preferredVersions.
30
54
  */
@@ -49,10 +73,8 @@ export interface ResolvedEnvironment extends Omit<Environment, 'blueprint' | 'mo
49
73
  * Resolved config with all paths absolute and optional fields set.
50
74
  */
51
75
  export interface ResolvedWPTesterConfig extends Omit<WPTesterConfig, 'projectHostPath' | 'projectVFSPath' | 'projectType' | 'reporters' | 'environments' | 'tests'> {
52
- /** Absolute path to project on host (always defined after resolution) */
53
- projectHostPath: string;
54
- /** VFS path determined by project type or explicit config (always defined after resolution) */
55
- projectVFSPath: string;
76
+ /** Resolved project path with both host and VFS paths */
77
+ projectPath: ResolvedPath;
56
78
  /** Project type (always defined after resolution) */
57
79
  projectType: ProjectType;
58
80
  /** Resolved environments with loaded blueprints */
@@ -1 +1 @@
1
- {"version":3,"file":"resolved-types.d.ts","sourceRoot":"","sources":["../src/resolved-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEpK;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,yFAAyF;IACzF,OAAO,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC;IACxC,4BAA4B;IAC5B,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC;IAC5E,sEAAsE;IACtE,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC;IAC3D,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,8DAA8D;IAC9D,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,sBAAsB,EAAE,mBAAmB,CAAC;IAC1F,iFAAiF;IACjF,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAAC,s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C5B,sGAAsG;IACtG,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,cAAc,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,aAAa,GAAG,WAAW,GAAG,cAAc,GAAG,OAAO,CAAC;IACjK,yDAAyD;IACzD,WAAW,EAAE,YAAY,CAAC;IAC1B,qDAAqD;IACrD,WAAW,EAAE,WAAW,CAAC;IACzB,mDAAmD;IACnD,YAAY,EAAE,mBAAmB,EAAE,CAAC;IACpC,sDAAsD;IACtD,KAAK,EAAE,aAAa,CAAC;IACrB,sFAAsF;IACtF,SAAS,EAAE,iBAAiB,CAAC;CAC9B"}
package/dist/schema.json CHANGED
@@ -2432,8 +2432,9 @@
2432
2432
  "type": "boolean"
2433
2433
  },
2434
2434
  "outputFile": {
2435
- "description": "Path where the JSON report file should be written",
2436
- "type": "string"
2435
+ "description": "Path where the JSON report file should be written. Defaults to wp-tester-results.json in the config directory.",
2436
+ "type": "string",
2437
+ "default": "wp-tester-results.json"
2437
2438
  },
2438
2439
  "passed": {
2439
2440
  "default": false,
@@ -2451,9 +2452,6 @@
2451
2452
  "type": "boolean"
2452
2453
  }
2453
2454
  },
2454
- "required": [
2455
- "outputFile"
2456
- ],
2457
2455
  "type": "object"
2458
2456
  },
2459
2457
  "MkdirStep": {
@@ -0,0 +1,18 @@
1
+ import type { Tests } from "./wp-tester-config.js";
2
+ import type { ResolvedTests, ResolvedPath } from "./resolved-types.js";
3
+ /**
4
+ * Resolve PHPUnit arguments to map host paths to VFS paths
5
+ *
6
+ * @param args - Original arguments from config
7
+ * @param projectPath - Project path with host and VFS paths
8
+ * @returns Resolved arguments with paths converted to VFS paths
9
+ */
10
+ export declare function resolvePhpunitArgs(args: string[], projectPath: ResolvedPath): string[];
11
+ /**
12
+ * Resolve PHPUnit config paths and set default testMode
13
+ * @param tests - Tests configuration
14
+ * @param projectPath - Project path with host and VFS paths
15
+ * @returns Resolved tests configuration
16
+ */
17
+ export declare function resolveTests(tests: Tests, projectPath: ResolvedPath): Promise<ResolvedTests>;
18
+ //# sourceMappingURL=test-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-resolver.d.ts","sourceRoot":"","sources":["../src/test-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAyB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA8B3F;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,YAAY,GAAG,MAAM,EAAE,CAuCtF;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAyClG"}
@@ -0,0 +1,107 @@
1
+ import { resolveAbsolute, toResolvedPath } from "./path-utils.js";
2
+ import { resolveBootstrapPath } from './options/phpunit-detect.js';
3
+ import { hostToVfs } from './path-mappers.js';
4
+ /**
5
+ * PHPUnit flags that are boolean (do not take a value).
6
+ * If a flag is NOT in this list, we assume it takes a value,
7
+ * and therefore the next argument should NOT be resolved as a path.
8
+ */
9
+ const PHPUNIT_BOOLEAN_FLAGS = new Set([
10
+ '--teamcity', '--debug', '--verbose', '--testdox',
11
+ '--stderr', '--stop-on-error', '--stop-on-failure', '--stop-on-warning',
12
+ '--stop-on-defect', '--stop-on-risky', '--stop-on-skipped', '--stop-on-incomplete',
13
+ '--stop-on-deprecation', '--stop-on-notice',
14
+ '--fail-on-warning', '--fail-on-risky', '--fail-on-incomplete', '--fail-on-skipped',
15
+ '--fail-on-deprecation', '--fail-on-notice',
16
+ '--strict-coverage', '--strict-global-state', '--disallow-test-output',
17
+ '--disallow-resource-usage', '--enforce-time-limit',
18
+ '--process-isolation', '--no-globals-backup', '--static-backup',
19
+ '--no-configuration', '--no-coverage', '--no-logging', '--no-interaction',
20
+ '--no-extensions', '--no-output', '--dont-report-useless-tests',
21
+ '--no-progress',
22
+ '--display-deprecations', '--display-errors', '--display-incomplete',
23
+ '--display-notices', '--display-skipped', '--display-warnings',
24
+ '--strict',
25
+ '--help', '--version',
26
+ '--list-groups', '--list-suites', '--list-tests', '--list-tests-xml',
27
+ ]);
28
+ /**
29
+ * Resolve PHPUnit arguments to map host paths to VFS paths
30
+ *
31
+ * @param args - Original arguments from config
32
+ * @param projectPath - Project path with host and VFS paths
33
+ * @returns Resolved arguments with paths converted to VFS paths
34
+ */
35
+ export function resolvePhpunitArgs(args, projectPath) {
36
+ const resolvedArgs = [];
37
+ for (let i = 0; i < args.length; i++) {
38
+ const arg = args[i];
39
+ // Don't resolve flags
40
+ if (arg.startsWith('-')) {
41
+ resolvedArgs.push(arg);
42
+ continue;
43
+ }
44
+ // Check if the previous argument was a flag that takes a value
45
+ const prevArg = args[i - 1];
46
+ if (prevArg?.startsWith('-') && !prevArg.includes('=')) {
47
+ // If the previous flag is NOT a known boolean flag, assume it takes a value
48
+ const flagName = prevArg.split('=')[0];
49
+ if (!PHPUNIT_BOOLEAN_FLAGS.has(flagName)) {
50
+ resolvedArgs.push(arg); // This is the flag's value, not a path
51
+ continue;
52
+ }
53
+ }
54
+ // Resolve arguments that look like file/directory paths
55
+ const looksLikePath = arg.includes('/') ||
56
+ arg.endsWith('.php') ||
57
+ arg === 'tests' || arg === 'test';
58
+ if (looksLikePath) {
59
+ const absoluteHostPath = resolveAbsolute(arg, projectPath.hostPath);
60
+ const vfsPath = hostToVfs(absoluteHostPath, projectPath);
61
+ resolvedArgs.push(vfsPath);
62
+ continue;
63
+ }
64
+ resolvedArgs.push(arg);
65
+ }
66
+ return resolvedArgs;
67
+ }
68
+ /**
69
+ * Resolve PHPUnit config paths and set default testMode
70
+ * @param tests - Tests configuration
71
+ * @param projectPath - Project path with host and VFS paths
72
+ * @returns Resolved tests configuration
73
+ */
74
+ export async function resolveTests(tests, projectPath) {
75
+ // If no PHPUnit config, return tests as-is (but explicitly typed)
76
+ if (!tests.phpunit) {
77
+ return {
78
+ plugin: tests.plugin,
79
+ theme: tests.theme,
80
+ wp: tests.wp,
81
+ passWithNoTests: tests.passWithNoTests,
82
+ };
83
+ }
84
+ // Resolve PHPUnit config with absolute paths and default testMode
85
+ const phpunit = tests.phpunit;
86
+ const resolvedConfigHostPath = resolveAbsolute(phpunit.configPath, projectPath.hostPath);
87
+ // Resolve bootstrap path using centralized logic
88
+ const bootstrapHostPath = await resolveBootstrapPath(resolvedConfigHostPath, projectPath.hostPath, phpunit.bootstrapPath);
89
+ const resolvedPhpunit = {
90
+ phpunitPath: toResolvedPath(resolveAbsolute(phpunit.phpunitPath, projectPath.hostPath), projectPath),
91
+ configPath: toResolvedPath(resolvedConfigHostPath, projectPath),
92
+ testMode: phpunit.testMode ?? "unit",
93
+ bootstrapPath: bootstrapHostPath ? toResolvedPath(bootstrapHostPath, projectPath) : undefined,
94
+ };
95
+ // Resolve phpunitArgs paths if present
96
+ if (phpunit.phpunitArgs) {
97
+ resolvedPhpunit.phpunitArgs = resolvePhpunitArgs(phpunit.phpunitArgs, projectPath);
98
+ }
99
+ return {
100
+ plugin: tests.plugin,
101
+ theme: tests.theme,
102
+ wp: tests.wp,
103
+ phpunit: resolvedPhpunit,
104
+ passWithNoTests: tests.passWithNoTests,
105
+ };
106
+ }
107
+ //# sourceMappingURL=test-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-resolver.js","sourceRoot":"","sources":["../src/test-resolver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,YAAY,EAAE,SAA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