Example #1
0
 function it_allows_detaching_itself_from_taxonomy(TaxonomyInterface $taxonomy, TaxonInterface $root)
 {
     $taxonomy->getRoot()->willReturn($root);
     $this->setTaxonomy($taxonomy);
     $this->getTaxonomy()->shouldReturn($taxonomy);
     $this->setTaxonomy(null);
     $this->getTaxonomy()->shouldReturn(null);
 }
 /**
  * Add taxon childs to the taxons array recursively.
  *
  * @param TaxonomyInterface $taxonomy
  * @param Collection        $value
  * @param \Traversable      $children
  * @param array             $taxons
  */
 private function addChildren(TaxonomyInterface $taxonomy, Collection $value, $children, array &$taxons)
 {
     if (!is_array($children) && !$children instanceof \Traversable) {
         throw new \InvalidArgumentException('Expecting array or Traversable!');
     }
     /* @var $children TaxonInterface[] */
     foreach ($children as $child) {
         if ($value->contains($this->saveObjects ? $child : $child->getId())) {
             $taxons[$taxonomy->getId()][] = $child;
         }
         if (!$child->getChildren()->isEmpty()) {
             $this->addChildren($taxonomy, $value, $child->getChildren(), $taxons);
         }
     }
 }
 function let(TaxonomyInterface $entityOne, TaxonomyInterface $entityTwo)
 {
     $entityOne->getId()->willReturn(1);
     $entityTwo->getId()->willReturn(2);
     $this->beConstructedWith(array($entityOne, $entityTwo));
 }