public function expectWithMethodTimes() { $target = \Enhance\Expect::method('TestA')->times(1); \Enhance\Assert::isFalse($target->ExpectArguments); \Enhance\Assert::isTrue($target->ExpectTimes); \Enhance\Assert::areIdentical(1, $target->ExpectedCalls); }
public function verifyWithAMock() { $mock = \Enhance\MockFactory::createMock('ExampleDependencyClass'); $mock->addExpectation(\Enhance\Expect::method('getSomething')->with(1, 'Arg2')->returns('Something')->times(1)); $target = new ExampleClass($mock); $result = $target->doSomething(); $mock->verifyExpectations(); }
public function createStubExpectCallsSucceed() { /** @var IMockExample $stub */ $stub = \Enhance\StubFactory::createStub('ExampleClass'); $stub->addExpectation(\Enhance\Expect::method('doSomething')->returns('Some Value')); $stub->addExpectation(\Enhance\Expect::method('anotherMethod')->returns(5)); $result1 = $stub->doSomething(); $result2 = $stub->doSomething(); $result3 = $stub->anotherMethod(); $stub->callNotExpectedMethod(); \Enhance\Assert::areIdentical('Some Value', $result1); \Enhance\Assert::areIdentical('Some Value', $result2); \Enhance\Assert::areIdentical(5, $result3); }