🐘
PHPモックフレームワークPhakeのSublime Text補完
PHPUnit で使えるモックフレームワーク"Phake"が PHPUnit 標準のモック機構より便利で書きやすかったので、もっと自分に勢いを付けるためにと Sublime Text 補完を作成しました。Phake リファレンスに書かれているものは恐らく全て補完できると思います。
せっかくなので使い方なども書きたいところですが、まだ自分でも理解していない API が含まれるので、これはまたの機会に。私はこのスライドで Phake の魅力に気付きました。
{
"scope": "source.php",
"completions": [
{ "trigger": "Phake::mock\tPhake", "contents": "Phake::mock(${1});" },
{
"trigger": "Phake::mock ifUnstubbed\tPhake",
"contents": "Phake::mock(${1}, Phake::ifUnstubbed(${2})->thenReturn(${3}));"
},
{
"trigger": "Phake::partialMock\tPhake",
"contents": "Phake::partialMock(${1}, ${2})"
},
{ "trigger": "Phake::when\tPhake", "contents": "Phake::when(${1})" },
{
"trigger": "Phake::when thenReturn\tPhake",
"contents": "Phake::when(${1})->${2}(${3})->thenReturn(${4});"
},
{
"trigger": "Phake::when thenThrow\tPhake",
"contents": "Phake::when(${1})->${2}(${3})->thenThrow(new ${4:Exception}(${5}));"
},
{
"trigger": "Phake::when thenCallParent\tPhake",
"contents": "Phake::when(${1})->${2}(${3})->thenCallParent();"
},
{
"trigger": "Phake::whenCallMethodWith\tPhake",
"contents": "Phake::whenCallMethodWith(${1})->isCalledOn(${2})->thenReturn(${3});"
},
{
"trigger": "Phake::setReference\tPhake",
"contents": "Phake::setReference(${1})"
},
{
"trigger": "Phake::setReference when\tPhake",
"contents": "Phake::setReference(${1})->when(${2})"
},
{ "trigger": "Phake::verify\tPhake", "contents": "Phake::verify(${1})" },
{
"trigger": "Phake::verify()->();\tPhake",
"contents": "Phake::verify(${1})->${2}(${3});"
},
{
"trigger": "Phake::verify(times)->();\tPhake",
"contents": "Phake::verify(${1}, Phake::times(${2}))->${3}(${4});"
},
{
"trigger": "Phake::verify(atLeast)->();\tPhake",
"contents": "Phake::verify(${1}, Phake::atLeast(${2}))->${3}(${4});"
},
{
"trigger": "Phake::verify(atMost)->();\tPhake",
"contents": "Phake::verify(${1}, Phake::atMost(${2}))->${3}(${4});"
},
{
"trigger": "Phake::verify(never)->();\tPhake",
"contents": "Phake::verify(${1}, Phake::never())->${2}(${3});"
},
{ "trigger": "Phake::times\tPhake", "contents": "Phake::times(${1})" },
{ "trigger": "Phake::atLeast\tPhake", "contents": "Phake::atLeast(${1})" },
{ "trigger": "Phake::atMost\tPhake", "contents": "Phake::atMost(${1})" },
{ "trigger": "Phake::never\tPhake", "contents": "Phake::never()${1}" },
{
"trigger": "Phake::verifyCallMethodWith\tPhake",
"contents": "Phake::verifyCallMethodWith(${1})->isCalledOn(${2});"
},
{ "trigger": "Phake::inOrder\tPhake", "contents": "Phake::inOrder(${1});" },
{ "trigger": "Phake::capture\tPhake", "contents": "Phake::capture(${1})" },
{
"trigger": "Phake::capture when\tPhake",
"contents": "Phake::capture(${1})->when(${2})"
},
{
"trigger": "Phake::anyParameters\tPhake",
"contents": "Phake::anyParameters()"
}
]
}
.sublime-completions
をそのまま載せているのでコピペしてお好みに改変して使ってください。
--
Discussion