IcalLibTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. App::uses('IcalLib', 'Tools.Lib');
  3. class IcalLibTest extends CakeTestCase {
  4. public $file;
  5. public function setUp() {
  6. parent::setUp();
  7. $this->Ical = new IcalLib();
  8. $this->file = CakePlugin::path('Tools') . 'Test' . DS . 'test_files' . DS . 'ics' . DS . 'basic.ics';
  9. }
  10. public function tearDown() {
  11. parent::tearDown();
  12. unset($this->Ical);
  13. }
  14. public function testObject() {
  15. $this->assertTrue(is_object($this->Ical));
  16. }
  17. /** building **/
  18. // see IcalHelper() for this
  19. /** parsing **/
  20. public function testParse() {
  21. $is = $this->Ical->parse($this->file);
  22. $this->assertTrue(!empty($is));
  23. }
  24. public function testCalendarInfos() {
  25. $is = $this->Ical->parse($this->file);
  26. $is = $this->Ical->getCalendarInfos();
  27. //pr($is);
  28. $this->assertTrue(!empty($is));
  29. }
  30. public function testEvents() {
  31. $is = $this->Ical->parse($this->file);
  32. $is = $this->Ical->getEvents();
  33. //pr($is);
  34. $this->assertTrue(!empty($is));
  35. }
  36. public function testTodos() {
  37. $is = $this->Ical->parse($this->file);
  38. $is = $this->Ical->getTodos();
  39. //debug($is).BR;
  40. $this->assertEmpty($is);
  41. }
  42. public function testEventsAsList() {
  43. $is = $this->Ical->parse($this->file);
  44. $is = $this->Ical->getEventsAsList();
  45. foreach ($is as $i => $val) {
  46. //echo date(FORMAT_NICE_YMD, $i).': '.h($val).BR;
  47. }
  48. $this->assertTrue(!empty($is));
  49. }
  50. }