Skip to content

Commit 5eb8a92

Browse files
committed
pest v2
1 parent e20ba2e commit 5eb8a92

File tree

8 files changed

+438
-15
lines changed

8 files changed

+438
-15
lines changed

.github/workflows/jest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
run: cd ${{ env.PHPUNIT_PROJECT }} && composer update --prefer-dist --no-interaction --no-progress
5757

5858
- name: Install Composer dependencies (PEST)
59-
if: matrix.php >= '8.2'
59+
if: matrix.php >= '8.1'
6060
run: cd ${{ env.PEST_PROJECT }} && composer update --prefer-dist --no-interaction --no-progress
6161

6262
# Install required deps for action

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"displayName": "PHPUnit Test Explorer",
55
"icon": "img/icon.png",
66
"publisher": "recca0120",
7-
"version": "3.5.8",
7+
"version": "3.5.9",
88
"private": true,
99
"license": "MIT",
1010
"repository": {

src/PHPUnit/ProblemMatcher/PestProblemMatcher.test.ts

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ describe('Pest ProblemMatcher Text', () => {
8585
});
8686

8787
it('testSuiteStarted tests/Fixtures/CollisionTest.php', () => {
88-
resultShouldBe(`##teamcity[testSuiteStarted name='Tests\\Unit\\CollisionTest' locationHint='pest_qn://tests/Fixtures/CollisionTest.php' flowId='68573']`, {
88+
resultShouldBe(`##teamcity[testSuiteStarted name='Tests\\Fixtures\\CollisionTest' locationHint='pest_qn://tests/Fixtures/CollisionTest.php' flowId='68573']`, {
8989
event: TestResultEvent.testSuiteStarted,
9090
id: 'tests/Fixtures/CollisionTest.php',
9191
testId: 'tests/Fixtures/CollisionTest.php',
92-
name: 'Tests\\Unit\\CollisionTest',
92+
name: 'Tests\\Fixtures\\CollisionTest',
9393
file: 'tests/Fixtures/CollisionTest.php',
9494
flowId: 68573,
9595
});
@@ -149,22 +149,22 @@ describe('Pest ProblemMatcher Text', () => {
149149
});
150150

151151
it('testSuiteFinished tests/Fixtures/CollisionTest.php', () => {
152-
resultShouldBe(`##teamcity[testSuiteFinished name='Tests\\Unit\\CollisionTest' flowId='68573']`, {
152+
resultShouldBe(`##teamcity[testSuiteFinished name='Tests\\Fixtures\\CollisionTest' flowId='68573']`, {
153153
event: TestResultEvent.testSuiteFinished,
154154
id: 'tests/Fixtures/CollisionTest.php',
155155
testId: 'tests/Fixtures/CollisionTest.php',
156-
name: 'Tests\\Unit\\CollisionTest',
156+
name: 'Tests\\Fixtures\\CollisionTest',
157157
file: 'tests/Fixtures/CollisionTest.php',
158158
flowId: 68573,
159159
});
160160
});
161161

162162
it('testSuiteStarted tests/Fixtures/DirectoryWithTests/ExampleTest.php', () => {
163-
resultShouldBe(`##teamcity[testSuiteStarted name='Tests\\Unit\\DirectoryWithTests\\ExampleTest' locationHint='pest_qn://tests/Fixtures/DirectoryWithTests/ExampleTest.php' flowId='68573']`, {
163+
resultShouldBe(`##teamcity[testSuiteStarted name='Tests\\Fixtures\\DirectoryWithTests\\ExampleTest' locationHint='pest_qn://tests/Fixtures/DirectoryWithTests/ExampleTest.php' flowId='68573']`, {
164164
event: TestResultEvent.testSuiteStarted,
165165
id: 'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
166166
testId: 'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
167-
name: 'Tests\\Unit\\DirectoryWithTests\\ExampleTest',
167+
name: 'Tests\\Fixtures\\DirectoryWithTests\\ExampleTest',
168168
file: 'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
169169
flowId: 68573,
170170
});
@@ -192,12 +192,12 @@ describe('Pest ProblemMatcher Text', () => {
192192
});
193193
});
194194

195-
it('testSuiteFinished tests/Fixtures/CollisionTest.php', () => {
196-
resultShouldBe(`##teamcity[testSuiteFinished name='Tests\\Unit\\DirectoryWithTests\\ExampleTest' flowId='68573']`, {
195+
it('testSuiteFinished tests/Fixtures/DirectoryWithTests/ExampleTest.php', () => {
196+
resultShouldBe(`##teamcity[testSuiteFinished name='Tests\\Fixtures\\DirectoryWithTests\\ExampleTest' flowId='68573']`, {
197197
event: TestResultEvent.testSuiteFinished,
198198
id: 'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
199199
testId: 'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
200-
name: 'Tests\\Unit\\DirectoryWithTests\\ExampleTest',
200+
name: 'Tests\\Fixtures\\DirectoryWithTests\\ExampleTest',
201201
file: 'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
202202
flowId: 68573,
203203
});
@@ -466,4 +466,26 @@ describe('Pest ProblemMatcher Text', () => {
466466
flowId: 68573,
467467
});
468468
});
469+
470+
describe('Pest v2', () => {
471+
it('testSuiteStarted phpunit.xml and locationHint prefix is file://', () => {
472+
resultShouldBe(`##teamcity[testSuiteStarted name='${pestProject('phpunit.xml')}' locationHint='file://Example (Tests\\Feature\\Example)' flowId='57317']`, {
473+
event: TestResultEvent.testSuiteStarted,
474+
id: pestProject('phpunit.xml'),
475+
testId: pestProject('phpunit.xml'),
476+
name: pestProject('phpunit.xml'),
477+
flowId: 57317,
478+
});
479+
});
480+
481+
it('testSuiteStarted Test Suite and locationHint prefix is file://', () => {
482+
resultShouldBe(`##teamcity[testSuiteStarted name='Test Suite' locationHint='file://Example (Tests\\Feature\\Example)' flowId='57317']`, {
483+
event: TestResultEvent.testSuiteStarted,
484+
id: 'Test Suite',
485+
testId: 'Test Suite',
486+
name: 'Test Suite',
487+
flowId: 57317,
488+
});
489+
});
490+
});
469491
});

src/PHPUnit/TestParser/Transformers/PestTransformer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { TransformerFactory } from './TransformerFactory';
66
export class PestTransformer extends PHPUnitTransformer {
77
fromLocationHit(locationHint: string, name: string) {
88
let file = '';
9-
const matched = locationHint.match(/pest_qn:\/\/(?<id>(?<prefix>\w+)\s+\((?<classFQN>[\w\\]+)\)(::(?<method>.+))?)/);
9+
const matched = locationHint.match(/(pest_qn|file):\/\/(?<id>(?<prefix>\w+)\s+\((?<classFQN>[\w\\]+)\)(::(?<method>.+))?)/);
1010
if (!matched) {
11-
const id = locationHint.replace(/pest_qn:\/\//, '').replace(/\\/g, '/');
11+
const id = locationHint.replace(/(pest_qn|file):\/\//, '').replace(/\\/g, '/');
1212
const testId = id;
1313
file = id.split('::')[0];
1414

src/PHPUnit/TestParser/Transformers/TransformerFactory.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import { PHPUnitTransformer } from './PHPUnitTransformer';
33

44
export abstract class TransformerFactory {
55
static isPest(text: string) {
6-
return /^pest|^P\\|pest_qn:\/\//i.test(text);
6+
return new RegExp([
7+
'^pest',
8+
'^P\\\\',
9+
'^pest_qn:\/\/',
10+
'^file:\/\/',
11+
].join('|'), 'i').test(text);
712
}
813

914
static factory(text: string) {

src/PHPUnit/__tests__/fixtures/pest-stub/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "project",
44
"require-dev": {
55
"mockery/mockery": "^1.5 || 1.3",
6-
"pestphp/pest": "^3.6"
6+
"pestphp/pest": "^2.36 || ^3.6"
77
},
88
"license": "MIT",
99
"autoload": {

0 commit comments

Comments
 (0)