Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"displayName": "PHPUnit Test Explorer",
"icon": "img/icon.png",
"publisher": "recca0120",
"version": "3.5.9",
"version": "3.5.10",
"private": true,
"license": "MIT",
"repository": {
Expand Down
94 changes: 94 additions & 0 deletions src/PHPUnit/ProblemMatcher/PestProblemMatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,5 +487,99 @@ describe('Pest ProblemMatcher Text', () => {
flowId: 57317,
});
});

it('pest-v2 tests/Fixtures/CollisionTest.php', () => {
resultShouldBe(`##teamcity[testSuiteStarted name='Tests\\Fixtures\\CollisionTest' locationHint='file://tests/Fixtures/CollisionTest.php' flowId='57317']`, {
event: TestResultEvent.testSuiteStarted,
id: 'tests/Fixtures/CollisionTest.php',
testId: 'tests/Fixtures/CollisionTest.php',
name: 'Tests\\Fixtures\\CollisionTest',
file: 'tests/Fixtures/CollisionTest.php',
flowId: 57317,
});

resultShouldBe(`##teamcity[testStarted name='success' locationHint='pest_qn://tests/Fixtures/CollisionTest.php::success' flowId='57317']`, {
event: TestResultEvent.testStarted,
id: 'tests/Fixtures/CollisionTest.php::success',
testId: 'tests/Fixtures/CollisionTest.php::success',
name: 'success',
file: 'tests/Fixtures/CollisionTest.php',
flowId: 57317,
});

resultShouldBe(`##teamcity[testFinished name='success' duration='0' flowId='57317']`, {
event: TestResultEvent.testFinished,
id: 'tests/Fixtures/CollisionTest.php::success',
testId: 'tests/Fixtures/CollisionTest.php::success',
name: 'success',
file: 'tests/Fixtures/CollisionTest.php',
flowId: 57317,
});

resultShouldBe(`##teamcity[testSuiteFinished name='Tests\\Fixtures\\CollisionTest' flowId='57317']`, {
event: TestResultEvent.testSuiteFinished,
id: 'tests/Fixtures/CollisionTest.php',
testId: 'tests/Fixtures/CollisionTest.php',
name: 'Tests\\Fixtures\\CollisionTest',
file: 'tests/Fixtures/CollisionTest.php',
flowId: 57317,
});
});

it('pest-v2 data set', () => {
resultShouldBe(`##teamcity[testSuiteStarted name='Tests\\Unit\\ExampleTest::__pest_evaluable_it_has_emails' locationHint='file://tests/Unit/ExampleTest.php' flowId='57317']`, {
event: TestResultEvent.testSuiteStarted,
id: 'tests/Unit/ExampleTest.php::it has emails',
testId: 'tests/Unit/ExampleTest.php::it has emails',
name: 'Tests\\Unit\\ExampleTest::__pest_evaluable_it_has_emails',
file: 'tests/Unit/ExampleTest.php',
flowId: 57317,
});

resultShouldBe(`##teamcity[testStarted name='it has emails with data set "(|'enunomaduro@gmail.com|')"' locationHint='pest_qn://tests/Unit/ExampleTest.php::it has emails with data set "(|'enunomaduro@gmail.com|')"' flowId='57317']`, {
event: TestResultEvent.testStarted,
id: 'tests/Unit/ExampleTest.php::it has emails with data set "(\'enunomaduro@gmail.com\')"',
testId: 'tests/Unit/ExampleTest.php::it has emails with data set "(\'enunomaduro@gmail.com\')"',
name: 'it has emails with data set "(\'enunomaduro@gmail.com\')"',
file: 'tests/Unit/ExampleTest.php',
flowId: 57317,
});

resultShouldBe(`##teamcity[testFinished name='it has emails with data set "(|'enunomaduro@gmail.com|')"' duration='1' flowId='57317']`, {
event: TestResultEvent.testFinished,
id: 'tests/Unit/ExampleTest.php::it has emails with data set "(\'enunomaduro@gmail.com\')"',
testId: 'tests/Unit/ExampleTest.php::it has emails with data set "(\'enunomaduro@gmail.com\')"',
name: 'it has emails with data set "(\'enunomaduro@gmail.com\')"',
file: 'tests/Unit/ExampleTest.php',
flowId: 57317,
});

resultShouldBe(`##teamcity[testStarted name='it has emails with data set "(|'other@example.com|')"' locationHint='pest_qn://tests/Unit/ExampleTest.php::it has emails with data set "(|'other@example.com|')"' flowId='57317']`, {
event: TestResultEvent.testStarted,
id: 'tests/Unit/ExampleTest.php::it has emails with data set "(\'other@example.com\')"',
testId: 'tests/Unit/ExampleTest.php::it has emails with data set "(\'other@example.com\')"',
name: 'it has emails with data set "(\'other@example.com\')"',
file: 'tests/Unit/ExampleTest.php',
flowId: 57317,
});

resultShouldBe(`##teamcity[testFinished name='it has emails with data set "(|'other@example.com|')"' duration='0' flowId='57317']`, {
event: TestResultEvent.testFinished,
id: 'tests/Unit/ExampleTest.php::it has emails with data set "(\'other@example.com\')"',
testId: 'tests/Unit/ExampleTest.php::it has emails with data set "(\'other@example.com\')"',
name: 'it has emails with data set "(\'other@example.com\')"',
file: 'tests/Unit/ExampleTest.php',
flowId: 57317,
});

resultShouldBe(`##teamcity[testSuiteFinished name='Tests\\Unit\\ExampleTest::__pest_evaluable_it_has_emails' flowId='57317']`, {
event: TestResultEvent.testSuiteFinished,
id: 'tests/Unit/ExampleTest.php::it has emails',
testId: 'tests/Unit/ExampleTest.php::it has emails',
name: 'Tests\\Unit\\ExampleTest::__pest_evaluable_it_has_emails',
file: 'tests/Unit/ExampleTest.php',
flowId: 57317,
});
});
});
});
2 changes: 1 addition & 1 deletion src/PHPUnit/TestParser/PHPUnitParser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Class, Declaration, Method, Namespace, Node, Program } from 'php-parser';
import { Parser } from './Parser';
import { TransformerFactory } from './Transformers';
import { TransformerFactory } from '../Transformer';
import { TestDefinition, TestType } from './types';
import { validator } from './Validator';

Expand Down
2 changes: 1 addition & 1 deletion src/PHPUnit/TestParser/Parser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Call, Declaration, Identifier, Namespace, Node, Variable } from 'php-parser';
import { PHPUnitXML } from '../PHPUnitXML';
import { annotationParser, attributeParser } from './AnnotationParser';
import { TransformerFactory } from './Transformers';
import { TransformerFactory } from '../Transformer';
import { TestDefinition, TestType } from './types';

export abstract class Parser {
Expand Down
2 changes: 1 addition & 1 deletion src/PHPUnit/TestParser/PestParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { basename, dirname, join, relative } from 'node:path';
import { Block, Call, Closure, Declaration, ExpressionStatement, Node, Program, String } from 'php-parser';
import { capitalize } from '../utils';
import { Parser } from './Parser';
import { TransformerFactory } from './Transformers';
import { TransformerFactory } from '../Transformer';
import { TestDefinition, TestType } from './types';

export class PestParser extends Parser {
Expand Down
2 changes: 1 addition & 1 deletion src/PHPUnit/TestParser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export * from './TestParser';
export * from './types';
export * from './PHPUnitParser';
export * from './PestParser';
export * from './Transformers';
export * from '../Transformer';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { capitalize, snakeCase, titleCase } from '../../utils';
import { TestDefinition, TestType } from '../types';
import { capitalize, snakeCase, titleCase } from '../utils';
import { TestDefinition, TestType } from '../TestParser/types';
import { Transformer } from './Transformer';

export class PHPUnitTransformer extends Transformer {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TestType } from '../types';
import { TestType } from '../TestParser/types';
import { PestTransformer } from './PestTransformer';

describe('PestTransformer', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { uncapitalize } from '../../utils';
import { TestDefinition, TestType } from '../types';
import { uncapitalize } from '../utils';
import { TestDefinition, TestType } from '../TestParser/types';
import { PHPUnitTransformer } from './PHPUnitTransformer';
import { TransformerFactory } from './TransformerFactory';

export class PestTransformer extends PHPUnitTransformer {
fromLocationHit(locationHint: string, name: string) {
locationHint = this.fixPestV2DataSet(locationHint, name);

let file = '';
const matched = locationHint.match(/(pest_qn|file):\/\/(?<id>(?<prefix>\w+)\s+\((?<classFQN>[\w\\]+)\)(::(?<method>.+))?)/);
if (!matched) {
const id = locationHint.replace(/(pest_qn|file):\/\//, '').replace(/\\/g, '/');
let id = locationHint.replace(/(pest_qn|file):\/\//, '').replace(/\\/g, '/');
const testId = id;
file = id.split('::')[0];

Expand Down Expand Up @@ -54,4 +56,13 @@ export class PestTransformer extends PHPUnitTransformer {
protected normalizeMethodName(methodName: string) {
return methodName.replace(/\*\//g, '{@*}');
}

private fixPestV2DataSet(locationHint: string, name: string) {
const matched = name.match(/__pest_evaluable_(?<name>.+)/);
if (matched && matched.groups?.name) {
locationHint += '::' + matched.groups.name.replace(/_/g, ' ');
}

return locationHint;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TestResultIdentify } from '../../ProblemMatcher';
import { TestDefinition, TestType } from '../types';
import { TestResultIdentify } from '../ProblemMatcher';
import { TestDefinition, TestType } from '../TestParser/types';

export abstract class Transformer {
static generateSearchText(input: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ describe('Extension Test', () => {
});
});

if (semver.gte(PHP_VERSION, '8.2.0')) {
if (semver.gte(PHP_VERSION, '8.1.0')) {
describe('PEST', () => {
const root = pestProject('');

Expand Down
Loading