/**
  * Returns the current object
  * Allows for conditional statements in a fluid interface.
  *
  * @throws SQL\Exception\QueryBuilderException
  *
  * @return \SQL\Base\QueryBuilder
  */
 public function _endif()
 {
     if (!$this->conditionalProxy) {
         throw new QueryBuilderException('_endif() must be called after _if()');
     }
     $this->conditionalProxy = $this->conditionalProxy->getParentProxy();
     if ($this->conditionalProxy) {
         return $this->conditionalProxy->getQueryOrProxy();
     }
     // reached last level
     return $this;
 }
 public function testFluidInterface()
 {
     $p = new QueryConditionalProxy($this->queryBuilder, false);
     $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface');
     $this->assertEquals($p->_elseif(true), $this->queryBuilder, '_elseif returns fluid interface');
     $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface');
     $this->assertEquals($p->_else(), $p, '_else returns fluid interface');
     $p = new QueryConditionalProxy($this->queryBuilder, true);
     $this->assertEquals($p->_elseif(true), $p, '_elseif returns fluid interface');
     $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface');
     $this->assertEquals($p->_else(), $p, '_else returns fluid interface');
     $p = new QueryConditionalProxy($this->queryBuilder, false);
     $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface');
     $this->assertEquals($p->_else(), $this->queryBuilder, '_else returns fluid interface');
     $p = new QueryConditionalProxy($this->queryBuilder, false);
     $this->assertEquals($p->_if(false), $p, '_if returns fluid interface');
     $this->assertEquals($p->_endif(), $this->queryBuilder, '_endif returns fluid interface');
     $p = new QueryConditionalProxy($this->queryBuilder, false);
     $this->assertEquals($p->_if(true), $this->queryBuilder, '_if returns fluid interface');
     $this->assertEquals($p->_endif(), $this->queryBuilder, '_endif returns fluid interface');
 }