Skip to content

Instantly share code, notes, and snippets.

@andersonfraga
Created September 4, 2012 21:47
Show Gist options
  • Save andersonfraga/3627001 to your computer and use it in GitHub Desktop.
Save andersonfraga/3627001 to your computer and use it in GitHub Desktop.
Sublime Snippets
<snippet>
<content><![CDATA[${1:namespace ${2:Bar\Foo};
}
class ${3:ClassName}${4: extends ${5:AnotherClass}}
{
${6:/***
* $7
*/}
function ${8:__construct}(${9:argument}) {
${0:# code...}
}
};]]></content>
<tabTrigger>class</tabTrigger>
<scope>source.php</scope>
<description>class …</description>
</snippet>
<!--
phpunit-test-with-data
A time-saving snippet for adding new tests with a data provider to your unit test class
HOW TO USE
In your PHP class, simply type the following:
phpunit-test-with-data<TAB><testcase-name>
Sublime Text will add the new test method to your file, and
give the method the name that you choose.
-->
<snippet>
<content><![CDATA[
/**
* ${3:[testcase-description]}
*
* @dataProvider ${1:[dataProviderMethod]}
*
* @return void
*/
public function test${2:[testcase-name]}()
{
// setup your test
// pre-conditions
// perform the change
// test the results
}
/**
* Data Provider for test$2
*
* @return array
*/
public function ${1:[dataProviderMethod]}()
{
return array(
array()
);
}
]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>testdata</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.php</scope>
<!-- Optional: Description to show in the menu -->
<description>Create a skeleton test method with a data provider</description>
</snippet>
<!--
phpunit-test
A time-saving snippet for adding new tests to your unit test class
HOW TO USE
In your PHP class, simply type the following:
phpunit-test<TAB><testcase-name>
Sublime Text will add the new test method to your file, and
give the method the name that you choose.
-->
<snippet>
<content><![CDATA[
public function test${1:[testcase-name]}()
{
// ----------------------------------------------------------------
// setup your test
//
// explain your test setup here if needed ...
// ----------------------------------------------------------------
// perform the change
//
// explain your test here if needed ...
// ----------------------------------------------------------------
// test the results
//
// explain what you expect to have happened
}
]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>test</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.php</scope>
<!-- Optional: Description to show in the menu -->
<description>Create a skeleton test method</description>
</snippet>
<!--
phpunit-testsuite
A time-saving device for creating skeleton PHPUnit TestCase classes
HOW TO USE
In your PHP class, simply type the following:
phpunit-testcase<TAB><classname>
Sublime Text will add the new TestCase class to your file, and
give the class the name that you choose.
-->
<snippet>
<content><![CDATA[
class ${1:[ClassName]}Test extends PHPUnit_Framework_TestCase {
public function setUp() {
// your code here
}
public function tearDown() {
// your code here
}
public function test${2:[testcase-name]}() {
// ----------------------------------------------------------------
// setup your test
//
// explain your test setup here if needed ...
// ----------------------------------------------------------------
// perform the change
//
// explain your test here if needed ...
// ----------------------------------------------------------------
// test the results
//
// explain what you expect to have happened
}
};
]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>testcase</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.php</scope>
<!-- Optional: Description to show in the menu -->
<description>Create a skeleton TestCase class</description>
</snippet>
<snippet>
<content><![CDATA[return ($1) ? $2 : $3;$0]]></content>
<tabTrigger>ret?</tabTrigger>
<scope>source.php</scope>
<description>return ternary</description>
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment