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

PHP Phake类代码示例

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

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



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

示例1: simpleStubWithPhake

 /** @test */
 public function simpleStubWithPhake()
 {
     $service = \Phake::mock('\\Acme\\ServiceInterface');
     \Phake::when($service)->readTemp()->thenReturn(10)->thenReturn(12)->thenReturn(14);
     $temperature = new Temperature($service);
     $this->assertEquals(12, $temperature->average());
 }
开发者ID:isidromerayo,项目名称:simple_php_skeleton,代码行数:8,代码来源:TemperatureStubTest.php


示例2: parseNormal

 /**
  * @test
  */
 public function parseNormal()
 {
     \Phake::when($this->commentsParser)->parse(\Phake::anyParameters())->thenReturn(null);
     $stmts = (include __DIR__ . '/../fixtures/1/Model/Product.php.property_base.cache');
     $this->parser->parse($stmts, $this->property, $this->class);
     \Phake::verify($this->commentsParser)->parse(\Phake::anyParameters());
 }
开发者ID:domaincoder,项目名称:code-metamodel-php,代码行数:10,代码来源:PropertyAnnotationsParserTest.php


示例3: setUp

 protected function setUp()
 {
     parent::setUp();
     Phake::when($this->facade)->is_user_logged_in()->thenReturn(true);
     Phake::when($this->facade)->wp_get_current_user()->thenReturn($this->user);
     Phake::when($this->wpdb)->get_var(Phake::anyParameters())->thenReturn('true');
 }
开发者ID:ThemeSurgeon,项目名称:launchkey-wordpress,代码行数:7,代码来源:class-launchkey-wp-native-client-still-authenticated-heartbeat-test.php


示例4: initialize

 public function initialize($object)
 {
     $reflectionClass = new ReflectionClass($object);
     $reader = new Phake_Annotation_Reader($reflectionClass);
     if ($this->useDoctrineParser()) {
         $parser = new \Doctrine\Common\Annotations\PhpParser();
     }
     $properties = $reader->getPropertiesWithAnnotation('Mock');
     foreach ($properties as $property) {
         $annotations = $reader->getPropertyAnnotations($property);
         if ($annotations['Mock'] !== true) {
             $mockedClass = $annotations['Mock'];
         } else {
             $mockedClass = $annotations['var'];
         }
         if (isset($parser)) {
             // Ignore it if the class start with a backslash
             if (substr($mockedClass, 0, 1) !== '\\') {
                 $useStatements = $parser->parseClass($reflectionClass);
                 $key = strtolower($mockedClass);
                 if (array_key_exists($key, $useStatements)) {
                     $mockedClass = $useStatements[$key];
                 }
             }
         }
         $reflProp = new ReflectionProperty(get_class($object), $property);
         $reflProp->setAccessible(true);
         $reflProp->setValue($object, Phake::mock($mockedClass));
     }
 }
开发者ID:eric-seekas,项目名称:Phake,代码行数:30,代码来源:MockInitializer.php


示例5: testToString

 public function testToString()
 {
     Phake::when($this->adapted)->__toString->thenReturn('test string');
     $result = $this->matcher->__toString();
     Phake::verify($this->adapted)->__toString();
     $this->assertEquals('test string', $result);
 }
开发者ID:eric-seekas,项目名称:Phake,代码行数:7,代码来源:ChainedArgumentMatcherTest.php


示例6: testStorageDestruct

 public function testStorageDestruct()
 {
     $this->Web->queries($this->queries);
     $this->Web->crawl();
     // assertion maximus
     \Phake::verify($this->Storage, \Phake::times(1))->destruct();
 }
开发者ID:jessecascio,项目名称:spider,代码行数:7,代码来源:WebTest.php


示例7: parseClassComment

 /**
  * @test
  */
 public function parseClassComment()
 {
     \Phake::when($this->annotationsParser)->parse(\Phake::anyParameters())->thenReturn([]);
     $stmts = (include __DIR__ . '/../fixtures/1/Model/Product.php.class.cache');
     $class = $this->parser->parse($stmts, '', '');
     $this->assertThat($class->comment, $this->equalTo('商品エンティティ'));
 }
开发者ID:domaincoder,项目名称:code-metamodel-php,代码行数:10,代码来源:ClassParserTest.php


示例8: setUp

 /**
  * Sets up test fixture
  */
 public function setUp()
 {
     $this->matcher1 = Phake::mock('Phake_Matchers_IChainableArgumentMatcher');
     $this->obj = $this->getMock('Phake_IMock');
     PhakeTestUtil::setStubMapper($this->obj, Phake::mock('Phake_Stubber_StubMapper'));
     $this->proxy = new Phake_Proxies_CallStubberProxy($this->matcher1, false);
 }
开发者ID:eric-seekas,项目名称:Phake,代码行数:10,代码来源:CallStubberProxyTest.php


