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

PHP Mockery\Mock类代码示例

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

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



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

示例1: test_gets_model_by_classname

 public function test_gets_model_by_classname()
 {
     $this->modelManagerMock->shouldReceive('getAbstractionLayer')->once()->andReturn($this->mock('ANavallaSuiza\\Laravel\\Database\\Contracts\\Dbal\\AbstractionLayer'));
     $this->modelManagerMock->shouldReceive('getModelInstance')->once()->with('Anavel\\Crud\\Tests\\Models\\User');
     $model = $this->sut->getByClassName('Anavel\\Crud\\Tests\\Models\\User', []);
     $this->assertInstanceOf('Anavel\\Crud\\Contracts\\Abstractor\\Model', $model);
 }
开发者ID:ablunier,项目名称:crud,代码行数:7,代码来源:ModelFactoryTest.php


示例2: test_it_throws_exception_when_route_binder_does_not_exist

 public function test_it_throws_exception_when_route_binder_does_not_exist()
 {
     $this->setExpectedException(InvalidArgumentException::class, 'RouteBinder [NotExistingRouteBinder] does not exist');
     $this->app->shouldReceive('getContext')->once()->andReturn($context = 'web');
     $this->config->shouldReceive('get')->once()->with($context . '.routes', [])->andReturn([\NotExistingRouteBinder::class]);
     $this->binder->loadRoutes(\Mockery::mock(Router::class));
 }
开发者ID:Mosaic,项目名称:Mosaic,代码行数:7,代码来源:LoadRoutesFromBindersTest.php


示例3: it_registers_the_client

 /**
  * @test
  */
 public function it_registers_the_client()
 {
     //        $this->markTestIncomplete();
     $this->app_mock->shouldReceive('make')->with('config')->andReturn(['services' => ['connectwise' => []]])->once();
     $this->app_mock->shouldReceive('singleton')->withArgs(['connectwise', Mockery::any()])->once();
     $this->service_provider->register();
 }
开发者ID:JustinAzoff,项目名称:connectwise-php-generator,代码行数:10,代码来源:ServiceProviderTest.php


示例4: setUpMocks

 protected function setUpMocks()
 {
     $this->localeMock = Mockery::mock(LocaleInterface::class);
     $this->viewFinderMock = Mockery::mock(ViewFinderInterface::class);
     $this->viewMock = Mockery::mock(View::class);
     $this->viewMock->shouldReceive('getPath')->andReturn('');
 }
开发者ID:neondigital,项目名称:laravel-locale,代码行数:7,代码来源:ComposingTest.php


示例5: testFilter

 /**
  * @covers phpDocumentor\Descriptor\Filter\Filter::filter
  */
 public function testFilter()
 {
     $filterableMock = m::mock('phpDocumentor\\Descriptor\\Filter\\Filterable');
     $this->filterChainMock->shouldReceive('filter')->with($filterableMock)->andReturn($filterableMock);
     $this->classFactoryMock->shouldReceive('getChainFor')->with(get_class($filterableMock))->andReturn($this->filterChainMock);
     $this->assertSame($filterableMock, $this->fixture->filter($filterableMock));
 }
开发者ID:bbonnesoeur,项目名称:phpDocumentor2,代码行数:10,代码来源:FilterTest.php


示例6: testRenderWithToString

 /**
  * @covers ::__toString
  */
 public function testRenderWithToString()
 {
     $this->viewMock->shouldReceive('merge')->with($this->presenter)->once();
     $this->viewMock->shouldReceive('autoFilter')->with(true)->once();
     $this->viewMock->shouldReceive('render')->with([])->once()->andReturn('');
     $result = (string) $this->presenter;
 }
开发者ID:fuelphp,项目名称:display,代码行数:10,代码来源:PresenterTest.php


示例7: postValidate_returns_a_failed_response_on_validation_errors

 /**
  * @test postValidate() returns a failed response on validation errors
  */
 public function postValidate_returns_a_failed_response_on_validation_errors()
 {
     $this->input->shouldReceive('all')->withNoArgs()->once()->andReturn(array('foo'));
     $this->validator->shouldReceive('make')->with(array('foo'), array('recaptcha_response_field' => 'required|recaptcha'))->once()->andReturn($this->getFailsMockFixture(true));
     $this->response->shouldReceive('json')->with(array('result' => 'failed'))->once()->andReturn('bar');
     $controller = $this->getCaptchaControllerInstance();
     $this->assertEquals('bar', $controller->postValidate());
 }
