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


PHP Mockery::Mock方法代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     $this->dodajPracownikaCommand = M::mock(DodajPracownikaCommand::class);
     $this->commandBus = M::mock(MessageBus::class);
     $this->pracownikRepository = M::mock(IPracownikRepository::class);
     $this->container = M::mock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $this->token_storage = M::mock(TokenStorageInterface::class);
     $this->token = M::mock();
     $this->unitOfWork = M::mock(UnitOfWork::class);
     $this->request = new Request();
     $this->user = M::mock(User::class);
     $this->user_zalogowany = M::mock(User::class);
     $this->pracownik = M::mock(Pracownik::class);
     $this->controller = new PracownikController($this->dodajPracownikaCommand, $this->commandBus, $this->pracownikRepository);
     $this->controller->setContainer($this->container);
     $this->controller->setUnitOfWork($this->unitOfWork);
     $this->request->headers = M::Mock(HeaderBag::class);
     $this->request->headers->shouldReceive('get')->with('referer')->once()->andReturn('http://localhost');
     $this->unitOfWork->shouldReceive('commit')->once()->andReturn();
     $this->container->shouldReceive('has')->with('security.token_storage')->once()->andReturn(true);
     $this->token->shouldReceive('getUser')->once()->andReturn($this->user_zalogowany);
     $this->token_storage->shouldReceive('getToken')->once()->andReturn($this->token);
     $this->container->shouldReceive('get')->with('security.token_storage')->once()->andReturn($this->token_storage);
     $form_factory = M::Mock(FormFactoryInterface::class);
     $this->form = M::Mock(Form::class);
     $this->form->shouldReceive('handleRequest')->once()->andReturn(true);
     $this->form->shouldReceive('createView')->once()->andReturn('stworzyła się jakaś forma');
     $this->commandBus->shouldReceive('handle')->once()->andReturn();
     $form_factory->shouldReceive('create')->once()->andReturn($this->form);
     $this->container->shouldReceive('get')->with('form.factory')->once()->andReturn($form_factory);
     $this->pracownikRepository->shouldReceive('findAllByUser')->once()->andReturn('Jakaś organizacja');
     $this->pracownik->shouldReceive('getUser')->once()->andReturn($this->user);
     $this->pracownik->shouldReceive('setDel')->once()->andReturn();
 }
开发者ID:mgugniewicz,项目名称:dodajurlop,代码行数:34,代码来源:PracownikControllerTest.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     $this->mImage = M::mock('Agency\\Contracts\\ImageInterface');
     $this->mHelper = M::Mock('Agency\\Contracts\\HelperInterface');
     $this->images = new ImageRepository($this->mImage, $this->mHelper);
     $this->mHelper->shouldReceive('getUniqueId')->andReturn('12345');
 }
开发者ID:vinelab,项目名称:agency,代码行数:8,代码来源:ImageRepositoryTest.php

示例3: testCanGenerateControllerUsingCustomTemplate

 public function testCanGenerateControllerUsingCustomTemplate()
 {
     $file = m::mock('Illuminate\\Filesystem\\Filesystem')->makePartial();
     $cache = m::Mock('Way\\Generators\\Cache');
     $file->shouldReceive('put')->once()->with(app_path() . '/controllers/FoosController.php', file_get_contents(__DIR__ . '/stubs/scaffold/controller.txt'));
     $generator = new ControllerGenerator($file, $cache);
     $generator->make(app_path() . '/controllers/FoosController.php', static::$templatesDir . '/scaffold/controller.txt');
 }
开发者ID:samplex,项目名称:shorturl,代码行数:8,代码来源:ControllerGeneratorTest.php

示例4: testCanGenerateModelUsingCustomTemplateAndFields

 public function testCanGenerateModelUsingCustomTemplateAndFields()
 {
     $file = m::mock('Illuminate\\Filesystem\\Filesystem')->makePartial();
     $cache = m::Mock('Way\\Generators\\Cache');
     $cache->shouldReceive('getFields')->once()->andReturn(['title' => 'string', 'age' => 'integer']);
     $file->shouldReceive('put')->once()->with(app_path() . '/models/Foo.php', file_get_contents(__DIR__ . '/stubs/scaffold/model.txt'));
     $generator = new ModelGenerator($file, $cache);
     $generator->make(app_path() . '/models/Foo.php', static::$templatesDir . '/scaffold/model.txt');
 }
开发者ID:amaly,项目名称:laravel-generators,代码行数:9,代码来源:ModelGeneratorTest.php

