public function testOverrides() { $store = $this->getMockStore(); $name = 'handle'; $url = 'http://example.com/feed'; $feed = new FeedHandle($this->getMockBuilder('DataFeed\\Store\\FeedStore')->getMock(), $this->getMockBuilder('DataFeed\\Cache\\FeedCache')->getMock(), $this->getMockBuilder('DataFeed\\Pagination\\PageUrlFactory')->disableOriginalConstructor()->getMock(), $this->getMockBuilder('DataFeed\\Pagination\\PageUpdateCheckFactory')->getMock(), $name, $url); $this->assertEquals($feed->getInterval(), null); $feed->setInterval(24 * 60 * 60); $this->assertEquals($feed->getName(), $name); $this->assertEquals($feed->getURL(), $url); $this->assertEquals($feed->getOURL(), null); $this->assertEquals($feed->getEffectiveURL(), $url); $this->assertEquals($feed->getInterval(), 24 * 60 * 60); $this->assertEquals($feed->getOInterval(), null); $this->assertEquals($feed->getEffectiveInterval(), 24 * 60 * 60); $this->assertEquals($feed->getKey(), null); $this->assertEquals($feed->getKeyParameter(), null); $oURL = 'https://example.com/feed2'; $oInterval = 1; $feed->setOURL($oURL); $feed->setOInterval($oInterval); $this->assertEquals($feed->getURL(), $url); $this->assertEquals($feed->getEffectiveURL(), $oURL); $this->assertEquals($feed->getInterval(), 24 * 60 * 60); $this->assertEquals($feed->getEffectiveInterval(), $oInterval); $feed->setOURL(null); $feed->setOInterval(null); $this->assertEquals($feed->getName(), $name); $this->assertEquals($feed->getURL(), $url); $this->assertEquals($feed->getOURL(), null); $this->assertEquals($feed->getEffectiveURL(), $url); $this->assertEquals($feed->getInterval(), 24 * 60 * 60); $this->assertEquals($feed->getOInterval(), null); $this->assertEquals($feed->getEffectiveInterval(), 24 * 60 * 60); $feed->setKey('12345'); $this->assertEquals($feed->getEffectiveURL(), $url . '?key=12345'); $feed->setKeyParameter('foo'); $this->assertEquals($feed->getEffectiveURL(), $url . '?foo=12345'); $feed->setOURL($oURL . '?bar=baz'); $this->assertEquals($feed->getEffectiveURL(), $oURL . '?bar=baz&foo=12345'); $this->assertEquals($feed->asArray(), array('name' => $name, 'url' => $url, 'o_url' => $oURL . '?bar=baz', 'interval' => 24 * 60 * 60, 'o_interval' => null, 'key' => '12345', 'key_parameter' => 'foo', 'pagination_policy' => null, 'o_pagination_policy' => null)); }
private function fillFeedHandle($row, FeedHandle $feed) { $dirty = false; if ($feed->getURL() === null) { $feed->setURL($row->df_url); } else { if ($feed->getURL() != $row->df_url) { $dirty = true; } } if ($row->df_o_url !== null && $row->df_o_url !== '') { $feed->setOURL($row->df_o_url); } if ($feed->getInterval() === null) { $feed->setInterval($row->df_interval); } else { if ($feed->getInterval() != $row->df_interval) { $dirty = true; } } if ($row->df_o_interval !== null) { $feed->setOInterval($row->df_o_interval); } if ($row->df_key !== null) { $feed->setKey($row->df_key); } if ($row->df_key_parameter !== null) { $feed->setKeyParameter($row->df_key_parameter); } if ($row->df_o_pagination_policy !== null) { $feed->setOPaginationPolicy($row->df_o_pagination_policy); } if ($feed->getPaginationPolicy() === null) { $feed->setPaginationPolicy($row->df_pagination_policy); } else { if ($feed->getPaginationPolicy() != $row->df_pagination_policy) { $dirty = true; } } $feed->setCreated($row->df_created); return $dirty ? self::LOAD_RESULT_DIRTY : self::LOAD_RESULT_CLEAN; }