Exemple #1
0
 public function testWrite()
 {
     $writer = new SyWriter();
     $rssWriter = new RssWriter();
     $sy = new Sy();
     $sy->setUpdateFrequency(2);
     $sy->setUpdateBase(new \DateTime('2001-01-01', new \DateTimeZone('UTC')));
     $sy->setUpdatePeriod(Sy::PERIOD_DAILY);
     $writer->write($rssWriter, $sy);
     $this->assertSame("<sy:updatePeriod>daily</sy:updatePeriod><sy:updateFrequency>2</sy:updateFrequency><sy:updateBase>Mon, 01 Jan 2001 00:00:00 +0000</sy:updateBase>", $rssWriter->getXmlWriter()->flush());
 }
Exemple #2
0
 public function testAccessors()
 {
     $sy = new Sy();
     $base = new \DateTime('2000-01-01');
     $sy->setUpdatePeriod(Sy::PERIOD_HOURLY)->setUpdateFrequency(4)->setUpdateBase($base)->setUpdateFrequency(1);
     $this->assertSame(Sy::PERIOD_HOURLY, $sy->getUpdatePeriod());
     $this->assertSame(1, $sy->getUpdateFrequency());
     $this->assertSame($base, $sy->getUpdateBase());
     $sy->setUpdateBase(null);
     $this->assertNull($sy->getUpdateBase());
 }
Exemple #3
0
 public function write(RssWriter $rssWriter, Sy $extension)
 {
     $writer = $rssWriter->getXmlWriter();
     if ($extension->getUpdatePeriod()) {
         $writer->writeElement('sy:updatePeriod', $extension->getUpdatePeriod());
     }
     if ($extension->getUpdateFrequency()) {
         $writer->writeElement('sy:updateFrequency', $extension->getUpdateFrequency());
     }
     if ($extension->getUpdateBase()) {
         $writer->writeElement('sy:updateBase', $extension->getUpdateBase()->format('r'));
     }
 }