Skip to content

Commit

Permalink
complete configs
Browse files Browse the repository at this point in the history
  • Loading branch information
mamuz committed Feb 27, 2015
1 parent 9d5ce37 commit 31c9c40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 9 additions & 5 deletions src/MamuzBlogFeed/Feed/Writer/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

class Builder implements BuilderInterface
{
/** @var Feed */
private $feedPrototype;

/** @var Feed */
private $feed;

Expand All @@ -27,20 +30,20 @@ class Builder implements BuilderInterface
/**
* @param ExtractionInterface $postExtractor
* @param HydrationInterface $hydrator
* @param Feed $feed
* @param Feed $feedPrototype
*/
public function __construct(
ExtractionInterface $postExtractor,
HydrationInterface $hydrator,
Feed $feed = null
Feed $feedPrototype = null
) {
$this->postExtractor = $postExtractor;
$this->hydrator = $hydrator;

if ($feed) {
$this->feed = $feed;
if ($feedPrototype) {
$this->feedPrototype = $feedPrototype;
} else {
$this->feed = new Feed;
$this->feedPrototype = new Feed;
}
}

Expand All @@ -62,6 +65,7 @@ public function create(array $feedOptions, \IteratorAggregate $entries = null)
*/
private function createFeed(array $feedOptions)
{
$this->feed = clone $this->feedPrototype;
$this->feed->setType('rss');
$this->feed->setLastBuildDate(time());
$this->feed->setGenerator('MamuzBlogFeed');
Expand Down
8 changes: 4 additions & 4 deletions tests/MamuzBlogFeedTest/Feed/Writer/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function testCreationWithUserFeed()
$this->hydrator->shouldReceive('hydrate')->andReturnUsing(
function ($data, $object) use ($options, $feed) {
if ($object instanceof \Zend\Feed\Writer\Feed) {
$this->assertSame($feed, $object);
$this->assertNotSame($feed, $object);
} else {
$this->assertInstanceOf('Zend\Feed\Writer\Entry', $object);
}
Expand Down Expand Up @@ -118,7 +118,7 @@ public function testCreationWithUserFeedAndEntryDatetimeObject()
$this->hydrator->shouldReceive('hydrate')->andReturnUsing(
function ($data, $object) use ($options, $feed) {
if ($object instanceof \Zend\Feed\Writer\Feed) {
$this->assertSame($feed, $object);
$this->assertNotSame($feed, $object);
} else {
$this->assertInstanceOf('Zend\Feed\Writer\Entry', $object);
}
Expand Down Expand Up @@ -164,7 +164,7 @@ public function testCreationWithUserFeedAndEntryDatetimeObjectOrdered()
$this->hydrator->shouldReceive('hydrate')->andReturnUsing(
function ($data, $object) use ($options, $feed, $entryFirst, $entryLast) {
if ($object instanceof \Zend\Feed\Writer\Feed) {
$this->assertSame($feed, $object);
$this->assertNotSame($feed, $object);
} else {
$this->assertInstanceOf('Zend\Feed\Writer\Entry', $object);
if ($this->iteratorCnt == 0) {
Expand Down Expand Up @@ -196,7 +196,7 @@ public function testCreationWithUserFeedWithoutEntries()
$this->hydrator->shouldReceive('hydrate')->andReturnUsing(
function ($data, $object) use ($options, $feed) {
if ($object instanceof \Zend\Feed\Writer\Feed) {
$this->assertSame($feed, $object);
$this->assertNotSame($feed, $object);
} else {
$this->assertInstanceOf('Zend\Feed\Writer\Entry', $object);
}
Expand Down

0 comments on commit 31c9c40

Please sign in to comment.