public function testFindSchedules()
 {
     $limit = 2;
     $offset = 1;
     $this->repository->expects($this->once())->method('findBy')->with(array(), array(), $limit, $offset);
     $this->subject->findSchedules($limit, $offset);
 }
Пример #2
0
 /**
  * @expectedException \Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException
  */
 public function testFindWithInvalidObject()
 {
     $this->loader->expects($this->atLeastOnce())->method('mapPathToId')->with('/foo/bar')->will($this->returnValue(1337));
     $this->loader->expects($this->never())->method('getStreamFromImage');
     $this->om->expects($this->atLeastOnce())->method('find')->with(null, 1337)->will($this->returnValue(null));
     $this->loader->find('/foo/bar');
 }
 public function testFindSchedules()
 {
     $limit = 5;
     $offset = 10;
     $this->repository->expects($this->once())->method('findBy')->with(array('isActive' => true), array(), $limit, $offset)->willReturn('foobar');
     $result = $this->subject->findSchedules($limit, $offset);
     $this->assertSame('foobar', $result);
 }
 public function testGetNextValueWithNotExistingSequenceReturnsNextValue()
 {
     $sequenceName = 'ABC';
     $this->repository->expects($this->once())->method('findOneBy')->with(array('name' => $sequenceName))->willReturn(null);
     $this->objectManager->expects($this->any())->method('persist');
     $this->objectManager->expects($this->any())->method('flush');
     $result = $this->subject->getNextValue($sequenceName);
     $this->assertEquals(1, $result);
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $firstDomainConfiguration = $this->getMockBuilder('Kunstmaan\\AdminBundle\\Helper\\DomainConfigurationInterface')->disableOriginalConstructor()->getMock();
     $firstDomainConfiguration->expects($this->any())->method('getHost')->will($this->returnValue('sub.domain.com'));
     $secondDomainConfiguration = $this->getMockBuilder('Kunstmaan\\AdminBundle\\Helper\\DomainConfigurationInterface')->disableOriginalConstructor()->getMock();
     $secondDomainConfiguration->expects($this->any())->method('getHost')->will($this->returnValue('other.domain.com'));
     $this->repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $this->repository->expects($this->any())->method('findAll')->will($this->returnValue($this->getRedirects()));
     $this->firstObject = new RedirectRouter($this->repository, $firstDomainConfiguration);
     $this->secondObject = new RedirectRouter($this->repository, $secondDomainConfiguration);
 }
 /**
  * Tests that the Transformer uses the query_builder_method configuration option
  * allowing configuration of createQueryBuilder call.
  */
 public function testTransformUsesDefaultQueryBuilderMethodConfiguration()
 {
     $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
     $this->repository->expects($this->never())->method('customQueryBuilderCreator');
     $this->repository->expects($this->once())->method('createQueryBuilder')->with($this->equalTo(ElasticaToModelTransformer::ENTITY_ALIAS))->will($this->returnValue($qb));
     $transformer = new ElasticaToModelTransformer($this->registry, $this->objectClass);
     $class = new \ReflectionClass('FOS\\ElasticaBundle\\Doctrine\\ORM\\ElasticaToModelTransformer');
     $method = $class->getMethod('getEntityQueryBuilder');
     $method->setAccessible(true);
     $method->invokeArgs($transformer, array());
 }
Пример #7
0
 /**
  * @dataProvider sourceDataProvider
  *
  * @param mixed  $source
  * @param bool   $foundInDatabase
  * @param array  $expectedResult
  * @param string $exception
  */
 public function testToMagentoData($source, $foundInDatabase, $expectedResult, $exception = null)
 {
     if ($exception) {
         $this->setExpectedException($exception);
     }
     if ($foundInDatabase === true) {
         $region = new Region();
         $region->setRegionId(self::TEST_MAGENTO_REGION_ID);
         $this->repository->expects($this->once())->method('findOneBy')->will($this->returnValue($region));
     } elseif ($foundInDatabase === false) {
         $this->repository->expects($this->once())->method('findOneBy')->will($this->returnValue(null));
     }
     // more than one call should not provoke expectation errors
     $this->assertSame($expectedResult, $this->converter->toMagentoData($source));
     $this->assertSame($expectedResult, $this->converter->toMagentoData($source));
 }
 /**
  * @param mixed $formData
  * @param bool $expects
  * @param bool $isFormValid
  * @param PriceList|null $priceList
  *
  * @dataProvider onPostSubmitDataProvider
  */
 public function testOnPostSubmit($formData, $expects, $isFormValid = true, $priceList = null)
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|FormEvent $event */
     $event = $this->getMockBuilder('Symfony\\Component\\Form\\FormEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->once())->method('getData')->willReturn($formData);
     $rootForm = $this->getMock('Symfony\\Component\\Form\\FormInterface');
     $rootForm->expects($this->any())->method('isValid')->willReturn($isFormValid);
     $event->expects($this->any())->method('getForm')->willReturn($rootForm);
     if ($expects && $isFormValid) {
         $this->repository->expects($this->once())->method($this->getSetterMethodName())->with($formData, $priceList);
         $priceListFrom = $this->getMock('Symfony\\Component\\Form\\FormInterface');
         $priceListFrom->expects($this->once())->method('getData')->willReturn($priceList);
         $rootForm->expects($this->once())->method('get')->willReturn($priceListFrom);
     }
     $this->getExtension()->onPostSubmit($event);
 }
