當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Mockery\Mock類代碼示例

本文整理匯總了PHP中Mockery\Mock的典型用法代碼示例。如果您正苦於以下問題:PHP Mock類的具體用法?PHP Mock怎麽用?PHP Mock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Mock類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

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

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

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

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

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

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

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

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

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


注:本文中的Mockery\Mock類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。