Example #1
0
 /**
  * Add the content of a Criteria to the current Criteria
  * In case of conflict, the current Criteria keeps its properties
  * @see Criteria::mergeWith()
  *
  * @param Criteria $criteria The criteria to read properties from
  * @param string   $operator The logical operator used to combine conditions
  *              Defaults to Criteria::LOGICAL_AND, also accapts Criteria::LOGICAL_OR
  *
  * @return ModelCriteria The primary criteria object
  */
 public function mergeWith(Criteria $criteria, $operator = null)
 {
     parent::mergeWith($criteria, $operator);
     // merge with
     if ($criteria instanceof ModelCriteria) {
         $this->with = array_merge($this->getWith(), $criteria->getWith());
     }
     return $this;
 }
Example #2
0
 public function testMergeWithFurtherModified()
 {
     $c1 = new Criteria();
     $c2 = new Criteria();
     $c2->setLimit(123);
     $c1->mergeWith($c2);
     $this->assertEquals(123, $c1->getLimit(), 'mergeWith() makes the merge');
     $c2->setLimit(456);
     $this->assertEquals(123, $c1->getLimit(), 'further modifying a merged criteria does not affect the merger');
 }