• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP generate_mock_once函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中generate_mock_once函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_mock_once函数的具体用法?PHP generate_mock_once怎么用?PHP generate_mock_once使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了generate_mock_once函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testURIDefinitionValidation

 function testURIDefinitionValidation()
 {
     $parser = new HTMLPurifier_URIParser();
     $uri = $parser->parse('http://example.com');
     $this->config->set('URI.DefinitionID', 'HTMLPurifier_AttrDef_URITest->testURIDefinitionValidation');
     generate_mock_once('HTMLPurifier_URIDefinition');
     $uri_def = new HTMLPurifier_URIDefinitionMock();
     $uri_def->expectOnce('filter', array($uri, '*', '*'));
     $uri_def->setReturnValue('filter', true, array($uri, '*', '*'));
     $uri_def->expectOnce('postFilter', array($uri, '*', '*'));
     $uri_def->setReturnValue('postFilter', true, array($uri, '*', '*'));
     $uri_def->setup = true;
     // Since definitions are no longer passed by reference, we need
     // to muck around with the cache to insert our mock. This is
     // technically a little bad, since the cache shouldn't change
     // behavior, but I don't feel too good about letting users
     // overload entire definitions.
     generate_mock_once('HTMLPurifier_DefinitionCache');
     $cache_mock = new HTMLPurifier_DefinitionCacheMock();
     $cache_mock->setReturnValue('get', $uri_def);
     generate_mock_once('HTMLPurifier_DefinitionCacheFactory');
     $factory_mock = new HTMLPurifier_DefinitionCacheFactoryMock();
     $old = HTMLPurifier_DefinitionCacheFactory::instance();
     HTMLPurifier_DefinitionCacheFactory::instance($factory_mock);
     $factory_mock->setReturnValue('create', $cache_mock);
     $this->assertDef('http://example.com');
     HTMLPurifier_DefinitionCacheFactory::instance($old);
 }
开发者ID:rakesh-mohanta,项目名称:scalr,代码行数:28,代码来源:URITest.php