示例9: testGetUrl

 public function testGetUrl()
 {
     $container = \Phake::mock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     \Phake::when($container)->getParameter(ModeraFileRepositoryExtension::CONFIG_KEY . '.default_url_generator')->thenReturn('default_url_generator');
     \Phake::when($container)->getParameter(ModeraFileRepositoryExtension::CONFIG_KEY . '.url_generators')->thenReturn(array('foo' => 'foo_url_generator', 'bar' => 'bar_url_generator'));
     $defaultUrlGenerator = \Phake::mock('Modera\\FileRepositoryBundle\\StoredFile\\UrlGeneratorInterface');
     \Phake::when($container)->get('default_url_generator')->thenReturn($defaultUrlGenerator);
     $fooUrlGenerator = \Phake::mock('Modera\\FileRepositoryBundle\\StoredFile\\UrlGeneratorInterface');
     \Phake::when($container)->get('foo_url_generator')->thenReturn($fooUrlGenerator);
     \Phake::when($container)->get('bar_url_generator')->thenReturn('not_url_generator');
     $context = array();
     $splFile = new \SplFileInfo(__FILE__);
     $repository = \Phake::mock('Modera\\FileRepositoryBundle\\Entity\\Repository');
     \Phake::when($repository)->generateStorageKey($splFile, $context)->thenReturn('storage-key');
     $storedFile = new StoredFile($repository, $splFile, $context);
     $storedFile->init($container);
     \Phake::when($defaultUrlGenerator)->generateUrl($storedFile)->thenReturn('default_url');
     \Phake::when($fooUrlGenerator)->generateUrl($storedFile)->thenReturn('foo_url');
     \Phake::when($repository)->getConfig()->thenReturn(array('filesystem' => 'foo'));
     $this->assertEquals('foo_url', $storedFile->getUrl());
     \Phake::when($repository)->getConfig()->thenReturn(array('filesystem' => 'bar'));
     $this->assertEquals('default_url', $storedFile->getUrl());
     \Phake::when($repository)->getConfig()->thenReturn(array('filesystem' => 'baz'));
     $this->assertEquals('default_url', $storedFile->getUrl());
 }
开发者ID:modera,项目名称:foundation,代码行数:25,代码来源:StoredFileTest.php


示例10: should_convert_segment_to_string

 /** @test */
 public function should_convert_segment_to_string()
 {
     $segment = new Segment('XXX');
     $segment->var = 'value';
     $segmentMapping = new SegmentMapping('XXX');
     $segmentMapping->addDataElement(1, new DataElementMapping(2345, true, DataElementType::A, 'var'));
     $message = new Message();
     $message->setReferenceNumber(34834);
     $message->setIdentifier(["type" => 'TEST', "version" => 'S', "release" => '404', "controllingAgency" => 'PG']);
     $message->addSegment($segment);
     //        $messageMapping = new MessageMapping();
     //        $messageMapping->setDefaults(["0065" => 'TEST', "0052" => 'S', "0054" => '404', "0051" => 'PG']);
     //        $messageMapping->addSegment(new MessageSegmentMapping('UNH', 1, true));
     //        $messageMapping->addSegment(new MessageSegmentMapping('XXX', 99, true));
     //        $messageMapping->addSegment(new MessageSegmentMapping('UNT', 1, true));
     $interchange = new Interchange();
     $interchange->setSyntax(["name" => 'UNOC', "version" => 3]);
     $interchange->setSender(['id' => 'zenon']);
     $interchange->setRecipient(['id' => 'stefan']);
     $interchange->setTime(['date' => '20150101', 'time' => '1034']);
     $interchange->setControlReference('17');
     $interchange->setMessages([$message]);
     $mappingLoader = \Phake::mock(MappingLoader::class);
     \Phake::when($mappingLoader)->loadSegments(\Phake::anyParameters())->thenReturn(['XXX' => $segmentMapping]);
     $encoder = new Encoder(new AnnotationPrinter(new AnnotationReader()), new SegmentPrinter(), $mappingLoader);
     $result = $encoder->encode($interchange);
     $this->assertEquals("UNB+UNOC:3+zenon+stefan+20150101:1034+17'UNH+34834+TEST:S:404:PG'XXX+value'UNT+1+34834'UNZ+1+17'", $result);
 }
开发者ID:progrupa,项目名称:edifact,代码行数:29,代码来源:EncoderTest.php


示例11: testFindInTrans

 public function testFindInTrans()
 {
     $this->target->begin();
     $this->target->find('hoge', 'ssd', array('a', 'b', 3), 'fuga');
     \Phake::verify($this->write)->find('hoge', 'ssd', array('a', 'b', 3), 'fuga');
     \Phake::verify($this->read, \Phake::never())->find('hoge', 'ssd', array('a', 'b', 3), 'fuga');
 }
开发者ID:aainc,项目名称:Mahotora,代码行数:7,代码来源:MultiDatabaseSessionTest.php


