本文整理汇总了PHP中MyTextSanitizer::loadConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP MyTextSanitizer::loadConfig方法的具体用法?PHP MyTextSanitizer::loadConfig怎么用?PHP MyTextSanitizer::loadConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyTextSanitizer
的用法示例。
在下文中一共展示了MyTextSanitizer::loadConfig方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MyTextSanitizer
function test_load()
{
$ts = new MyTextSanitizer();
$instance = new $this->myclass($ts);
$this->assertInstanceOf($this->myclass, $instance);
$censorConf = null;
$xoops = Xoops::getInstance();
if (!isset($censorConf)) {
$censorConf = $xoops->getConfigs();
$config = $ts->loadConfig(dirname(__FILE__));
//merge and allow config override
$censorConf = array_merge($censorConf, $config);
}
$censorConf['censor_enable'] = 0;
$text = 'text';
$value = $instance->load($ts, $text, $censorConf);
$this->assertSame($text, $value);
$censorConf['censor_enable'] = 1;
$censorConf['censor_words'] = null;
$text = 'text';
$value = $instance->load($ts, $text, $censorConf);
$this->assertSame($text, $value);
$censorConf['censor_enable'] = 1;
$censorConf['censor_words'] = array('shit', 'fuck');
$text = 'text';
$value = $instance->load($ts, $text, $censorConf);
$this->assertSame($text, $value);
$censorConf['censor_enable'] = 1;
$censorConf['censor_words'] = array('shit', 'fuck');
$censorConf['censor_admin'] = 1;
$text = 'text';
$value = $instance->load($ts, $text, $censorConf);
$this->assertSame($text, $value);
$censorConf['censor_enable'] = 1;
$censorConf['censor_words'] = array('shit', 'fuck');
$censorConf['censor_admin'] = 0;
$replacement = empty($censorConf['censor_replace']) ? '##censor##' : $censorConf['censor_replace'];
$text = 'text with fuck and shit and fuck';
$value = $instance->load($ts, $text, $censorConf);
$this->assertTrue(strpos($value, 'fuck') === false);
$this->assertTrue(strpos($value, 'shit') === false);
$this->assertTrue(strpos($value, $replacement) !== false);
}