Esempio n. 1
0
 /**
  * Stub chain of methods
  *
  * @param string $code
  */
 protected function stub($code)
 {
     $this->checkEntity();
     if (!$code instanceof Closure) {
         throw new PStub_Stubber_Exception('Invalid use of chain stubber');
     }
     $callback = $code;
     $chain = $this->createChain($callback);
     $index = PStub_Stubber_Container::addValue($chain);
     $this->usedIndexes['value'][] = $index;
     $stubCode = str_replace('%index%', $index, self::$templates['value']);
     $method = $this->getReflectionMethodObject();
     $method->setBody($stubCode);
 }
Esempio n. 2
0
 /**
  * Clean used indexed in container
  *
  */
 protected function cleanContainer()
 {
     foreach ($this->usedIndexes['value'] as $index) {
         PStub_Stubber_Container::removeValue($index);
     }
     $this->usedIndexes['value'] = array();
     foreach ($this->usedIndexes['callback'] as $index) {
         PStub_Stubber_Container::removeMethod($index);
     }
     $this->usedIndexes['callback'] = array();
 }