$m = LimeMock::create('TestInterfaceWithTypeHints'); // assertions $t->ok($m instanceof TestInterfaceWithTypeHints, 'The mock implements the interface'); // @Test: Methods with reference parameters can be mocked // test $m = LimeMock::create('TestInterfaceWithReferenceParameters'); // assertions $t->ok($m instanceof TestInterfaceWithReferenceParameters, 'The mock implements the interface'); // @Test: Methods with default values can be mocked // test $m = LimeMock::create('TestInterfaceWithDefaultValues'); // assertions $t->ok($m instanceof TestInterfaceWithDefaultValues, 'The mock implements the interface'); // @Test: Mocking of classes does not trigger autoloading // fixtures TestAutoloader::$calls = 0; // test $m = LimeMock::create('Foobar'); // assertions $t->is(TestAutoloader::$calls, 0, 'The autoloader was not called'); // @Test: Methods in the mocked class are not called // fixtures $m->calls = 0; // test $m->testMethod(); $m->replay(); $m->testMethod(); // assertions $t->is($m->calls, 0, 'The method has not been called'); // @Test: Unmocked methods in the mocked class are called if the option "stub_methods" is FALSE // fixtures
/** * Asserts that after loading the a new class its class constructor is called * * The class constructor is expected to set the public atribute * $testClassConstructorState to an expected value. * * @param String $expectedState The expected value of $testClassConstructorState * @param String $class A new class * * @dataProvider provideTestClassConstructor * @see $testClassConstructorState * @return void */ public function testClassConstructor($expectedState, $class) { self::$testClassConstructorState = ''; $this->_autoloaderTestHelper->assertLoadable($class); $this->assertEquals($expectedState, self::$testClassConstructorState); }