Пример #9
0
 /**
  * @test
  */
 public function findBy()
 {
     $return = array(new SimpleModel());
     $criteria = array('id' => 2);
     $this->objectRepository->expects($this->once())->method('findBy')->with($criteria)->will($this->returnValue($return));
     $this->assertEquals($return, $this->uut->findBy($criteria));
 }
 /**
  * Checks that the 'hints' parameter is used on the created query
  */
 public function testUsesHintsConfigurationIfGiven()
 {
     $query = $this->getMockBuilder('Doctrine\\ORM\\AbstractQuery')->setMethods(array('setHint', 'execute', 'setHydrationMode'))->disableOriginalConstructor()->getMockForAbstractClass();
     $query->expects($this->any())->method('setHydrationMode')->willReturnSelf();
     $query->expects($this->once())->method('setHint')->with('customHintName', 'Custom\\Hint\\Class')->willReturnSelf();
     $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
     $qb->expects($this->any())->method('getQuery')->willReturn($query);
     $qb->expects($this->any())->method('expr')->willReturn($this->getMockBuilder('Doctrine\\ORM\\Query\\Expr')->getMock());
     $qb->expects($this->any())->method('andWhere')->willReturnSelf();
     $this->repository->expects($this->once())->method('createQueryBuilder')->with($this->equalTo(ElasticaToModelTransformer::ENTITY_ALIAS))->will($this->returnValue($qb));
     $transformer = new ElasticaToModelTransformer($this->registry, $this->objectClass, array('hints' => array(array('name' => 'customHintName', 'value' => 'Custom\\Hint\\Class'))));
     $class = new \ReflectionClass('FOS\\ElasticaBundle\\Doctrine\\ORM\\ElasticaToModelTransformer');
     $method = $class->getMethod('findByIdentifiers');
     $method->setAccessible(true);
     $method->invokeArgs($transformer, array(array(1, 2, 3), true));
 }
Пример #11
0
 public function testFindBy()
 {
     $criteria = array('foo');
     $orderBy = array('foo' => 'bar');
     $limit = 2;
     $offset = 1;
     $this->repository->expects($this->once())->method('findBy')->with($criteria, $orderBy, $limit, $offset);
     $this->subject->findBy($criteria, $orderBy, $limit, $offset);
 }
 public function testReleaseWithExistingLockReturnsTrue()
 {
     $lockName = 'ABC';
     $lockNameWithPrefix = $this->prefix . '-ABC';
     $this->repository->expects($this->once())->method('findOneBy')->with(['name' => $lockNameWithPrefix])->willReturn(new ResourceLock());
     $this->objectManager->expects($this->once())->method('remove');
     $this->objectManager->expects($this->once())->method('flush');
     $result = $this->subject->release($lockName);
     $this->assertTrue($result);
 }
Пример #13
0
 public function testOnRemovedRemovePlugin()
 {
     $plugin = $this->getMock('\\AnimeDb\\Bundle\\AppBundle\\Entity\\Plugin');
     $this->rep->expects($this->once())->method('find')->will($this->returnValue($plugin))->with('foo/bar');
     $this->em->expects($this->once())->method('remove')->with($plugin);
     $this->em->expects($this->once())->method('flush');
     // test
     $event = '\\AnimeDb\\Bundle\\AnimeDbBundle\\Event\\Package\\Removed';
     $this->listener->onRemoved($this->getEvent($this->getPackage(), $event));
 }
Пример #14
0
 public function testLoadChoicesForValuesLoadsOnlyChoicesIfValueIsIdReader()
 {
     $loader = new DoctrineChoiceLoader($this->om, $this->class, $this->idReader, $this->objectLoader);
     $choices = array($this->obj2, $this->obj3);
     $value = array($this->idReader, 'getIdValue');
     $this->idReader->expects($this->any())->method('isSingleId')->willReturn(true);
     $this->idReader->expects($this->any())->method('getIdField')->willReturn('idField');
     $this->repository->expects($this->never())->method('findAll');
     $this->objectLoader->expects($this->once())->method('getEntitiesByIds')->with('idField', array('2'))->willReturn($choices);
     $this->idReader->expects($this->any())->method('getIdValue')->willReturnMap(array(array($this->obj2, '2'), array($this->obj3, '3')));
     $this->assertSame(array($this->obj2), $loader->loadChoicesForValues(array('2'), $value));
 }
Пример #15
0
 public function testFindByChannel()
 {
     $channel = 'Channel';
     $this->repository->expects($this->once())->method('findBy')->with(['channel' => $channel]);
     $this->subject->findByChannel($channel);
 }
 public function testLoad()
 {
     $template = $this->getMockBuilder(Mail::class)->disableOriginalConstructor()->getMock();
     $this->repo->expects($this->once())->method('findOneBy')->with(array('name' => 'test', 'enabled' => true, 'type' => MailUtil::getValidTypes(MailTypes::TYPE_ALL)))->will($this->returnValue($template));
     $this->assertSame($template, $this->loader->load('test'));
 }
 public function testLoad()
 {
     $template = $this->getMockBuilder(Layout::class)->disableOriginalConstructor()->getMock();
     $this->repo->expects($this->once())->method('findOneBy')->with(array('name' => 'test', 'enabled' => true))->will($this->returnValue($template));
     $this->assertSame($template, $this->loader->load('test'));
 }
 public function testFindBy()
 {
     $criteria = array('foo');
     $this->repository->expects($this->once())->method('findOneBy')->with($criteria);
     $this->subject->findOneBy($criteria);
 }