Mar*_*yne 1 php tdd phpunit unit-testing mockery
我有下面的代码,我希望在运行时失败,因为类DoesNothing不使用mock类或调用任何必需的方法.
<?php
class DoesNothing
{
}
class DoesNothingTest extends YourMockeryTestCase
{
/**
* @test
*/
public function somethingIsCalled()
{
$this->mock = Mockery::mock();
$keys = array(
'1234',
'abcxyz',
'*&(%&^$-*/~@:{}',
')*&GA^FAUIB(*',
'',
' ',
);
foreach ($keys as $key) {
$this->mock
->shouldReceive('remove')
->atLeast()->times(1)
->with($key);
}
$var = new DoesNothing($this->mock);
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行它时,它会通过.我希望它能说"没有调用方法删除"等.
可能有什么不对?与Mockery如何与PHPUnit谈话有关?
谢谢,马丁
编辑:我也提到我们正在使用Etsy的PHPExtensions将它集成到PHPUnit中
您的方法名称应该以test,否则PHPUnit不会将其确定为测试.
public function testSomethingIsCalled()
Run Code Online (Sandbox Code Playgroud)
编辑
你必须调用Mockery::close()你的拆解方法来执行期望.即
/**
* Tear down
*/
public function tearDown()
{
\Mockery::close();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
221 次 |
| 最近记录: |