Skip to content

Instantly share code, notes, and snippets.

@DCzajkowski
Last active February 18, 2019 18:12
Show Gist options
  • Save DCzajkowski/86fb11e6e5c4aee6b9157364772799ce to your computer and use it in GitHub Desktop.
Save DCzajkowski/86fb11e6e5c4aee6b9157364772799ce to your computer and use it in GitHub Desktop.
# Create a file in Plugins/
# You can run this via Sublime's console with: view.run_command("php_unit_test_method")
# You can bind it to ctrl+e as a regular command
import sublime
import sublime_plugin
class PhpUnitTestMethodCommand(sublime_plugin.TextCommand):
def run(self, edit):
line = self.view.substr(self.view.line(self.view.sel()[0]))
lineSplit = line.split('it', 1)
self.view.replace(edit, self.view.line(self.view.sel()[0]), lineSplit[0] + '/** @test */\n' + lineSplit[0] + 'function ' + 'it' + lineSplit[1].replace(' ', '_') + '() {\n' + lineSplit[0] + ' \n' + lineSplit[0] + '}')
@DCzajkowski
Copy link
Author

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment