public function testHierarchy()
 {
     $criteria = new ProxyTestCriteria();
     $p = new TestPropelConditionalProxy($criteria, true);
     $this->assertEquals($p->getCriteria(), $criteria, 'main object is the given one');
     $this->assertInstanceOf('\\Propel\\Runtime\\Util\\PropelConditionalProxy', $p2 = $p->_if(true), '_if returns fluid interface');
     $this->assertEquals($p2->getCriteria(), $criteria, 'main object is the given one, even with nested proxies');
     $this->assertEquals($p2->getParentProxy(), $p, 'nested proxy is respected');
     $p = new PropelConditionalProxy($criteria, true);
     $this->assertEquals($criteria, $p->_if(true), '_if returns fluid interface');
 }
 public function __construct(Criteria $criteria, $cond, self $proxy = null)
 {
     $this->criteria = $criteria;
     $this->wasTrue = false;
     $this->setConditionalState($cond);
     $this->parent = $proxy;
     if (null === $proxy) {
         $this->parentState = true;
     } else {
         $this->parentState = $proxy->getConditionalState();
     }
 }
Beispiel #3
0
 /**
  * Returns the current object
  * Allows for conditional statements in a fluid interface.
  *
  * @return $this|Criteria
  */
 public function _endif()
 {
     if (!$this->conditionalProxy) {
         throw new LogicException(__METHOD__ . ' must be called after _if()');
     }
     $this->conditionalProxy = $this->conditionalProxy->getParentProxy();
     if ($this->conditionalProxy) {
         return $this->conditionalProxy->getCriteriaOrProxy();
     }
     // reached last level
     return $this;
 }