本文整理汇总了PHP中Singleton::dropInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Singleton::dropInstance方法的具体用法?PHP Singleton::dropInstance怎么用?PHP Singleton::dropInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Singleton
的用法示例。
在下文中一共展示了Singleton::dropInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: suite
public static function suite()
{
$suite = new TestSuite('onPHP-' . ONPHP_VERSION);
foreach (self::$paths as $testPath) {
foreach (glob($testPath . '*Test' . EXT_CLASS, GLOB_BRACE) as $file) {
$suite->addTestFile($file);
}
}
// meta, DB and DAOs ordered tests portion
if (self::$dbs) {
try {
Singleton::getInstance('DBTestPool', self::$dbs)->connect();
} catch (Exception $e) {
Singleton::dropInstance('DBTestPool');
Singleton::getInstance('DBTestPool');
}
// build stuff from meta
$metaDir = ONPHP_TEST_PATH . 'meta' . DIRECTORY_SEPARATOR;
$path = ONPHP_META_PATH . 'bin' . DIRECTORY_SEPARATOR . 'build.php';
$_SERVER['argv'] = array();
$_SERVER['argv'][0] = $path;
$_SERVER['argv'][1] = $metaDir . 'config.inc.php';
$_SERVER['argv'][2] = $metaDir . 'config.meta.xml';
$_SERVER['argv'][] = '--force';
$_SERVER['argv'][] = '--no-schema-check';
$_SERVER['argv'][] = '--drop-stale-files';
include $path;
// provide paths to autogenerated stuff
set_include_path(get_include_path() . PATH_SEPARATOR . ONPHP_META_AUTO_BUSINESS_DIR . PATH_SEPARATOR . ONPHP_META_AUTO_DAO_DIR . PATH_SEPARATOR . ONPHP_META_AUTO_PROTO_DIR . PATH_SEPARATOR . ONPHP_META_DAO_DIR . PATH_SEPARATOR . ONPHP_META_BUSINESS_DIR . PATH_SEPARATOR . ONPHP_META_PROTO_DIR);
$daoTest = new DAOTest();
$out = MetaConfiguration::me()->getOutput();
foreach (DBTestPool::me()->getPool() as $connector => $db) {
DBPool::me()->setDefault($db);
$out->info('Using ')->info(get_class($db), true)->infoLine(' connector.');
try {
$daoTest->drop();
} catch (DatabaseException $e) {
// previous shutdown was clean
}
$daoTest->create()->fill(false);
MetaConfiguration::me()->checkIntegrity();
$out->newLine();
$daoTest->drop();
}
DBPool::me()->dropDefault();
}
$suite->addTestSuite('DAOTest');
return $suite;
}
示例2: suite
public static function suite()
{
$suite = new TestSuite('onPHP-' . ONPHP_VERSION);
// meta, DB and DAOs ordered tests portion
if (self::$dbs) {
try {
/**
* @todo fail - constructor with argument, but static method 'me' - without
*/
Singleton::getInstance('DBTestPool', self::$dbs)->connect();
} catch (Exception $e) {
Singleton::dropInstance('DBTestPool');
Singleton::getInstance('DBTestPool');
}
// build stuff from meta
$metaDir = ONPHP_TEST_PATH . 'meta' . DIRECTORY_SEPARATOR;
$path = ONPHP_META_PATH . 'bin' . DIRECTORY_SEPARATOR . 'build.php';
$_SERVER['argv'] = array();
$_SERVER['argv'][0] = $path;
$_SERVER['argv'][1] = $metaDir . 'config.inc.php';
$_SERVER['argv'][2] = $metaDir . 'config.meta.xml';
$_SERVER['argv'][] = '--force';
$_SERVER['argv'][] = '--no-schema-check';
$_SERVER['argv'][] = '--drop-stale-files';
include $path;
AutoloaderPool::get('onPHP')->addPaths(array(ONPHP_META_AUTO_BUSINESS_DIR, ONPHP_META_AUTO_DAO_DIR, ONPHP_META_AUTO_PROTO_DIR, ONPHP_META_DAO_DIR, ONPHP_META_BUSINESS_DIR, ONPHP_META_PROTO_DIR));
$dBCreator = DBTestCreator::create()->setSchemaPath(ONPHP_META_AUTO_DIR . 'schema.php')->setTestPool(DBTestPool::me());
$out = MetaConfiguration::me()->getOutput();
foreach (DBTestPool::me()->getPool() as $connector => $db) {
DBPool::me()->setDefault($db);
$out->info('Using ')->info(get_class($db), true)->infoLine(' connector.');
$dBCreator->dropDB(true);
$dBCreator->createDB()->fillDB();
MetaConfiguration::me()->checkIntegrity();
$out->newLine();
$dBCreator->dropDB();
}
DBPool::me()->dropDefault();
}
foreach (self::$paths as $testPath) {
foreach (glob($testPath . '*Test' . EXT_CLASS, GLOB_BRACE) as $file) {
$suite->addTestFile($file);
}
}
return $suite;
}
示例3: testArguments
public function testArguments()
{
// cleaning up
try {
Singleton::dropInstance(self::SINGLE_CLASS_NAME);
} catch (MissingElementException $e) {
// that's ok for the first pass
}
try {
Singleton::getInstance(self::SINGLE_CLASS_NAME);
$this->fail();
} catch (BaseException $e) {
// pass
}
$this->assertSameInstances(self::SINGLE_CLASS_NAME, Singleton::getInstance(self::SINGLE_CLASS_NAME, 'val1'), Singleton::getInstance(self::SINGLE_CLASS_NAME, 'val2'));
$this->assertSameInstances(self::MULTI_CLASS_NAME, Singleton::getInstance(self::MULTI_CLASS_NAME, 'val1', 'val2', 'val3'), Singleton::getInstance(self::MULTI_CLASS_NAME, 'val1', 'val2'));
}