RecurTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Sabre\VObject\Property\ICalendar;
  3. use Sabre\VObject\Component\VCalendar;
  4. class RecurTest extends \PHPUnit_Framework_TestCase {
  5. function testParts() {
  6. $vcal = new VCalendar();
  7. $recur = $vcal->add('RRULE', 'FREQ=Daily');
  8. $this->assertInstanceOf('Sabre\VObject\Property\ICalendar\Recur', $recur);
  9. $this->assertEquals(array('FREQ'=>'DAILY'), $recur->getParts());
  10. $recur->setParts(array('freq'=>'MONTHLY'));
  11. $this->assertEquals(array('FREQ'=>'MONTHLY'), $recur->getParts());
  12. }
  13. /**
  14. * @expectedException \InvalidArgumentException
  15. */
  16. function testSetValueBadVal() {
  17. $vcal = new VCalendar();
  18. $recur = $vcal->add('RRULE', 'FREQ=Daily');
  19. $recur->setValue(new \Exception());
  20. }
  21. function testSetSubParts() {
  22. $vcal = new VCalendar();
  23. $recur = $vcal->add('RRULE', array('FREQ'=>'DAILY', 'BYDAY'=>'mo,tu', 'BYMONTH' => array(0,1)));
  24. $this->assertEquals(array(
  25. 'FREQ'=>'DAILY',
  26. 'BYDAY' => array('MO','TU'),
  27. 'BYMONTH' => array(0,1),
  28. ), $recur->getParts());
  29. }
  30. }