开发者ID:LaraGit,项目名称:larapress,代码行数:11,代码来源:CaptchaControllerTest.php


示例8: testFindOneById

 public function testFindOneById()
 {
     $image1 = $this->dummyData->getTag();
     $this->imageRepository->shouldReceive('findOneById')->with($image1->getId())->andReturn($image1)->once();
     $image = $this->imageService->findOneById($image1->getId());
     $this->assertEntitiesEqual($image1, $image);
 }
开发者ID:inklabs,项目名称:kommerce-core,代码行数:7,代码来源:ImageServiceTest.php


示例9: setUp

 protected function setUp()
 {
     $this->rodzaj = new LoadUrlopRodzajData();
     $this->manager = M::mock(ObjectManager::class);
     $this->manager->shouldReceive('persist');
     $this->manager->shouldReceive('flush');
 }
开发者ID:mgugniewicz,项目名称:dodajurlop,代码行数:7,代码来源:LoadUrlopRodzajDataTest.php


示例10: testEndpoint

 public function testEndpoint()
 {
     $this->viewFactory->shouldReceive('make')->withArgs(['fooTable', ['columns' => ['id' => 'id'], 'showHeaders' => false, 'id' => 'fooBar', 'endpoint' => '/test/endpoint/gets/set']])->times(1)->andReturn($this->view);
     $this->viewFactory->shouldReceive('make')->withArgs(['fooScript', ['id' => 'fooBar', 'columns' => ['id' => 'id'], 'options' => [], 'callbacks' => [], 'endpoint' => '/test/endpoint/gets/set']])->times(1)->andReturn($this->view);
     $this->dtv2->endpoint('/test/endpoint/gets/set');
     $this->dtv2->html();
 }
开发者ID:openskill,项目名称:datatable,代码行数:7,代码来源:DatatableViewTest.php


示例11: testGetAttributeValuesByIds

 public function testGetAttributeValuesByIds()
 {
     $attributeValue1 = $this->dummyData->getAttributeValue();
     $this->attributeValueRepository->shouldReceive('getAttributeValuesByIds')->with([$attributeValue1->getId()], null)->andReturn([$attributeValue1])->once();
     $attributeValues = $this->attributeValueService->getAttributeValuesByIds([$attributeValue1->getId()]);
     $this->assertEntitiesEqual($attributeValue1, $attributeValues[0]);
 }
开发者ID:inklabs,项目名称:kommerce-core,代码行数:7,代码来源:AttributeValueServiceTest.php


示例12: test_can_pass_middleware_during_dispatch_from_array

 public function test_can_pass_middleware_during_dispatch_from_array()
 {
     $this->container->shouldReceive('make')->with(TacticianCommandHandler::class)->once()->andReturn(new TacticianCommandHandler());
     $this->container->shouldReceive('make')->with(LockingMiddleware::class)->once()->andReturn(new LockingMiddleware());
     $result = $this->bus->dispatchFromArray(TacticianCommand::class, [], [LockingMiddleware::class]);
     $this->assertEquals('handled', $result);
 }
开发者ID:Mosaic,项目名称:Mosaic,代码行数:7,代码来源:TacticianBusTest.php


示例13: it_adds_writes_error_to_output_on_fail

 /**
  * @test
  */
 public function it_adds_writes_error_to_output_on_fail()
 {
     $this->response_mock->shouldReceive('getSuccessful')->andReturn(false)->once();
     $this->response_mock->shouldReceive('getResponse')->andReturn("Error")->once();
     $this->output_mock->shouldReceive('writeln')->with("<error>Error</error>")->once();
     $this->stub->exposeOutputResponse($this->response_mock);
 }
开发者ID:JustinAzoff,项目名称:connectwise-php-generator,代码行数:10,代码来源:ResponseParserTest.php


示例14: getDashboard_sets_the_page_title_and_makes_the_dashboard_view

 /**
  * @test getDashboard() sets the page title and makes the dashboard view
  */
 public function getDashboard_sets_the_page_title_and_makes_the_dashboard_view()
 {
     $this->helpers->shouldReceive('setPageTitle')->with('Dashboard')->once();
     $this->view->shouldReceive('make')->with('larapress::pages.cp.dashboard')->once()->andReturn('foo');
     $controller = $this->getControlPanelControllerInstance();
     $this->assertEquals('foo', $controller->getDashboard());
 }
