Inheritance: implements Mockery\MockInterface
Ejemplo n.º 1
0
 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);
 }
 protected function setUp()
 {
     $this->rodzaj = new LoadUrlopRodzajData();
     $this->manager = M::mock(ObjectManager::class);
     $this->manager->shouldReceive('persist');
     $this->manager->shouldReceive('flush');
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 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();
 }
 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]);
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
 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));
 }
 /**
  * @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);
 }
 /**
  * @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());
 }
Ejemplo n.º 10
0
 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);
     }
 }
 /**
  * @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();
 }
Ejemplo n.º 12
0
 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();
 }
 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);
 }
Ejemplo n.º 14
0
 /**
  * @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()));
 }
Ejemplo n.º 15
0
 /**
  * @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);
 }
 public function testFindAll()
 {
     $cartPriceRule1 = $this->dummyData->getCartPriceRule();
     $this->cartPriceRuleRepository->shouldReceive('findAll')->andReturn([$cartPriceRule1])->once();
     $cartPriceRules = $this->cartPriceRuleService->findAll();
     $this->assertEntitiesEqual($cartPriceRule1, $cartPriceRules[0]);
 }
Ejemplo n.º 17
0
 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('');
 }
Ejemplo n.º 18
0
 public function testFileExists()
 {
     $this->mock->shouldReceive('locateName')->once()->with('bar')->andReturn(true);
     $this->mock->shouldReceive('locateName')->once()->with('foo/bar')->andReturn(false);
     $this->assertTrue($this->zip->fileExists('bar'));
     $this->assertFalse($this->zip->fileExists('foo/bar'));
 }
 /**
  * @test
  */
 public function preCommitAddPhpCsFixerWithInvalidLevel()
 {
     $this->setExpectedException(\InvalidArgumentException::class);
     $this->IO->shouldReceive('ask')->times(2)->andReturn('y', 'invalid_level');
     $configData = $this->preCommitProcessor->execute(['pre-commit' => ['execute' => ['phpunit' => true, 'phpcs' => true, 'phplint' => true, 'phpmd' => true, 'jsonlint' => true], 'enabled' => true]]);
     $configData['pre-commit']['execute'];
 }
Ejemplo n.º 20
0
 /**
  * @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));
 }
Ejemplo n.º 21
0
 public function testSubmitValidDataDodajPracownik()
 {
     //dane formularza - pola i wartości wpisane
     $formData = ['imie' => 'Johan', 'nazw' => 'Kruzestein', 'email' => '*****@*****.**', 'iloscDniWolnych' => '40'];
     // dodajPracownikCommand
     $token = M::mock(AbstractToken::class);
     $token->shouldReceive('getUser')->once();
     $this->tokenStorage->shouldReceive('getToken')->once()->andReturn($token);
     $dodajPracownikCommand = new DodajPracownikaCommand($this->tokenStorage);
     $dodajPracownikCommand->setImie($formData['imie']);
     $dodajPracownikCommand->setNazw($formData['nazw']);
     $dodajPracownikCommand->setEmail($formData['email']);
     $dodajPracownikCommand->setIloscDniWolnych($formData['iloscDniWolnych']);
     //formularz
     $form = $this->factory->create(PracownikType::class, $dodajPracownikCommand);
     //submit formularz
     $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($dodajPracownikCommand, $form->getData());
     // sprawdzamy czy zgadzają się pola formularza
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
Ejemplo n.º 22
0
 public function testAllGetCouponsByIds()
 {
     $coupon1 = $this->dummyData->getCoupon();
     $this->couponRepository->shouldReceive('getAllCouponsByIds')->with([$coupon1->getId()], null)->andReturn([$coupon1])->once();
     $coupons = $this->couponService->getAllCouponsByIds([$coupon1->getId()]);
     $this->assertSame($coupon1, $coupons[0]);
 }
Ejemplo n.º 23
0
 /**
  * @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;
 }
Ejemplo n.º 24
0
 public function testFindByZip5AndStateWithZip5()
 {
     $taxRate1 = $this->dummyData->getTaxRate();
     $this->taxRateRepository->shouldReceive('findByZip5AndState')->with($taxRate1->getZip5(), null)->andReturn($taxRate1)->once();
     $taxRate = $this->taxRateService->findByZip5AndState($taxRate1->getZip5());
     $this->assertEntitiesEqual($taxRate1, $taxRate);
 }
 private function getHandler()
 {
     $this->organizacjaRepository->shouldReceive('add')->once()->andReturn();
     $this->command->shouldReceive('getUser')->once()->andReturn(new User());
     $this->command->shouldReceive('getNazwa')->once()->andReturn();
     $this->command->shouldReceive('getPnazwa')->once()->andReturn();
 }
Ejemplo n.º 26
0
 public function testFindOneById()
 {
     $attribute1 = $this->dummyData->getAttribute();
     $this->attributeRepository->shouldReceive('findOneById')->with($attribute1->getId())->andReturn($attribute1)->once();
     $attribute = $this->attributeService->findOneById($attribute1->getId());
     $this->assertSame($attribute1, $attribute);
 }
 public function test_transforms_debugstack_query_log_to_clockwork_compatible_array()
 {
     $this->writer->shouldReceive('debug')->once();
     $this->logger->startQuery('SELECT * FROM table WHERE condition = ?', ['value']);
     $this->logger->stopQuery();
     $this->assertEquals('SELECT * FROM table WHERE condition = "value"', $this->logger->getQuery());
 }
Ejemplo n.º 28
0
 /**
  * @test
  */
 public function render_withoutTemplateEngine_returnString()
 {
     $this->mockedFileLoader->shouldReceive('load')->with('test', 'template')->andReturn('test {{param1}} test {{param2}} test');
     $response = $this->invokeMethod('render', ['test', ['param1' => 'value1', 'param2' => 'value2']]);
     $this->assertInstanceOf('Neat\\Http\\Response', $response);
     $this->assertSame('test value1 test value2 test', $response->body);
 }
Ejemplo n.º 29
0
 public function testDirectLogCallsAreProxiedToTheZendLogger()
 {
     $logLevel = LogLevel::INFO;
     $message = 'it works!';
     $extra = array('foo' => 'bar');
     $this->zendLogger->shouldReceive('log')->once()->with($this->psrLogger->getZendLogLevel($logLevel), $message, $extra)->andReturnSelf();
     call_user_func(array($this->psrLogger, 'log'), $logLevel, $message, $extra);
 }
Ejemplo n.º 30
0
 /**
  * @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());
 }