public function setUp() { self::$_mockCache = array(); $ioc = \Mockery::mock('org_tubepress_api_ioc_IocService'); $ioc->shouldReceive('get')->zeroOrMoreTimes()->andReturnUsing(function ($className) { if (!array_key_exists($className, TubePressUnitTest::$_mockCache)) { org_tubepress_impl_classloader_ClassLoader::loadClass($className); $mock = \Mockery::mock($className); TubePressUnitTest::$_mockCache[$className] = $mock; if (!is_a($mock, $className)) { TubePressUnitTest::fail("Failed to built mock of {$className}"); } } return TubePressUnitTest::$_mockCache[$className]; }); org_tubepress_impl_ioc_IocContainer::setInstance($ioc); }
function testCustomContainer() { org_tubepress_impl_ioc_IocContainer::setInstance(new FakeIocService()); $result = org_tubepress_impl_ioc_IocContainer::getInstance(); $this->assertTrue(is_a($result, 'FakeIocService')); }