开发者ID:LaraGit,项目名称:larapress,代码行数:10,代码来源:ControlPanelControllerTest.php


示例15: testSubmitValidDataDodajOrganizacje

 public function testSubmitValidDataDodajOrganizacje()
 {
     //dane formularza - pola i wartości wpisane
     $formData = ['nazwa' => 'Testowa nazwa', 'pnazwa' => 'Pełna nazwa'];
     // dodajOrganizacjeCommand
     $token = M::mock(AbstractToken::class);
     $token->shouldReceive('getUser')->once();
     $this->tokenStorage->shouldReceive('getToken')->once()->andReturn($token);
     $dodajOrganizacjeCommand = new DodajOrganizacjeCommand($this->tokenStorage);
     $dodajOrganizacjeCommand->setNazwa($formData['nazwa']);
     $dodajOrganizacjeCommand->setPnazwa($formData['pnazwa']);
     // formularz
     $form = $this->factory->create(OrganizacjaType::class, $dodajOrganizacjeCommand);
     // submit formularza
     $form->submit($formData);
     // this test checks that none of your data transformers used by the form failed
     $this->assertTrue($form->isSynchronized());
     // sprawdzamy czy obiekty są sobie równe
     $this->assertEquals($dodajOrganizacjeCommand, $form->getData());
     // sprawdzamy czy zgadzają się pola formularza
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
开发者ID:mgugniewicz,项目名称:dodajurlop,代码行数:26,代码来源:OrganizacjaTypeTest.php


示例16: setUp

 protected function setUp()
 {
     $this->entityManager = M::mock(EntityManager::class);
     $classMetaData = new ClassMetadata('AppBundle\\Entity\\Organizacja');
     $this->entityManager->shouldReceive('getClassMetadata')->andReturn($classMetaData);
     $this->entityManager->shouldReceive('persist')->andReturn();
 }
开发者ID:mgugniewicz,项目名称:dodajurlop,代码行数:7,代码来源:TestowanieRepository.php


示例17: testGenerateThrowsException

 public function testGenerateThrowsException()
 {
     $this->repository->shouldReceive('referenceNumberExists')->andReturn(true)->times(3);
     $entity = new FakeReferenceNumberEntity();
     $this->setExpectedException(RuntimeException::class, 'Lookup limit reached');
     $this->hashSegmentGenerator->generate($entity);
 }
开发者ID:inklabs,项目名称:kommerce-core,代码行数:7,代码来源:HashSegmentReferenceNumberGeneratorTest.php


示例18: getMessageCommitConfigurationReturnsSuccesfull

 /**
  * @test
  */
 public function getMessageCommitConfigurationReturnsSuccesfull()
 {
     $data = array('commit-msg' => array('regular-expression' => 'expression'));
     $this->configFileValidator->shouldReceive('validate');
     $this->configFileReader->setData($data);
     $this->assertTrue(is_array($this->configFile->getMessageCommitConfiguration()));
 }
开发者ID:raphaelcarles,项目名称:php-git-hooks,代码行数:10,代码来源:ConfigFileTest.php


示例19: dataMethodsSendsProperRequestWithData

 /**
  * @test
  * @dataProvider dataMethods
  */
 public function dataMethodsSendsProperRequestWithData($method, $expectedMethod)
 {
     $this->request->shouldReceive($expectedMethod)->with('http://test.example.com/foo/bar', '{"test":"boo"}')->andReturnSelf();
     $this->request->shouldReceive('send')->andReturn((object) ['body' => 'OK']);
     $actual = $this->client->callRestfulApi($method, 'foo/bar', json_encode(['test' => 'boo']));
     $this->assertEquals('OK', $actual);
 }
开发者ID:alfmartinez,项目名称:am-micro-client,代码行数:11,代码来源:ClientTest.php


示例20: testFindAll

 public function testFindAll()
 {
     $cartPriceRule1 = $this->dummyData->getCartPriceRule();
     $this->cartPriceRuleRepository->shouldReceive('findAll')->andReturn([$cartPriceRule1])->once();
     $cartPriceRules = $this->cartPriceRuleService->findAll();
     $this->assertEntitiesEqual($cartPriceRule1, $cartPriceRules[0]);
 }
开发者ID:inklabs,项目名称:kommerce-core,代码行数:7,代码来源:CartPriceRuleServiceTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Mockery\MockInterface类代码示例发布时间:2022-05-23
下一篇:
PHP Builder\SimpleXMLElement类代码示例发布时间: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