IcalLibTest.php 1.3 KB

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