当前位置: 首页>>代码示例>>PHP>>正文


PHP Phake::mock方法代码示例

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


在下文中一共展示了Phake::mock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setUp

 public function setUp()
 {
     $this->httpFoundationRequestHandler = \Phake::mock('Symfony\\Component\\Form\\Extension\\HttpFoundation\\HttpFoundationRequestHandler');
     $this->jsonRequestHandler = new JsonRequestHandler($this->httpFoundationRequestHandler);
     $this->form = \Phake::mock('Symfony\\Component\\Form\\FormInterface');
     $this->request = \Phake::mock('Symfony\\Component\\HttpFoundation\\Request');
 }
开发者ID:LinkValue,项目名称:JsonFormExtension-dev,代码行数:7,代码来源:JsonRequestHandlerTest.php

示例3: setUp

 /**
  * Sets up the test fixture
  */
 public function setUp()
 {
     Phake::initAnnotations($this);
     $this->matcher = $this->getMock('Phake_Matchers_MethodMatcher', array(), array(), '', false);
     $this->stubMapper = Phake::mock('Phake_Stubber_StubMapper');
     $this->binder = new Phake_Stubber_AnswerBinder($this->matcher, $this->stubMapper);
 }
开发者ID:eric-seekas,项目名称:Phake,代码行数:10,代码来源:AnswerBinderTest.php

示例4: 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

示例5: 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

示例6: it_grants_access_from_token_roles

 /**
  * @test
  */
 public function it_grants_access_from_token_roles()
 {
     $user = \Phake::mock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
     \Phake::when($user)->getRoles()->thenReturn(array('ROLE_USER', 'ROLE_ADMIN'));
     $context = new MockTokenContext($user);
     $this->assertTrue($context->isGranted('ROLE_USER'));
 }
开发者ID:wakermahmud,项目名称:QafooLabsNoFrameworkBundle,代码行数:10,代码来源:MockTokenContextTest.php

示例7: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->container = \Phake::mock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $this->webUploader = \Phake::mock(WebUploader::clazz());
     $this->ctr = new UniversalUploaderController();
     $this->ctr->setContainer($this->container);
 }
开发者ID:modera,项目名称:foundation,代码行数:10,代码来源:UniversalUploaderControllerTest.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: setUp

 public function setUp()
 {
     $this->target = new Session(new Request(array(), array()), array());
     $_SESSION = array('HOGE' => 1, 'FUGA' => 2, 'PIYO' => array('FIZZ' => 'BUZZ'));
     $this->bindable = \Phake::mock('\\Hoimi\\Bindable');
     \Phake::when($this->bindable)->getSessionKey()->thenReturn('bindable.dummy');
 }
开发者ID:aainc,项目名称:Hoimi,代码行数:7,代码来源:SessionTest.php

示例10: testGetAction

 /**
  * @expectedException Symfony\Component\Security\Core\Exception\AccessDeniedException
  */
 public function testGetAction()
 {
     $ctrl = $this->createStoredFileController();
     $request = \Phake::mock('Symfony\\Component\\HttpFoundation\\Request');
     $resp = $ctrl->getAction($request, '');
     $this->assertEquals(Response::HTTP_NOT_FOUND, $resp->getStatusCode());
     $this->assertEquals('File not found.', $resp->getContent());
     $content = 'Hello World!';
     $storageKey = 'storage-key/repository-name/file-name.txt';
     $ctrl->storedFile = $this->createStoredFile($storageKey, $content);
     $resp = $ctrl->getAction($request, 'storage-key');
     $this->assertEquals(Response::HTTP_OK, $resp->getStatusCode());
     $this->assertEquals($content, $resp->getContent());
     $this->assertNull($resp->headers->get('content-disposition'));
     $resp = $ctrl->getAction($request, $storageKey);
     $this->assertEquals(Response::HTTP_OK, $resp->getStatusCode());
     $this->assertEquals($content, $resp->getContent());
     $this->assertNull($resp->headers->get('content-disposition'));
     $content = 'Download test';
     $ctrl->storedFile = $this->createStoredFile($storageKey, $content);
     \Phake::when($request)->get('dl')->thenReturn('');
     $resp = $ctrl->getAction($request, 'storage-key/repository-name/download-me.txt');
     $this->assertEquals(Response::HTTP_OK, $resp->getStatusCode());
     $this->assertEquals($content, $resp->getContent());
     $this->assertEquals('attachment; filename="download-me.txt"', $resp->headers->get('content-disposition'));
     $resp = $ctrl->getAction($request, 'storage-key/foo.txt');
     $this->assertEquals(Response::HTTP_OK, $resp->getStatusCode());
     $this->assertEquals($content, $resp->getContent());
     $this->assertEquals('attachment; filename="foo.txt"', $resp->headers->get('content-disposition'));
     $ctrl->setEnabled(false);
     $resp = $ctrl->getAction($request, 'Exception');
 }
开发者ID:modera,项目名称:foundation,代码行数:35,代码来源:StoredFileControllerTest.php

示例11: 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

示例12: setUp

 public function setUp()
 {
     $this->mockReader = Phake::mock('Phake_MockReader');
     $this->stubMapper = Phake::mock('Phake_Stubber_StubMapper');
     $this->callRecorder = Phake::mock('Phake_CallRecorder_Recorder');
     $this->resetter = new Phake_Mock_Resetter($this->mockReader);
 }
开发者ID:ngyuki,项目名称:phake,代码行数:7,代码来源:ResetterTest.php

示例13: 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

示例14: testBuild

 public function testBuild()
 {
     $containerBuilder = \Phake::mock('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
     $bundle = new ModeraRoutingBundle();
     $bundle->build($containerBuilder);
     \Phake::verify($containerBuilder, \Phake::atLeast(2))->addCompilerPass($this->isInstanceOf('Symfony\\Component\\DependencyInjection\\Compiler\\CompilerPassInterface'));
 }
开发者ID:modera,项目名称:foundation,代码行数:7,代码来源:ModeraRoutingBundleTest.php

示例15: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->container = \Phake::mock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     \Phake::when($this->container)->get('modera_server_crud.persistence.default_handler')->thenReturn(new DummyDoctrinePersistenceHandler());
     \Phake::when($this->container)->get('doctrine.orm.entity_manager')->thenReturn(new DummyDoctrineEntityManager());
 }
开发者ID:modera,项目名称:foundation,代码行数:7,代码来源:FilterTest.php


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