Esempio n. 1
0
$t->expect('LimeMockException');
// test
$m->testMethod(1);
// @Test: If a class with the mock's control methods is mocked, an exception is thrown
// test
$t->expect('LogicException');
$m = LimeMock::create('TestClassWithControlMethods');
// @Test: If a class with the mock's control methods is mocked and "generate_controls" is set to false, no exception is thrown
// test
$m = LimeMock::create('TestClassWithControlMethods', array('generate_controls' => false));
// @Test: The control methods like ->replay() can be mocked
// fixtures
$m = LimeMock::create('TestClass', array('generate_controls' => false));
// test
$m->replay()->returns('Foobar');
LimeMock::replay($m);
$value = $m->replay();
// assertions
$t->is($value, 'Foobar', 'The return value was correct');
// @Test: If no method call is expected, all method calls are ignored
// test
$m->replay();
$m->testMethod1();
$m->testMethod2(1, 'Foobar');
$m->verify();
// assertions
$t->is(count($m->__lime_getInvocationTrace()), 0, 'No test passed');
// @Test: If setExpectNothing() is called, no method must be called
// fixture
$m->setExpectNothing();
$m->replay();