Example #1
0
 /**
  * @return array
  */
 protected function buildRootPath()
 {
     $items = [];
     $segments = explode('/', rtrim($this->route, '/'));
     $route = '';
     $delim = '';
     foreach ($segments as $segment) {
         $route .= $delim . $segment;
         $delim = '/';
         $item = $this->collection->getItem($route);
         if (isset($item)) {
             $items[] = $item;
         }
     }
     return $items;
 }
 public function test_getting_non_existent_item_from_collection()
 {
     $this->setExpectedException('UnexpectedValueException');
     $coll = new Collection();
     $coll->addItem('Test Item', 1);
     $actual = $coll->getItem(2);
 }
Example #3
0
 /**
  * 
  * EDITA CARRINHO
  * @param Collection $arrayCollection
  * @param Array $nomeIndiceArraySessao
  */
 public function editCarrinho($arrayCollection, $nomeIndiceArraySessao)
 {
     //remove a sessao de conteudo do carrinho
     unset($_SESSION[$this->nomeSessao]);
     //quantidade de indices do array
     $i = count($nomeIndiceArraySessao);
     while ($arrayCollection->Proximo()) {
         $alternativa = $arrayCollection->getItem();
         $stringItem = '';
         //contagem de qual indice está
         $j = 1;
         foreach ($nomeIndiceArraySessao as $value) {
             $stringItem .= $alternativa[$value];
             if ($j < $i) {
                 $stringItem .= '|';
             }
             $j++;
         }
         $stringItem .= '#';
         //adiciona ao carrinho
         $this->insereCarrinho($stringItem);
     }
 }