示例5: mockAuthorityService

 protected function mockAuthorityService()
 {
     $authService = \Mockery::Mock('TransformCore\\PHE\\LocalHealthAuthorityBundle\\Service\\AuthorityService');
     $authService->shouldReceive('get')->with('transformcore.phe.lha.authority')->andReturnSelf();
     $authService->shouldReceive('populateAddressDetailsFromPostCode')->andReturn($this->createQuestionnaire());
     $authService->shouldReceive('findByPostCode')->withAnyArgs()->once()->andReturn(array((new Authority())->setCountry('United Kingdom')->setDistrictCouncil(new DistrictCouncil('AA', 'AA BB CC'))->setCounty(new County('AA', 'AA BB CC'))));
     $authService->shouldReceive('findByPostCode')->withAnyArgs()->andReturnNull();
     return $authService;
 }
开发者ID:TransformCore,项目名称:HayPersistenceApi,代码行数:9,代码来源:PopulateLocationMetaDataServiceTest.php

示例6: testClassify

 /**
  *@dataProvider classifyProvider
  */
 public function testClassify($string, $probs, $expect)
 {
     $resultOb = m::Mock('\\BayesPHP\\Sample\\Result');
     $resultOb->shouldReceive('getWordProbability')->times(5)->andReturn($probs[0], $probs[1], $probs[2], $probs[3], $probs[4]);
     $stemer = m::Mock('\\BayesPHP\\Stemer');
     $stemer->shouldReceive('process')->once()->andReturn($string);
     $classifier = new Classifier($resultOb, $stemer);
     $classifierResult = $classifier->classify($string);
     $this->assertEquals($classifierResult->getProbabilities(), $expect);
 }
开发者ID:habeelety,项目名称:BayesPHP,代码行数:13,代码来源:ClassifierTest.php

示例7: testGetQRCodeUrlWithTitle

 /**
  * @runInSeparateProcess
  */
 public function testGetQRCodeUrlWithTitle()
 {
     $mock = m::Mock('alias:Fuel\\Core\\Config');
     $mock->shouldReceive('load')->andReturn(array('title' => 'TheMock'));
     $secret = \G2FA\G2FA::createSecret();
     $otpauth = urlencode('otpauth://totp/bar?secret=' . $secret . '&issuer=' . urlencode('TheMock'));
     $expect = "https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=" . $otpauth;
     $actual = \G2FA\G2FA::getQRCodeUrl('bar', $secret);
     $this->assertEquals($expect, $actual);
 }
开发者ID:yoshihisa,项目名称:fuel-g2fa,代码行数:13,代码来源:g2fa.php

示例8: testGetDoesNotThrowExceptionIfHttpFailsAndThrowHttpExceptionsIsFalse

 public function testGetDoesNotThrowExceptionIfHttpFailsAndThrowHttpExceptionsIsFalse()
 {
     $cache = Mockery::mock('\\Imdb\\Cache', ['get' => null, 'set' => true]);
     $request = Mockery::mock(['sendRequest' => false]);
     $config = new Config();
     $config->throwHttpExceptions = false;
     $pages = Mockery::Mock('\\Imdb\\Pages[buildRequest]', [$config, $cache, new Logger()]);
     $pages->shouldAllowMockingProtectedMethods();
     $pages->shouldReceive('buildRequest')->once()->andReturn($request);
     $pages->get('test');
 }
开发者ID:qasa1,项目名称:medidore,代码行数:11,代码来源:PagesTest.php

示例9: testPutDistrictCouncilActionReturns404

 public function testPutDistrictCouncilActionReturns404()
 {
     $container = $this->mockContainer();
     $container->shouldReceive('saveWebsite')->withAnyArgs()->andReturn(new DistrictCouncil('', ''));
     $this->instance->setContainer($container);
     $pf = \Mockery::Mock('FOS\\RestBundle\\Request\\ParamFetcher')->shouldIgnoreMissing();
     $result = $this->instance->putDistrictCouncilAction(PHP_INT_MAX, $pf);
     $this->assertInstanceOf(View::class, $result);
     $this->assertNotNull($result->getData());
     $this->assertInstanceOf(DistrictCouncil::class, $result->getData());
     $this->assertNull($result->getData()->getId());
     $this->assertEquals(404, $result->getStatusCode());
 }
开发者ID:TransformCore,项目名称:HayPersistenceApi,代码行数:13,代码来源:DistrictCouncilControllerTest.php

