-
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
0 parents
commit a1de9e3
Showing
14 changed files
with
3,849 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"env": { | ||
"browser": false, | ||
"commonjs": true, | ||
"es6": true, | ||
"node": true | ||
}, | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"no-const-assign": "warn", | ||
"no-this-before-super": "warn", | ||
"no-undef": "warn", | ||
"no-unreachable": "warn", | ||
"no-unused-vars": "warn", | ||
"constructor-super": "warn", | ||
"valid-typeof": "warn" | ||
} | ||
} |
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,3 @@ | ||
node_modules | ||
.vscode-test/ | ||
.vsix |
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,7 @@ | ||
.vscode/** | ||
.vscode-test/** | ||
test/** | ||
.gitignore | ||
jsconfig.json | ||
vsc-extension-quickstart.md | ||
.eslintrc.json |
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,7 @@ | ||
# Change Log | ||
All notable changes to the "better-phpunit" extension will be documented in this file. | ||
|
||
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. | ||
|
||
## [Unreleased] | ||
- Initial release |
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,25 @@ | ||
# Better PHPUnit | ||
|
||
![Demo GIF](demo.gif) | ||
|
||
## Features: | ||
- Color output! | ||
- Run individual methods by placing your cursor anywhere in the method | ||
- Test failures are displayed in the "Problems" panel for quick access | ||
|
||
> Note: this plugin registers "tasks" to run phpunit, not a command like other extensions. This makes it possible to leverage the problem output and color terminal. | ||
Keybindings: | ||
> Note: you will have to add these bindings to your own `keybindings.json` file, otherwise, the bindings will not work right. | ||
``` | ||
{ | ||
"key": "cmd+k cmd+o", | ||
"command": "workbench.action.tasks.runTask", | ||
"args": "phpunit: method" | ||
}, | ||
{ | ||
"key": "cmd+k cmd+i", | ||
"command": "workbench.action.tasks.runTask", | ||
"args": "phpunit: file" | ||
} | ||
``` |
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,62 @@ | ||
const vscode = require('vscode'); | ||
|
||
function activate(context) { | ||
|
||
let disposable = vscode.commands.registerCommand('extension.sayHello', function () { | ||
vscode.window.showInformationMessage('Hello World!'); | ||
}); | ||
|
||
let provider = vscode.workspace.registerTaskProvider('phpunit', { | ||
provideTasks: () => { | ||
const rootDirectory = vscode.workspace.rootPath; | ||
const fileName = vscode.window.activeTextEditor.document.fileName; | ||
const methodName = getMethodName(vscode.window.activeTextEditor.selection.active.line); | ||
|
||
return [ | ||
new vscode.Task( | ||
{type: "phpunit", task: "file"}, | ||
"file", | ||
'phpunit', | ||
new vscode.ShellExecution(`${rootDirectory}/vendor/bin/phpunit ${fileName}`), | ||
'$phpunit' | ||
), | ||
new vscode.Task( | ||
{ type: "phpunit", task: "method" }, | ||
"method", | ||
'phpunit', | ||
new vscode.ShellExecution(`${rootDirectory}/vendor/bin/phpunit ${fileName} --filter ${methodName}`), | ||
'$phpunit' | ||
), | ||
]; | ||
}, | ||
resolveTask(task) { | ||
return undefined; | ||
} | ||
}); | ||
|
||
context.subscriptions.push([disposable, provider]); | ||
} | ||
exports.activate = activate; | ||
|
||
function deactivate() { | ||
} | ||
exports.deactivate = deactivate; | ||
|
||
function getMethodName(lineNumber) { | ||
let methodName = ''; | ||
let line = lineNumber; | ||
|
||
while (line > 0) { | ||
const lineText = vscode.window.activeTextEditor.document.lineAt(line).text; | ||
const methodMatch = lineText.match(/^.*function\s*(.*)\(/); | ||
const classMatch = lineText.match(/^.*class\s*(\w*)\s*.*$/); | ||
if (methodMatch || classMatch) { | ||
const match = methodMatch || classMatch; | ||
methodName = match[1]; | ||
break; | ||
} | ||
line = line - 1; | ||
} | ||
|
||
return methodName; | ||
} |
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,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es6", | ||
"lib": [ | ||
"es6" | ||
] | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
Oops, something went wrong.