Tidied up and consolidated snippets for PHPUnit
This commit is contained in:
parent
3b7c903c35
commit
120ead2c37
@ -1,76 +0,0 @@
|
|||||||
# suggestion? report bugs?
|
|
||||||
# please go to https://github.com/chrisyue/vim-snippets/issues
|
|
||||||
#
|
|
||||||
# to use add the following to your .vimrc
|
|
||||||
# `autocmd BufRead,BufNewFile,BufEnter *Test.php UltiSnipsAddFiletypes php-phpunit`
|
|
||||||
priority -50
|
|
||||||
|
|
||||||
snippet testcase "class XYZTest extends \PHPUnit_Framework_TestCase { ... }"
|
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace `!p
|
|
||||||
relpath = os.path.relpath(path)
|
|
||||||
m = re.search(r'[A-Z].+(?=/)', relpath)
|
|
||||||
if m:
|
|
||||||
snip.rv = m.group().replace('/', '\\')
|
|
||||||
`;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author `!v g:snips_author`
|
|
||||||
*/
|
|
||||||
class `!p
|
|
||||||
snip.rv = re.match(r'.*(?=\.)', fn).group()
|
|
||||||
` extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
public function test${1}()
|
|
||||||
{
|
|
||||||
${0:${VISUAL}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet test "public function testXYZ() { ... }"
|
|
||||||
public function test${1}()
|
|
||||||
{
|
|
||||||
${0:${VISUAL}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet setup "protected function setUp() { ... }"
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
${0:${VISUAL}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet teardown "protected function tearDown() { ... }"
|
|
||||||
protected function tearDown()
|
|
||||||
{
|
|
||||||
${0:${VISUAL}}
|
|
||||||
}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet exp "phpunit expects" i
|
|
||||||
expects($this->${1:once}())
|
|
||||||
->method('${2}')
|
|
||||||
->with($this->equalTo(${3})${4})
|
|
||||||
->will($this->returnValue(${5}));
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet testcmt "phpunit comment with group" b
|
|
||||||
/**
|
|
||||||
* @group ${1}
|
|
||||||
*/
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet fail "$this->fail()"
|
|
||||||
$this->fail(${1});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet marki "$this->markTestIncomplete()"
|
|
||||||
$this->markTestIncomplete(${1});
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet marks "$this->markTestSkipped()"
|
|
||||||
$this->markTestSkipped(${1});
|
|
||||||
endsnippet
|
|
@ -363,4 +363,29 @@ snippet inheritdoc "@inheritdoc docblock"
|
|||||||
*/
|
*/
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
# PHPUnit snippets
|
||||||
|
snippet testcase "class XYZTest extends \PHPUnit_Framework_TestCase { ... }"
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace `!p
|
||||||
|
relpath = os.path.relpath(path)
|
||||||
|
m = re.search(r'[A-Z].+(?=/)', relpath)
|
||||||
|
if m:
|
||||||
|
snip.rv = m.group().replace('/', '\\')
|
||||||
|
`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author `!v g:snips_author`
|
||||||
|
*/
|
||||||
|
class `!p
|
||||||
|
snip.rv = re.match(r'.*(?=\.)', fn).group()
|
||||||
|
` extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function test${1}()
|
||||||
|
{
|
||||||
|
${0:${VISUAL}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
# :vim:ft=snippets:
|
# :vim:ft=snippets:
|
||||||
|
@ -27,7 +27,7 @@ snippet ns
|
|||||||
snippet use
|
snippet use
|
||||||
use ${1:Foo\Bar\Baz};
|
use ${1:Foo\Bar\Baz};
|
||||||
${0}
|
${0}
|
||||||
snippet c
|
snippet c
|
||||||
class ${1:`vim_snippets#Filename()`}
|
class ${1:`vim_snippets#Filename()`}
|
||||||
{
|
{
|
||||||
${0}
|
${0}
|
||||||
@ -571,71 +571,77 @@ snippet CSVIterator
|
|||||||
|
|
||||||
} // end class
|
} // end class
|
||||||
|
|
||||||
snippet is
|
snippet is "isset()"
|
||||||
isset($1{VISUAL})
|
isset($1{VISUAL})
|
||||||
|
|
||||||
# phpunit
|
# phpunit
|
||||||
snippet ase
|
snippet ase "$this->assertEquals()"
|
||||||
$this->assertEquals(${1:expected}, ${2:actual});
|
$this->assertEquals(${1:expected}, ${2:actual});
|
||||||
|
snippet asne "$this->assertNotEquals()"
|
||||||
snippet asne
|
|
||||||
$this->assertNotEquals(${1:expected}, ${2:actual});
|
$this->assertNotEquals(${1:expected}, ${2:actual});
|
||||||
|
snippet asf "$this->assertFalse()"
|
||||||
snippet asf
|
$this->assertFalse(${1});
|
||||||
$this->assertFalse(${1:Something});
|
snippet ast "$this->assertTrue()"
|
||||||
|
$this->assertTrue(${1});
|
||||||
snippet ast
|
snippet asfex "$this->assertFileExists()"
|
||||||
$this->assertTrue(${1:Something});
|
$this->assertFileExists(${1:'path/to/file'});
|
||||||
|
snippet asfnex "$this->assertFileNotExists()"
|
||||||
snippet asfex
|
$this->assertFileNotExists(${1:'path/to/file'});
|
||||||
$this->assertFileExists(${1:path/to/file});
|
snippet ascon "$this->assertContains()"
|
||||||
|
$this->assertContains(${1:$needle}, ${2:$haystack});
|
||||||
snippet asfnex
|
snippet ashk "$this->assertArrayHasKey()"
|
||||||
$this->assertFileNotExists(${1:path/to/file});
|
$this->assertArrayHasKey(${1:$key}, ${2:$array});
|
||||||
|
snippet asnhk "$this->assertArrayNotHasKey()"
|
||||||
snippet ascon
|
this->assertArrayNotHasKey(${1:$key}, ${2:$array});
|
||||||
$this->assertContains(${1:Search Value}, ${2:Array or Iterator});
|
snippet ascha "$this->assertClassHasAttribute()"
|
||||||
|
$this->assertClassHasAttribute(${1:$attributeName}, '${2:$className}');
|
||||||
snippet ashk
|
snippet asi "$this->assertInstanceOf(...)"
|
||||||
$this->assertArrayHasKey(${1:key}, ${2:array});
|
|
||||||
|
|
||||||
snippet asnhk
|
|
||||||
this->assertArrayNotHasKey(${1:value}, ${2:array});
|
|
||||||
|
|
||||||
snippet ascha
|
|
||||||
$this->assertClassHasAttribute('${1:Attribute Name}', '${2:ClassName}');
|
|
||||||
|
|
||||||
snippet asi
|
|
||||||
$this->assertInstanceOf(${1:expected}, ${2:actual});
|
$this->assertInstanceOf(${1:expected}, ${2:actual});
|
||||||
|
snippet test "public function testXYZ() { ... }"
|
||||||
snippet tc
|
public function test${1}()
|
||||||
public function test${1:name_of_the_test}()
|
|
||||||
{
|
{
|
||||||
${0:code}
|
${0}
|
||||||
}
|
}
|
||||||
snippet te
|
snippet setup "protected function setUp() { ... }"
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
${0}
|
||||||
|
}
|
||||||
|
snippet teardown "protected function tearDown() { ... }"
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
${0}
|
||||||
|
}
|
||||||
|
snippet exp "phpunit expects"
|
||||||
|
expects($this->${1:once}())
|
||||||
|
->method('${2}')
|
||||||
|
->with($this->equalTo(${3})${4})
|
||||||
|
->will($this->returnValue(${5}));
|
||||||
|
snippet testcmt "phpunit comment with group"
|
||||||
|
/**
|
||||||
|
* @group ${1}
|
||||||
|
*/
|
||||||
|
snippet fail "$this->fail()"
|
||||||
|
$this->fail(${1});
|
||||||
|
snippet marki "$this->markTestIncomplete()"
|
||||||
|
$this->markTestIncomplete(${1});
|
||||||
|
snippet marks "$this->markTestSkipped()"
|
||||||
|
$this->markTestSkipped(${1});
|
||||||
|
# end of phpunit snippets
|
||||||
|
snippet te "throw new Exception()"
|
||||||
throw new ${1:Exception}("${2:Error Processing Request}");
|
throw new ${1:Exception}("${2:Error Processing Request}");
|
||||||
|
|
||||||
snippet fpc "file_put_contents" b
|
snippet fpc "file_put_contents" b
|
||||||
file_put_contents(${1:file}, ${2:content}${3:, FILE_APPEND});$0
|
file_put_contents(${1:file}, ${2:content}${3:, FILE_APPEND});$0
|
||||||
|
|
||||||
snippet sr "str_replace"
|
snippet sr "str_replace"
|
||||||
str_replace(${1:search}, ${2:replace}, ${3:subject})$0
|
str_replace(${1:search}, ${2:replace}, ${3:subject})$0
|
||||||
|
|
||||||
snippet ia "in_array"
|
snippet ia "in_array"
|
||||||
in_array(${1:needle}, ${2:haystack})$0
|
in_array(${1:needle}, ${2:haystack})$0
|
||||||
|
|
||||||
snippet is "isset"
|
snippet is "isset"
|
||||||
isset(${1:var})$0
|
isset(${1:var})$0
|
||||||
|
|
||||||
snippet isa "isset array"
|
snippet isa "isset array"
|
||||||
isset($${1:array}[${2:key}])$0
|
isset($${1:array}[${2:key}])$0
|
||||||
|
|
||||||
snippet in "is_null"
|
snippet in "is_null"
|
||||||
is_null($${1:var})$0
|
is_null($${1:var})$0
|
||||||
|
|
||||||
snippet fe "file_exists"
|
snippet fe "file_exists"
|
||||||
file_exists(${1:file})$0
|
file_exists(${1:file})$0
|
||||||
|
|
||||||
snippet id "is_dir"
|
snippet id "is_dir"
|
||||||
is_dir(${1:path})$0
|
is_dir(${1:path})$0
|
||||||
|
Loading…
Reference in New Issue
Block a user