示例10: testAsHtml

 public function testAsHtml()
 {
     // Mock Resource
     $now = new DateTime();
     $content = 'this is the content';
     $mockResource = m::Mock('Fideloper\\ResourceCache\\Resource\\Eloquent\\Resource');
     $mockResource->shouldReceive('getEtag')->once()->andReturn(md5('example1'));
     $mockResource->shouldReceive('getLastUpdated')->once()->andReturn($now);
     $synResp = new SymfonyResponse();
     $htmlResponse = $synResp->asHtml($mockResource, $content, 200);
     // General health
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $htmlResponse, 'Response is of type Response');
     $this->assertEquals(200, $htmlResponse->getStatusCode(), 'Status code set to what we expected');
     $this->assertEquals($content, $htmlResponse->getContent(), 'Response content is as set');
     // ETag
     $this->assertEquals('"' . md5('example1') . '"', $htmlResponse->getEtag(), 'ETag set as expected');
     // Last-Modified
     $this->assertEquals($now->getTimestamp(), $htmlResponse->getLastModified()->getTimestamp(), 'Last Modified date set as expected');
 }
开发者ID:fideloper,项目名称:resourcecache,代码行数:19,代码来源:SymfonyResponseTest.php

示例11: it_should_be_able_to_register_an_instance_of_fixture_with_the_container

 /**
  * Test that the service provider can register an instance of fixture
  * with the application container.
  * 
  * @test
  * @return void
  */
 public function it_should_be_able_to_register_an_instance_of_fixture_with_the_container()
 {
     App::bind('db', function ($app) {
         $mockedDB = m::mock('Illuminate\\Database\\DatabaseManager');
         $mockedConnection = m::mock('Illuminate\\Database\\Connection');
         $pdo = new PDO('sqlite::memory:');
         $mockedDB->shouldReceive('connection')->once()->andReturn($mockedConnection);
         $mockedConnection->shouldReceive('getPdo')->once()->andReturn($pdo);
         return $mockedDB;
     });
     App::bind('Str', function ($app) {
         return m::mock('Illuminate\\Support\\Str');
     });
     App::bind('config', function ($app) {
         $mockedConfig = m::Mock('Illuminate\\Config\\Repository');
         $mockedConfig->shouldReceive('get')->once()->with('fixture-l4::config');
         return $mockedConfig;
     });
     $instance = Fixture::getFacadeRoot();
     $this->assertInstanceOf('Codesleeve\\Fixture\\Fixture', $instance);
 }
开发者ID:saga64,项目名称:fixture-l4,代码行数:28,代码来源:FixtureL4ServiceProvider.php

示例12: setUpEventDispatcher

 private function setUpEventDispatcher()
 {
     $dispatcher = \Mockery::Mock('Aol\\Atc\\EventDispatcher');
     return $dispatcher;
 }
开发者ID:dlundgren,项目名称:atc,代码行数:5,代码来源:DispatchTest.php

示例13: testRawAwfulGet

 /**
  * 复杂查询未命中缓存
  */
 public function testRawAwfulGet()
 {
     // 模拟数据库返回结果
     $this->conn->shouldReceive('select')->with('select count(*) from "user" where "id" = ?', [1], true)->andReturn([(object) ["count(*)" => 1]]);
     // 模拟未命中缓存
     $this->cache->shouldReceive('get')->with(['122a32ae3f8656ba95b87700de71506c'])->andReturn([]);
     // 模拟缓存查询结果
     $this->cache->shouldReceive('set')->with(['122a32ae3f8656ba95b87700de71506c' => [(object) ["count(*)" => 1]]]);
     $dispatcher = M::Mock(Dispatcher::class);
     $dispatcher->shouldReceive('fire')->with('angejia.pea.get', ['table' => 'user', 'db' => 'angejia']);
     $dispatcher->shouldReceive('fire')->with('angejia.pea.miss.awful', ['table' => 'user', 'db' => 'angejia']);
     $this->app->instance(Dispatcher::class, $dispatcher);
     $data = User::where('id', 1)->select(new Expression('count(*)'))->get();
     $this->assertEquals(1, $data[0]['count(*)']);
 }
开发者ID:angejia,项目名称:pea,代码行数:18,代码来源:ModelTest.php

示例14: testDeciderScanWithTwoEventAndNoAgentShouldMakeADecision

 public function testDeciderScanWithTwoEventAndNoAgentShouldMakeADecision()
 {
     $this->setUpTables();
     $this->setUpRepo();
     $dbManager = M::mock(DbManager::classname());
     $agentDao = M::mock(AgentDao::classname());
     $clearingDao = M::mock(ClearingDao::classname());
     $uploadDao = M::mock(UploadDao::classname());
     $highlightDao = M::mock(HighlightDao::classname());
     $decisionProcessor = M::mock(ClearingDecisionProcessor::classname());
     $agentLicenseEventProcessor = M::mock(AgentLicenseEventProcessor::classname());
     $uploadId = 13243;
     /*mock for Agent class **/
     $agentDao->shouldReceive('arsTableExists')->andReturn(true);
     $agentDao->shouldReceive('getCurrentAgentId')->andReturn($agentId = 24);
     $agentDao->shouldReceive('writeArsRecord')->with(anything(), $agentId, $uploadId)->andReturn($arsId = 2);
     $agentDao->shouldReceive('writeArsRecord')->with(anything(), $agentId, $uploadId, $arsId, true)->andReturn(0);
     $jobId = 42;
     $groupId = 6;
     $userId = 2;
     $itemIds = array(4343, 43);
     $bounds0 = M::mock(ItemTreeBounds::classname());
     $bounds0->shouldReceive('getItemId')->andReturn($itemIds[0]);
     $bounds0->shouldReceive('containsFiles')->andReturn(false);
     $bounds1 = M::mock(ItemTreeBounds::classname());
     $bounds1->shouldReceive('getItemId')->andReturn($itemIds[1]);
     $bounds1->shouldReceive('containsFiles')->andReturn(false);
     $bounds = array($bounds0, $bounds1);
     $uploadDao->shouldReceive('getItemTreeBounds')->with($itemIds[0])->andReturn($bounds[0]);
     $uploadDao->shouldReceive('getItemTreeBounds')->with($itemIds[1])->andReturn($bounds[1]);
     $clearingDao->shouldReceive('getEventIdsOfJob')->with($jobId)->andReturn(array($itemIds[0] => array(), $itemIds[1] => array()));
     $dbManager->shouldReceive('begin')->times(count($itemIds));
     $dbManager->shouldReceive('commit')->times(count($itemIds));
     /* dummy expectations needed for unmockable LicenseMap constructor */
     $dbManager->shouldReceive('prepare');
     $res = M::Mock(DbManager::classname());
     $dbManager->shouldReceive('execute')->andReturn($res);
     $row1 = array('rf_fk' => 2334, 'parent_fk' => 1);
     $row2 = array('rf_fk' => 2333, 'parent_fk' => 1);
     $dbManager->shouldReceive('fetchArray')->with($res)->andReturn($row1, $row2, false);
     $dbManager->shouldReceive('freeResult')->with($res);
     /* /expectations for LicenseMap */
     $decisionProcessor->shouldReceive('hasUnhandledScannerDetectedLicenses')->with($bounds0, $groupId, array(), anything())->andReturn(true);
     $clearingDao->shouldReceive('markDecisionAsWip')->with($itemIds[0], $userId, $groupId);
     $decisionProcessor->shouldReceive('hasUnhandledScannerDetectedLicenses')->with($bounds1, $groupId, array(), anything())->andReturn(false);
     $decisionProcessor->shouldReceive('makeDecisionFromLastEvents')->with($bounds1, $userId, $groupId, DecisionTypes::IDENTIFIED, false, array());
     $runner = new SchedulerTestRunnerMock($dbManager, $agentDao, $clearingDao, $uploadDao, $highlightDao, $decisionProcessor, $agentLicenseEventProcessor);
     list($success, $output, $retCode) = $runner->run($uploadId, $userId, $groupId, $jobId, $args = "");
     $this->assertTrue($success, 'cannot run decider');
     $this->assertEquals($retCode, 0, 'decider failed: ' . $output);
     assertThat($this->getHeartCount($output), equalTo(count($itemIds)));
     $this->rmRepo();
 }
开发者ID:DanielDobre,项目名称:fossology,代码行数:53,代码来源:schedulerTest.php

示例15: testWasNotModifiedIsNotUnmodified

 public function testWasNotModifiedIsNotUnmodified()
 {
     // Mock Request
     $mockRequest = m::mock('Symfony\\Component\\HttpFoundation\\Request');
     $mockRequest->shouldReceive('retrieveItem')->with('headers', 'if-match')->andReturn(false);
     $mockRequest->shouldReceive('retrieveItem')->with('headers', 'if-unmodified-since')->andReturn('1 March 2013');
     // Mock Resource
     $mockResource = m::Mock('Fideloper\\ResourceCache\\Resource\\Eloquent\\Resource');
     $mockResource->shouldReceive('getLastUpdated')->once()->andReturn(new DateTime('@' . strtotime('3 March 2013')));
     $symReq = new SymfonyRequest($mockRequest);
     $this->assertFalse($symReq->wasNotModified($mockResource), 'Was modified after March 1, on March 3, and so "was unmodified" returns false');
 }
开发者ID:fideloper,项目名称:resourcecache,代码行数:12,代码来源:SymfonyRequestTest.php


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