示例12: setUp

 public function setUp()
 {
     $this->mock = $this->getMock('Phake_IMock');
     $this->mockReader = Phake::mock('Phake_MockReader');
     Phake::when($this->mockReader)->getName($this->mock)->thenReturn('Phake_IMock');
     $this->call = new Phake_CallRecorder_Call($this->mock, 'someMethod', array('foo', 'bar'), $this->mockReader);
 }
开发者ID:ngyuki,项目名称:phake,代码行数:7,代码来源:CallTest.php


示例13: testCorrelationDataIsAttached

 public function testCorrelationDataIsAttached()
 {
     CorrelationDataHolder::setCorrelationData(array('correlationId' => 'test'));
     $this->testSubject->send(new HelloCommand('Hi !!!'));
     \Phake::verify($this->mockCommandBus)->dispatch(\Phake::capture($command), null);
     $this->assertEquals(array('correlationId' => 'test'), $command->getMetaData()->all());
 }
开发者ID:fcm,项目名称:GovernorFramework,代码行数:7,代码来源:DefaultCommandGatewayTest.php


示例14: invoke

 public function invoke($mock, $method, array $arguments, array &$argumentReference)
 {
     if ($this->mockInfo->isObjectFrozen()) {
         $result = new Phake_CallRecorder_VerifierResult(false, array(), 'This object has been frozen.');
         Phake::getClient()->processVerifierResult($result);
     }
 }
开发者ID:eric-seekas,项目名称:Phake,代码行数:7,代码来源:FrozenObjectCheck.php


示例15: getMockedInfo

 /**
  * @param Phake_IMock $mock
  * @return Phake_Mock_Info
  */
 public static function getMockedInfo(Phake_IMock $mock)
 {
     if (empty($mock->__PHAKE_info)) {
         $mock->__PHAKE_info = Phake::mock('Phake_Mock_Info');
     }
     return $mock->__PHAKE_info;
 }
开发者ID:eric-seekas,项目名称:Phake,代码行数:11,代码来源:PhakeTestUtil.php


示例16: testEventWithoutStringShouldThrowInvalidArgumentExceptionError

 public function testEventWithoutStringShouldThrowInvalidArgumentExceptionError()
 {
     $this->setExpectedExceptionRegExp('InvalidArgumentException', '/^Invalid argument: the submitted variable must be a string when you enable the json_format option.$/');
     $json = ['invalid json'];
     \Phake::when($this->formEvent)->getData()->thenReturn($json);
     $this->jsonExtensionListener->onPreSubmit($this->formEvent);
 }
开发者ID:LinkValue,项目名称:JsonFormExtension-dev,代码行数:7,代码来源:JsonExtensionListenerTest.php


示例17: testReset

 public function testReset()
 {
     $this->registry->resetAll();
     Phake::verify($this->info1)->resetInfo();
     Phake::verify($this->info2)->resetInfo();
     Phake::verify($this->info3)->resetInfo();
 }
开发者ID:svpernova09,项目名称:Phake,代码行数:7,代码来源:InfoRegistryTest.php


示例18: createIUT

 private function createIUT(array $cssAssets = array(), array $jsAssets = array())
 {
     $container = \Phake::mock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     \Phake::when($container)->get('modera_mjr_integration.css_resources_provider')->thenReturn($this->createMockProvider($cssAssets));
     \Phake::when($container)->get('modera_mjr_integration.js_resources_provider')->thenReturn($this->createMockProvider($jsAssets));
     return new AssetsProvider($container);
 }
开发者ID:modera,项目名称:foundation,代码行数:7,代码来源:AssetsProviderTest.php


示例19: testConfigureCustomAggregateFactory

 public function testConfigureCustomAggregateFactory()
 {
     $this->fixture->registerAggregateFactory($this->mockAggregateFactory);
     $this->fixture->registerAnnotatedCommandHandler(new MyCommandHandler($this->fixture->getRepository(), $this->fixture->getEventBus()));
     $this->fixture->given([new MyEvent("id1", 1)])->when(new TestCommand("id1"));
     \Phake::verify($this->mockAggregateFactory, \Phake::atLeast(1))->createAggregate(\Phake::equalTo("id1"), \Phake::anyParameters());
 }
开发者ID:peanohan,项目名称:GovernorFramework,代码行数:7,代码来源:GenericFixtureTest.php


示例20: setUp

 protected function setUp()
 {
     $this->paginUrl = \Phake::mock('Behoimi\\Pager\\PagingUrl');
     \Phake::when($this->paginUrl)->getPrev()->thenReturn('hoge');
     \Phake::when($this->paginUrl)->getNext()->thenReturn('fuga');
     $this->target = new ListResult(true, array((object) array('id' => 1, 'name' => 'name')), $this->paginUrl, null);
 }
开发者ID:aainc,项目名称:Behoimi,代码行数:7,代码来源:ListResultTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Phar类代码示例发布时间:2022-05-23
下一篇:
PHP PhabricatorWorker类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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