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));
 }
 /**
  * Store a feed instance on persistent storage.
  *
  * @param DataFeed $feed The feed to store.
  */
 public function storeFeedHandle(FeedHandle $feed)
 {
     $result = $this->getNamedRow($feed->getName());
     $data = array();
     $format = array();
     $add = function ($name, $value, $f) use($feed, &$data, &$format) {
         if ($value !== null) {
             $data[$name] = $value;
             array_push($format, $f);
         }
     };
     $add('df_url', $feed->getURL(), '%s');
     $add('df_o_url', $feed->getOURL(), '%s');
     $add('df_interval', $feed->getInterval(), '%d');
     $add('df_o_interval', $feed->getOInterval(), '%d');
     $add('df_key', $feed->getKey(), '%s');
     $add('df_key_parameter', $feed->getKeyParameter(), '%s');
     $add('df_pagination_policy', $feed->getPaginationPolicy(), '%s');
     $add('df_o_pagination_policy', $feed->getOPaginationPolicy(), '%s');
     if (is_array($result) && count($result) === 0) {
         $created = new \DateTime('now');
         $feed->setCreated($created);
         $add('df_created', $feed->getCreated()->format('Y-m-d H:i:s'), '%s');
         $add('df_name', $feed->getName(), '%s');
         $this->wpdb->insert($this->tableName(), $data, $format);
     } else {
         $this->wpdb->update($this->tableName(), $data, array('df_name' => $feed->getName()), $format, array('%s'));
     }
 }