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
|
||||
|
||||
# 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:
|
||||
|
@ -27,7 +27,7 @@ snippet ns
|
||||
snippet use
|
||||
use ${1:Foo\Bar\Baz};
|
||||
${0}
|
||||
snippet c
|
||||
snippet c
|
||||
class ${1:`vim_snippets#Filename()`}
|
||||
{
|
||||
${0}
|
||||
@ -571,71 +571,77 @@ snippet CSVIterator
|
||||
|
||||
} // end class
|
||||
|
||||
snippet is
|
||||
snippet is "isset()"
|
||||
isset($1{VISUAL})
|
||||
|
||||
# phpunit
|
||||
snippet ase
|
||||
# phpunit
|
||||
snippet ase "$this->assertEquals()"
|
||||
$this->assertEquals(${1:expected}, ${2:actual});
|
||||
|
||||
snippet asne
|
||||
snippet asne "$this->assertNotEquals()"
|
||||
$this->assertNotEquals(${1:expected}, ${2:actual});
|
||||
|
||||
snippet asf
|
||||
$this->assertFalse(${1:Something});
|
||||
|
||||
snippet ast
|
||||
$this->assertTrue(${1:Something});
|
||||
|
||||
snippet asfex
|
||||
$this->assertFileExists(${1:path/to/file});
|
||||
|
||||
snippet asfnex
|
||||
$this->assertFileNotExists(${1:path/to/file});
|
||||
|
||||
snippet ascon
|
||||
$this->assertContains(${1:Search Value}, ${2:Array or Iterator});
|
||||
|
||||
snippet ashk
|
||||
$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
|
||||
snippet asf "$this->assertFalse()"
|
||||
$this->assertFalse(${1});
|
||||
snippet ast "$this->assertTrue()"
|
||||
$this->assertTrue(${1});
|
||||
snippet asfex "$this->assertFileExists()"
|
||||
$this->assertFileExists(${1:'path/to/file'});
|
||||
snippet asfnex "$this->assertFileNotExists()"
|
||||
$this->assertFileNotExists(${1:'path/to/file'});
|
||||
snippet ascon "$this->assertContains()"
|
||||
$this->assertContains(${1:$needle}, ${2:$haystack});
|
||||
snippet ashk "$this->assertArrayHasKey()"
|
||||
$this->assertArrayHasKey(${1:$key}, ${2:$array});
|
||||
snippet asnhk "$this->assertArrayNotHasKey()"
|
||||
this->assertArrayNotHasKey(${1:$key}, ${2:$array});
|
||||
snippet ascha "$this->assertClassHasAttribute()"
|
||||
$this->assertClassHasAttribute(${1:$attributeName}, '${2:$className}');
|
||||
snippet asi "$this->assertInstanceOf(...)"
|
||||
$this->assertInstanceOf(${1:expected}, ${2:actual});
|
||||
|
||||
snippet tc
|
||||
public function test${1:name_of_the_test}()
|
||||
snippet test "public function testXYZ() { ... }"
|
||||
public function test${1}()
|
||||
{
|
||||
${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}");
|
||||
|
||||
snippet fpc "file_put_contents" b
|
||||
file_put_contents(${1:file}, ${2:content}${3:, FILE_APPEND});$0
|
||||
|
||||
snippet sr "str_replace"
|
||||
str_replace(${1:search}, ${2:replace}, ${3:subject})$0
|
||||
|
||||
snippet ia "in_array"
|
||||
in_array(${1:needle}, ${2:haystack})$0
|
||||
|
||||
snippet is "isset"
|
||||
isset(${1:var})$0
|
||||
|
||||
snippet isa "isset array"
|
||||
isset($${1:array}[${2:key}])$0
|
||||
|
||||
snippet in "is_null"
|
||||
is_null($${1:var})$0
|
||||
|
||||
snippet fe "file_exists"
|
||||
file_exists(${1:file})$0
|
||||
|
||||
snippet id "is_dir"
|
||||
is_dir(${1:path})$0
|
||||
|
Loading…
Reference in New Issue
Block a user