示例2: test

 function test()
 {
     generate_mock_once('HTMLPurifier_URIScheme');
     $config = HTMLPurifier_Config::create(array('URI.AllowedSchemes' => 'http, telnet', 'URI.OverrideAllowedSchemes' => true));
     $context = new HTMLPurifier_Context();
     $registry = new HTMLPurifier_URISchemeRegistry();
     $this->assertIsA($registry->getScheme('http', $config, $context), 'HTMLPurifier_URIScheme_http');
     $scheme_http = new HTMLPurifier_URISchemeMock();
     $scheme_telnet = new HTMLPurifier_URISchemeMock();
     $scheme_foobar = new HTMLPurifier_URISchemeMock();
     // register a new scheme
     $registry->register('telnet', $scheme_telnet);
     $this->assertIdentical($registry->getScheme('telnet', $config, $context), $scheme_telnet);
     // overload a scheme, this is FINAL (forget about defaults)
     $registry->register('http', $scheme_http);
     $this->assertIdentical($registry->getScheme('http', $config, $context), $scheme_http);
     // when we register a scheme, it's automatically allowed
     $registry->register('foobar', $scheme_foobar);
     $this->assertIdentical($registry->getScheme('foobar', $config, $context), $scheme_foobar);
     // now, test when overriding is not allowed
     $config = HTMLPurifier_Config::create(array('URI.AllowedSchemes' => 'http, telnet', 'URI.OverrideAllowedSchemes' => false));
     $this->assertNull($registry->getScheme('foobar', $config, $context));
     // scheme not allowed and never registered
     $this->assertNull($registry->getScheme('ftp', $config, $context));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:25,代码来源:URISchemeRegistryTest.php


示例3: test

 public function test()
 {
     generate_mock_once('HTMLPurifier_Strategy');
     generate_mock_once('HTMLPurifier_Config');
     generate_mock_once('HTMLPurifier_Context');
     // setup a bunch of mock strategies to inject into our composite test
     $mock_1 = new HTMLPurifier_StrategyMock();
     $mock_2 = new HTMLPurifier_StrategyMock();
     $mock_3 = new HTMLPurifier_StrategyMock();
     // setup the object
     $strategies = array(&$mock_1, &$mock_2, &$mock_3);
     $composite = new HTMLPurifier_Strategy_Composite_Test($strategies);
     // setup expectations
     $input_1 = 'This is raw data';
     $input_2 = 'Processed by 1';
     $input_3 = 'Processed by 1 and 2';
     $input_4 = 'Processed by 1, 2 and 3';
     // expected output
     $config = new HTMLPurifier_ConfigMock();
     $context = new HTMLPurifier_ContextMock();
     $params_1 = array($input_1, $config, $context);
     $params_2 = array($input_2, $config, $context);
     $params_3 = array($input_3, $config, $context);
     $mock_1->expectOnce('execute', $params_1);
     $mock_1->setReturnValue('execute', $input_2, $params_1);
     $mock_2->expectOnce('execute', $params_2);
     $mock_2->setReturnValue('execute', $input_3, $params_2);
     $mock_3->expectOnce('execute', $params_3);
     $mock_3->setReturnValue('execute', $input_4, $params_3);
     // perform test
     $output = $composite->execute($input_1, $config, $context);
     $this->assertIdentical($input_4, $output);
 }
开发者ID:youprofit,项目名称:casebox,代码行数:33,代码来源:CompositeTest.php


示例4: setUp

 public function setUp()
 {
     parent::setUp();
     generate_mock_once('HTMLPurifier_AttrDef');
     $this->with = new HTMLPurifier_AttrDefMock();
     $this->without = new HTMLPurifier_AttrDefMock();
     $this->def = new HTMLPurifier_AttrDef_Switch('tag', $this->with, $this->without);
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:8,代码来源:SwitchTest.php


示例5: generate_mock_once

 protected function &setUpSchemeRegistryMock()
 {
     $this->oldRegistry = HTMLPurifier_URISchemeRegistry::instance();
     generate_mock_once('HTMLPurifier_URIScheme');
     generate_mock_once('HTMLPurifier_URISchemeRegistry');
     $registry = HTMLPurifier_URISchemeRegistry::instance(new HTMLPurifier_URISchemeRegistryMock());
     return $registry;
 }
开发者ID:patdunlavey,项目名称:Williamstown-Beat,代码行数:8,代码来源:URITest.php


示例6: generateConfigMock

 /**
  * Generate a configuration mock object that returns $values
  * to a getBatch() call
  * @param $values Values to return when getBatch is invoked
  */
 protected function generateConfigMock($serial = 'defaultserial')
 {
     generate_mock_once('HTMLPurifier_Config');
     $config = new HTMLPurifier_ConfigMock();
     $config->setReturnValue('getBatchSerial', $serial, array('Test'));
     $config->version = '1.0.0';
     return $config;
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:13,代码来源:DefinitionCacheHarness.php


示例7: test_register

 public function test_register()
 {
     generate_mock_once('HTMLPurifier_DefinitionCache');
     $this->config->set('Cache.DefinitionImpl', 'TestCache');
     $this->factory->register('TestCache', $class = 'HTMLPurifier_DefinitionCacheMock');
     $cache = $this->factory->create('Test', $this->config);
     $this->assertIsA($cache, $class);
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:8,代码来源:DefinitionCacheFactoryTest.php


示例8: setUp

 public function setUp()
 {
     parent::setUp();
     $this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
     $this->config->set('AutoFormat.AutoParagraph', true);
     $this->config->set('AutoFormat.Linkify', true);
     $this->config->set('AutoFormat.RemoveEmpty', true);
     generate_mock_once('HTMLPurifier_Injector');
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:9,代码来源:MakeWellFormed_InjectorTest.php


示例9: test_addFilter_deprecated

 function test_addFilter_deprecated()
 {
     $this->expectError('HTMLPurifier->addFilter() is deprecated, use configuration directives in the Filter namespace or Filter.Custom');
     generate_mock_once('HTMLPurifier_Filter');
     $this->purifier->addFilter($mock = new HTMLPurifier_FilterMock());
     $mock->expectOnce('preFilter');
     $mock->expectOnce('postFilter');
     $this->purifier->purify('foo');
 }
开发者ID:odsherred,项目名称:subsites.odsherred.dk,代码行数:9,代码来源:HTMLPurifierTest.php


示例10: setup

 public function setup()
 {
     $this->config = HTMLPurifier_Config::create(array('Core.CollectErrors' => true));
     $this->context = new HTMLPurifier_Context();
     generate_mock_once('HTMLPurifier_ErrorCollector');
     $this->collector = new HTMLPurifier_ErrorCollectorEMock();
     $this->collector->prepare($this->context);
     $this->context->register('ErrorCollector', $this->collector);
     $this->callCount = 0;
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:10,代码来源:ErrorsHarness.php


示例11: createManager

 protected function createManager()
 {
     $manager = new HTMLPurifier_HTMLModuleManager();
     $this->config->set('HTML.CustomDoctype', 'Blank');
     $manager->doctypes->register('Blank');
     $attrdef_nmtokens = new HTMLPurifier_AttrDef_HTML_Nmtokens();
     generate_mock_once('HTMLPurifier_AttrDef');
     $attrdef = new HTMLPurifier_AttrDefMock();
     $attrdef->setReturnValue('make', $attrdef_nmtokens);
     $manager->attrTypes->set('NMTOKENS', $attrdef);
     return $manager;
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:12,代码来源:HTMLModuleManagerTest.php


示例12: test_expandIdentifiers

 public function test_expandIdentifiers()
 {
     generate_mock_once('HTMLPurifier_AttrTypes');
     $types = new HTMLPurifier_AttrTypesMock();
     $collections = new HTMLPurifier_AttrCollections($types, array());
     $attr = array('attr1' => 'Color', 'attr2*' => 'URI');
     $c_object = new HTMLPurifier_AttrDef_HTML_Color();
     $u_object = new HTMLPurifier_AttrDef_URI();
     $types->setReturnValue('get', $c_object, array('Color'));
     $types->setReturnValue('get', $u_object, array('URI'));
     $collections->expandIdentifiers($attr, $types);
     $u_object->required = true;
     $this->assertIdentical($attr, array('attr1' => $c_object, 'attr2' => $u_object));
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:14,代码来源:AttrCollectionsTest.php


示例13: test

 function test()
 {
     generate_mock_once('HTMLPurifier_AttrDef');
     $config = HTMLPurifier_Config::createDefault();
     $context = new HTMLPurifier_Context();
     // first test: value properly validates on first definition
     // so second def is never called
     $def1 = new HTMLPurifier_AttrDefMock();
     $def2 = new HTMLPurifier_AttrDefMock();
     $defs = array(&$def1, &$def2);
     $def = new HTMLPurifier_AttrDef_CSS_Composite_Testable($defs);
     $input = 'FOOBAR';
     $output = 'foobar';
     $def1_params = array($input, $config, $context);
     $def1->expectOnce('validate', $def1_params);
     $def1->setReturnValue('validate', $output, $def1_params);
     $def2->expectNever('validate');
     $result = $def->validate($input, $config, $context);
     $this->assertIdentical($output, $result);
     // second test, first def fails, second def works
     $def1 = new HTMLPurifier_AttrDefMock();
     $def2 = new HTMLPurifier_AttrDefMock();
     $defs = array(&$def1, &$def2);
     $def = new HTMLPurifier_AttrDef_CSS_Composite_Testable($defs);
     $input = 'BOOMA';
     $output = 'booma';
     $def_params = array($input, $config, $context);
     $def1->expectOnce('validate', $def_params);
     $def1->setReturnValue('validate', false, $def_params);
     $def2->expectOnce('validate', $def_params);
     $def2->setReturnValue('validate', $output, $def_params);
     $result = $def->validate($input, $config, $context);
     $this->assertIdentical($output, $result);
     // third test, all fail, so composite faiils
     $def1 = new HTMLPurifier_AttrDefMock();
     $def2 = new HTMLPurifier_AttrDefMock();
     $defs = array(&$def1, &$def2);
     $def = new HTMLPurifier_AttrDef_CSS_Composite_Testable($defs);
     $input = 'BOOMA';
     $output = false;
     $def_params = array($input, $config, $context);
     $def1->expectOnce('validate', $def_params);
     $def1->setReturnValue('validate', false, $def_params);
     $def2->expectOnce('validate', $def_params);
     $def2->setReturnValue('validate', false, $def_params);
     $result = $def->validate($input, $config, $context);
     $this->assertIdentical($output, $result);
 }
开发者ID:odsherred,项目名称:subsites.odsherred.dk,代码行数:48,代码来源:CompositeTest.php


示例14: createFilterMock

 protected function createFilterMock($expect = true, $result = true, $post = false, $setup = true)
 {
     static $i = 0;
     generate_mock_once('HTMLPurifier_URIFilter');
     $mock = new HTMLPurifier_URIFilterMock();
     if ($expect) {
         $mock->expectOnce('filter');
     } else {
         $mock->expectNever('filter');
     }
     $mock->setReturnValue('filter', $result);
     $mock->setReturnValue('prepare', $setup);
     $mock->name = $i++;
     $mock->post = $post;
     return $mock;
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:16,代码来源:URIDefinitionTest.php


示例15: testAttributesTransformedGlobalPre

 public function testAttributesTransformedGlobalPre()
 {
     $def = $this->config->getHTMLDefinition(true);
     generate_mock_once('HTMLPurifier_AttrTransform');
     $transform = new HTMLPurifier_AttrTransformMock();
     $input = array('original' => 'value');
     $output = array('class' => 'value');
     // must be valid
     $transform->setReturnValue('transform', $output, array($input, new AnythingExpectation(), new AnythingExpectation()));
     $def->info_attr_transform_pre[] = $transform;
     $token = new HTMLPurifier_Token_Start('span', $input, 1);
     $this->invoke($token);
     $result = $this->collector->getRaw();
     $expect = array(array(1, E_NOTICE, 'Attributes on <span> transformed from original to class', array()));
     $this->assertIdentical($result, $expect);
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:16,代码来源:AttrValidator_ErrorsTest.php


示例16: testStandardUsage

 public function testStandardUsage()
 {
     generate_mock_once('HTMLPurifier_IDAccumulator');
     $this->assertFalse($this->context->exists('IDAccumulator'));
     $accumulator = new HTMLPurifier_IDAccumulatorMock();
     $this->context->register('IDAccumulator', $accumulator);
     $this->assertTrue($this->context->exists('IDAccumulator'));
     $accumulator_2 =& $this->context->get('IDAccumulator');
     $this->assertReference($accumulator, $accumulator_2);
     $this->context->destroy('IDAccumulator');
     $this->assertFalse($this->context->exists('IDAccumulator'));
     $this->expectError('Attempted to retrieve non-existent variable IDAccumulator');
     $accumulator_3 =& $this->context->get('IDAccumulator');
     $this->assertNull($accumulator_3);
     $this->expectError('Attempted to destroy non-existent variable IDAccumulator');
     $this->context->destroy('IDAccumulator');
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:17,代码来源:ContextTest.php


示例17: test_parseContents

 public function test_parseContents()
 {
     $module = new HTMLPurifier_HTMLModule();
     // pre-defined templates
     $this->assertIdentical($module->parseContents('Inline'), array('optional', 'Inline | #PCDATA'));
     $this->assertIdentical($module->parseContents('Flow'), array('optional', 'Flow | #PCDATA'));
     $this->assertIdentical($module->parseContents('Empty'), array('empty', ''));
     // normalization procedures
     $this->assertIdentical($module->parseContents('optional: a'), array('optional', 'a'));
     $this->assertIdentical($module->parseContents('OPTIONAL :a'), array('optional', 'a'));
     $this->assertIdentical($module->parseContents('Optional: a'), array('optional', 'a'));
     // others
     $this->assertIdentical($module->parseContents('Optional: a | b | c'), array('optional', 'a | b | c'));
     // object pass-through
     generate_mock_once('HTMLPurifier_AttrDef');
     $this->assertIdentical($module->parseContents(new HTMLPurifier_AttrDefMock()), array(null, null));
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:17,代码来源:HTMLModuleTest.php


示例18: setup

 public function setup()
 {
     generate_mock_once('HTMLPurifier_Language');
     generate_mock_once('HTMLPurifier_Generator');
     parent::setup();
     $this->language = new HTMLPurifier_LanguageMock();
     $this->language->setReturnValue('getErrorName', 'Error', array(E_ERROR));
     $this->language->setReturnValue('getErrorName', 'Warning', array(E_WARNING));
     $this->language->setReturnValue('getErrorName', 'Notice', array(E_NOTICE));
     // this might prove to be troublesome if we need to set config
     $this->generator = new HTMLPurifier_Generator($this->config, $this->context);
     $this->line = false;
     $this->context->register('Locale', $this->language);
     $this->context->register('CurrentLine', $this->line);
     $this->context->register('Generator', $this->generator);
     $this->collector = new HTMLPurifier_ErrorCollector($this->context);
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:17,代码来源:ErrorCollectorTest.php


示例19: test_isOld

 function test_isOld()
 {
     // using null subclass because parent is abstract
     $cache = new HTMLPurifier_DefinitionCache_Null('Test');
     generate_mock_once('HTMLPurifier_Config');
     $config = new HTMLPurifier_ConfigMock();
     $config->version = '1.0.0';
     // hopefully no conflicts
     $config->setReturnValue('get', 10, array('Test', 'DefinitionRev'));
     $config->setReturnValue('getBatchSerial', 'hash', array('Test'));
     $this->assertIdentical($cache->isOld('1.0.0,hash,10', $config), false);
     $this->assertIdentical($cache->isOld('1.5.0,hash,1', $config), true);
     $this->assertIdentical($cache->isOld('0.9.0,hash,1', $config), true);
     $this->assertIdentical($cache->isOld('1.0.0,hash,1', $config), true);
     $this->assertIdentical($cache->isOld('1.0.0beta,hash,11', $config), true);
     $this->assertIdentical($cache->isOld('0.9.0,hash2,1', $config), true);
     $this->assertIdentical($cache->isOld('1.0.0,hash2,1', $config), false);
     // if hash is different, don't touch!
     $this->assertIdentical($cache->isOld('1.0.0beta,hash2,11', $config), true);
     $this->assertIdentical($cache->isOld('1.0.0-dev,hash2,11', $config), true);
 }
开发者ID:patdunlavey,项目名称:Williamstown-Beat,代码行数:21,代码来源:DefinitionCacheTest.php


示例20: test

 function test()
 {
     generate_mock_once('HTMLPurifier_DefinitionCache');
     $mock = new HTMLPurifier_DefinitionCacheMock();
     $mock->type = 'Test';
     $cache = new HTMLPurifier_DefinitionCache_Decorator();
     $cache = $cache->decorate($mock);
     $this->assertIdentical($cache->type, $mock->type);
     $def = $this->generateDefinition();
     $config = $this->generateConfigMock();
     $mock->expectOnce('add', array($def, $config));
     $cache->add($def, $config);
     $mock->expectOnce('set', array($def, $config));
     $cache->set($def, $config);
     $mock->expectOnce('replace', array($def, $config));
     $cache->replace($def, $config);
     $mock->expectOnce('get', array($config));
     $cache->get($config);
     $mock->expectOnce('flush', array($config));
     $cache->flush($config);
     $mock->expectOnce('cleanup', array($config));
     $cache->cleanup($config);
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:23,代码来源:DecoratorTest.php



注:本文中的generate_mock_once函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP generate_name函数代码示例发布时间:2022-05-15
下一篇:
PHP generate_map函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap