-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
754fd77
commit 5091b0f
Showing
3,083 changed files
with
241,869 additions
and
36 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
.vscode-test/ | ||
.vsix | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,134 @@ | ||
/* global suite, test */ | ||
const assert = require('assert'); | ||
const vscode = require('vscode'); | ||
const path = require('path'); | ||
const extension = require('../src/extension'); | ||
|
||
// | ||
// Note: This example test is leveraging the Mocha test framework. | ||
// Please refer to their documentation on https://mochajs.org/ for help. | ||
// | ||
suite("Better PHPUnit Test Suite", function() { | ||
|
||
// The module 'assert' provides assertion methods from node | ||
const assert = require('assert'); | ||
test("Run file outside of method", function (done) { | ||
this.timeout(8000); | ||
vscode.workspace.openTextDocument(path.join(vscode.workspace.rootPath, 'tests', 'SampleTest.php')) | ||
.then((document) => { | ||
vscode.window.showTextDocument(document).then(() => { | ||
vscode.commands.executeCommand('better-phpunit.run').then(() => { | ||
setTimeout(() => { | ||
assert.ok(extension.getCurrentCommandInstance().methodName === undefined); | ||
done(); | ||
}, 1000); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
// You can import and use all API from the 'vscode' module | ||
// as well as import your extension to test it | ||
const vscode = require('vscode'); | ||
const myExtension = require('../extension'); | ||
test("Run from within first method", function(done) { | ||
vscode.workspace.openTextDocument(path.join(vscode.workspace.rootPath, 'tests', 'SampleTest.php')) | ||
.then((document) => { | ||
vscode.window.showTextDocument(document, {selection: new vscode.Range(7, 0, 7, 0)}).then(() => { | ||
vscode.commands.executeCommand('better-phpunit.run').then(() => { | ||
setTimeout(() => { | ||
assert.equal('test_first', extension.getCurrentCommandInstance().methodName); | ||
done(); | ||
}, 1000); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
test("Run from within second method", function (done) { | ||
vscode.workspace.openTextDocument(path.join(vscode.workspace.rootPath, 'tests', 'SampleTest.php')) | ||
.then((document) => { | ||
vscode.window.showTextDocument(document, { selection: new vscode.Range(12, 0, 12, 0) }).then(() => { | ||
vscode.commands.executeCommand('better-phpunit.run').then(() => { | ||
setTimeout(() => { | ||
assert.equal('test_second', extension.getCurrentCommandInstance().methodName); | ||
done(); | ||
}, 1000); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
// Defines a Mocha test suite to group tests of similar kind together | ||
suite("Extension Tests", function() { | ||
test("Detect filename", function (done) { | ||
vscode.workspace.openTextDocument(path.join(vscode.workspace.rootPath, 'tests', 'SampleTest.php')) | ||
.then((document) => { | ||
vscode.window.showTextDocument(document).then(() => { | ||
vscode.commands.executeCommand('better-phpunit.run').then(() => { | ||
setTimeout(() => { | ||
assert.equal('/Users/calebporzio/Documents/Code/sites/better-phpunit/test/project-stub/tests/SampleTest.php', extension.getCurrentCommandInstance().fileName); | ||
done(); | ||
}, 1000); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
test("Detect filename with a space", function (done) { | ||
vscode.workspace.openTextDocument(path.join(vscode.workspace.rootPath, 'tests', 'File With Spaces Test.php')) | ||
.then((document) => { | ||
vscode.window.showTextDocument(document).then(() => { | ||
vscode.commands.executeCommand('better-phpunit.run').then(() => { | ||
setTimeout(() => { | ||
assert.equal('/Users/calebporzio/Documents/Code/sites/better-phpunit/test/project-stub/tests/FileXX WithXX SpacesXX Test.php', extension.getCurrentCommandInstance().fileName.replace(/\\/g, 'XX')); | ||
done(); | ||
}, 1000); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
test("Detect executable", function (done) { | ||
vscode.workspace.openTextDocument(path.join(vscode.workspace.rootPath, 'tests', 'SampleTest.php')) | ||
.then((document) => { | ||
vscode.window.showTextDocument(document).then(() => { | ||
vscode.commands.executeCommand('better-phpunit.run').then(() => { | ||
setTimeout(() => { | ||
assert.equal('/Users/calebporzio/Documents/Code/sites/better-phpunit/test/project-stub/vendor/bin/phpunit', extension.getCurrentCommandInstance().executablePath); | ||
done(); | ||
}, 1000); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
test("Detect executable in sub-directory", function (done) { | ||
vscode.workspace.openTextDocument(path.join(vscode.workspace.rootPath, 'sub-directory', 'tests', 'SampleTest.php')) | ||
.then((document) => { | ||
vscode.window.showTextDocument(document).then(() => { | ||
vscode.commands.executeCommand('better-phpunit.run').then(() => { | ||
setTimeout(() => { | ||
assert.equal('/Users/calebporzio/Documents/Code/sites/better-phpunit/test/project-stub/sub-directory/vendor/bin/phpunit', extension.getCurrentCommandInstance().executablePath); | ||
done(); | ||
}, 1000); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
test("Full command", function (done) { | ||
vscode.workspace.openTextDocument(path.join(vscode.workspace.rootPath, 'tests', 'SampleTest.php')) | ||
.then((document) => { | ||
vscode.window.showTextDocument(document, { selection: new vscode.Range(7, 0, 7, 0) }).then(() => { | ||
vscode.commands.executeCommand('better-phpunit.run').then(() => { | ||
setTimeout(() => { | ||
assert.equal("/Users/calebporzio/Documents/Code/sites/better-phpunit/test/project-stub/vendor/bin/phpunit /Users/calebporzio/Documents/Code/sites/better-phpunit/test/project-stub/tests/SampleTest.php --filter '^.*::test_first$'", extension.getCurrentCommandInstance().shellCommand); | ||
done(); | ||
}, 1000); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
// Defines a Mocha unit test | ||
test("Something 1", function() { | ||
assert.equal(-1, [1, 2, 3].indexOf(5)); | ||
assert.equal(-1, [1, 2, 3].indexOf(0)); | ||
test("Run previous", function (done) { | ||
vscode.workspace.openTextDocument(path.join(vscode.workspace.rootPath, 'tests', 'OtherTest.php')) | ||
.then((document) => { | ||
vscode.window.showTextDocument(document, { selection: new vscode.Range(12, 0, 12, 0) }).then(() => { | ||
vscode.commands.executeCommand('better-phpunit.run-previous').then(() => { | ||
setTimeout(() => { | ||
assert.equal("/Users/calebporzio/Documents/Code/sites/better-phpunit/test/project-stub/vendor/bin/phpunit /Users/calebporzio/Documents/Code/sites/better-phpunit/test/project-stub/tests/SampleTest.php --filter '^.*::test_first$'", extension.getCurrentCommandInstance().shellCommand); | ||
done(); | ||
}, 1000); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "calebporzio/project-stub", | ||
"description": "Test environment for Better PHPUnit VS Code extension", | ||
"authors": [ | ||
{ | ||
"name": "Caleb Porzio", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"phpunit/phpunit": "^6.4" | ||
} | ||
} |
Oops, something went wrong.