I apologies in advance for this. A God Method just fits the API which
doesn't require differentiating between classes, interfaces, abstracts,
names or partials - just so long as it's something that can be mocked.
I'll refactor it one day so it's easier to follow.
public mock ( ) : |
||
Результат |
public function testShouldIgnoreMissingCallingNonExistentMethods() { Mockery::getConfiguration()->allowMockingNonExistentMethods(true); $mock = $this->container->mock('ClassWithMethods')->shouldIgnoreMissing(); assertThat(nullValue($mock->foo())); assertThat(nullValue($mock->bar())); assertThat(nullValue($mock->nonExistentMethod())); $mock->shouldReceive(array('foo' => 'new_foo', 'nonExistentMethod' => 'result')); $mock->shouldReceive('bar')->passthru(); assertThat($mock->foo(), equalTo('new_foo')); assertThat($mock->bar(), equalTo('bar')); assertThat($mock->nonExistentMethod(), equalTo('result')); }
/** * @test */ public function itShouldAllowNullableClassToBeNull() { $mock = $this->container->mock("test\\Mockery\\Fixtures\\MethodWithNullableReturnType"); $mock->shouldReceive('nullableClass')->andReturn(null); $mock->nullableClass(); }