Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Very embryonic progress on PHPUnit execution support

  • Loading branch information...
commit 7db30db691286e88153a202de2da97c0f88c792c 1 parent 398e048
@stuartherbert authored
View
1  .gitignore
@@ -0,0 +1 @@
+*.pyc
View
13 Context.sublime-menu
@@ -0,0 +1,13 @@
+[
+ { "caption": "-" },
+ {
+ "caption": "PHPUnit",
+ "children":
+ [
+ { "command": "phpunit_not_available" },
+ { "command": "phpunit_test_this_class" },
+ { "command": "phpunit_run_all_tests" },
+ { "command": "phpunit_show_output" }
+ ]
+ }
+]
View
5 Default.sublime-commands
@@ -0,0 +1,5 @@
+[
+ { "command": "phpunit_test_this_class" },
+ { "command": "phpunit_run_all_tests" },
+ { "command": "phpunit_show_output" }
+]
View
78 phpunit.py
@@ -0,0 +1,78 @@
+import re
+import sublime
+import sublime_plugin
+
+class PhpunitBase(sublime_plugin.TextCommand):
+ def is_php_buffer(self):
+ # is this a PHP buffer?
+ if re.search('.+\PHP.tmLanguage', self.view.settings().get('syntax')):
+ return True
+ return False
+
+ def window(self):
+ return self.view.window()
+
+ def show_output(self):
+ self.ensure_output_panel()
+ self.window().run_command("show_panel", {"panel": "output.phpunit"})
+
+ def show_empty_output(self):
+ self.ensure_output_panel()
+ self.clear_test_view()
+ self.show_output()
+
+ def ensure_output_panel(self):
+ if not hasattr(self, 'output_window'):
+ self.output_window = self.window().get_output_panel("phpunit")
+
+ def clear_test_view(self):
+ self.output_window.set_read_only(False)
+ edit = self.output_window.begin_edit()
+ self.output_window.erase(edit, sublime.Region(0, self.output_window.size()))
+ self.output_window.end_edit(edit)
+ self.output_window.set_read_only(True)
+
+class PhpunitTestThisClass(PhpunitBase):
+ def run(self, args):
+ self.show_output()
+
+ def description(self):
+ return 'Test This Class...'
+
+ def is_enabled(self):
+ return self.is_php_buffer()
+
+ def is_visible(self):
+ return self.is_php_buffer()
+
+class PhpunitRunAllTestsCommand(PhpunitBase):
+ def run(self, args):
+ self.show_output()
+
+ def description(self):
+ return 'Run All Unit Tests...'
+
+ def is_enabled(self):
+ return self.is_php_buffer()
+
+ def is_visible(self):
+ return self.is_enabled()
+
+class PhpunitShowOutputCommand(PhpunitBase):
+ def run(self, args):
+ self.show_output()
+
+ def description(self):
+ return 'Show Test Output...'
+
+class PhpunitNotAvailableCommand(PhpunitBase):
+ def is_visible(self):
+ if not self.is_php_buffer():
+ return True
+ return False
+
+ def is_enabled(self):
+ return False
+
+ def description(self):
+ return 'PHPUnit tests can only be run on PHP windows'
Please sign in to comment.
Something went wrong with that request. Please try again.