Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function projectDataProvider()
 {
     $forEachProjector = new ForEachProjector(Selectors::key('list'), new ObjectProjector());
     /** @var \Cubiche\Core\Projection\WhereProjector $projector */
     $projector = $this->newTestedInstance(Criteria::property('foo')->eq(1), $forEachProjector);
     $result = new DefaultProjectionBuilder();
     $result->set('foo', 1);
     return array(array($projector, array('list' => array((object) array('foo' => 1), (object) array('foo' => 2), (object) array('foo' => 3))), new \ArrayIterator(array($result))));
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 protected function comparator()
 {
     return Comparator::by(Criteria::property('age'));
 }
 /**
  * @return \Cubiche\Core\Specification\SpecificationInterface
  */
 protected function newRandomSpecification()
 {
     switch (\rand(0, 3)) {
         case 0:
             return Criteria::eq(5);
         case 1:
             return Criteria::gte(5);
         case 2:
             return Criteria::property('foo')->lte(10);
         case 3:
         default:
             return Criteria::false();
     }
 }
 /**
  * Test findOne.
  */
 public function testFindOne()
 {
     $this->given($repository = $this->emptyRepository())->and($value = $this->randomValue())->when($repository->persist($value))->then()->object($repository->findOne(Criteria::property('id')->eq($value->id())))->isEqualTo($value);
 }
 /**
  * Test visitAtLeast.
  */
 public function testAtLeast()
 {
     $this->visitTest(Criteria::property('foo')->any(Criteria::property('bar')->gt(10)), function () {
         $qb = $this->createQueryBuilder();
         return $qb->field('foo')->elemMatch($qb->expr()->field('bar')->gt(10));
     });
     $this->notSupportedOperationTest(Criteria::property('foo')->atLeast(2, Criteria::property('bar')->gt(10)));
 }
Example #6
0
 /**
  * Test property.
  */
 public function testProperty()
 {
     $this->fieldSelectorTest(Criteria::property('foo'), Property::class, 'foo');
 }