Example #1
0
 /**
  * it_should_iterate_over_source_posts
  *
  * @param Lns\SocialFeed\Iterator\SourceIterator $sourceIterator1
  * @param Lns\SocialFeed\Iterator\SourceIterator $sourceIterator2
  * @param Lns\SocialFeed\Iterator\SourceIterator $sourceIterator3
  * @param Lns\SocialFeed\Model\PostInterface $post1
  * @param Lns\SocialFeed\Model\PostInterface $post2
  * @param Lns\SocialFeed\Model\PostInterface $post3
  * @param Lns\SocialFeed\Model\PostInterface $post4
  * @param Lns\SocialFeed\Model\PostInterface $post5
  * @param Lns\SocialFeed\Model\PostInterface $post6
  */
 function it_should_iterate_over_source_posts($sourceIterator1, $sourceIterator2, $sourceIterator3, $post1, $post2, $post3, $post4, $post5, $post6)
 {
     $post1->getCreatedAt()->willReturn(new \DateTime('2015-01-01'));
     $post2->getCreatedAt()->willReturn(new \DateTime('2015-02-01'));
     $post3->getCreatedAt()->willReturn(new \DateTime('2015-03-01'));
     $post4->getCreatedAt()->willReturn(new \DateTime('2015-04-01'));
     $post5->getCreatedAt()->willReturn(new \DateTime('2015-05-01'));
     $post6->getCreatedAt()->willReturn(new \DateTime('2015-06-01'));
     $sourceIterator1 = $this->prepareSourceIteratorDouble($sourceIterator1, new \ArrayIterator([$post6, $post3]));
     $sourceIterator2 = $this->prepareSourceIteratorDouble($sourceIterator2, new \ArrayIterator([$post5, $post4]));
     $sourceIterator3 = $this->prepareSourceIteratorDouble($sourceIterator3, new \ArrayIterator([$post2, $post1]));
     $this->addSourceIterator($sourceIterator1)->shouldReturn($this);
     $this->addSourceIterator($sourceIterator2)->shouldReturn($this);
     $this->addSourceIterator($sourceIterator3)->shouldReturn($this);
     $this->rewind();
     $this->current()->shouldReturn($post6);
     $this->valid()->shouldReturn(true);
     $this->next();
     $this->current()->shouldReturn($post5);
     $this->valid()->shouldReturn(true);
     $this->next();
     $this->current()->shouldReturn($post4);
     $this->valid()->shouldReturn(true);
     $this->next();
     $this->current()->shouldReturn($post3);
     $this->valid()->shouldReturn(true);
     $this->next();
     $this->current()->shouldReturn($post2);
     $this->valid()->shouldReturn(true);
     $this->next();
     $this->current()->shouldReturn($post1);
     $this->valid()->shouldReturn(true);
     $this->next();
     $this->valid()->shouldReturn(false);
 }
Example #2
0
 /**
  * it_should_be_possible_to_add_a_post_to_feed
  *
  * @param Lns\SocialFeed\Model\PostInterface $post1
  * @param Lns\SocialFeed\Model\PostInterface $post2
  */
 function it_should_be_possible_to_add_a_post_to_feed($post1, $post2)
 {
     $post1->getUniqueIdentifier()->willReturn('id1');
     $post2->getUniqueIdentifier()->willReturn('id2');
     $this->addPost($post1)->shouldReturn($this);
     $this->addPost($post2)->shouldReturn($this);
     $this->getPost('id1')->shouldReturn($post1);
     $this->getPost('id2')->shouldReturn($post2);
     $iterator = $this->getIterator();
 }
Example #3
0
 /**
  * comparePost.
  *
  * @param PostInterface $post1
  * @param PostInterface $post2
  */
 protected function comparePost(PostInterface $post1, PostInterface $post2)
 {
     return $post1->getCreatedAt() < $post2->getCreatedAt();
 }