97 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			97 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php 
 | |
| 
 | |
| use Sabre\VObject\Component\VCalendar;
 | |
| use Sabre\DAV\Exception\BadRequest;
 | |
| use Aerex\TaskwarriorPlugin\Plugin;
 | |
| use Aerex\TaskwarriorPlugin\Config;
 | |
| use Aerex\TaskwarriorPlugin\iCalEventProcessor;
 | |
| use Sabre\DAV\Server;
 | |
| use DateTime;
 | |
| use DateTimeZone;
 | |
| 
 | |
| class PluginTest extends \PHPUnit\Framework\TestCase {
 | |
|   
 | |
|  /** 
 | |
|   * @var Plugin
 | |
|   *
 | |
|   */ 
 | |
|   private $plugin;
 | |
|   /**
 | |
|    * @var VCalendar
 | |
|    */
 | |
|   private $cal;
 | |
| 
 | |
| 
 | |
|   
 | |
|   /**
 | |
|    * @var Server
 | |
|    */
 | |
|   private $server;
 | |
| 
 | |
|   /**
 | |
|    * @var TaskwarriorCalendarEvent
 | |
|    */
 | |
|   private $mockTaskCalEvent;
 | |
| 
 | |
| 
 | |
|   /**
 | |
|    * @var TaskwarriorConfig
 | |
|    */
 | |
|   private $mockTaskwarriorConfig;
 | |
| 
 | |
|   function setup(){
 | |
| 
 | |
|     $this->cal = new VCalendar();
 | |
|     $this->mockTaskCalEvent = $this->createMock(iCalEventProcessor::class);
 | |
|     $this->cal->add('VTODO', [
 | |
|       "UID" => "1ff0313e-1ffa-4a18-b8c1-449bddc9109c",
 | |
|     ], false);
 | |
| 
 | |
|   }
 | |
| 
 | |
|   function testCreateSimpleTask() {
 | |
| 
 | |
|     $this->server = new Server();
 | |
| 
 | |
|     $this->mockTaskCalEvent->expects($this->once())
 | |
|       ->method('importTask')
 | |
|       ->with($this->cal->VTODO);
 | |
| 
 | |
|     $this->plugin = new Plugin($this->mockTaskCalEvent);
 | |
|     $this->plugin->initialize($this->server);
 | |
|     $this->plugin->processCalendarEventForTaskwarrior($this->cal);
 | |
| 
 | |
|   }
 | |
| 
 | |
| /* 
 | |
|  * TODO Need to figure out why it is not throwing the correct Exception
 | |
|   function testBadRequest(){
 | |
|     $expectedBadRequestMessage = 'This was a bad request';
 | |
| 
 | |
|     $this->server = new Server();
 | |
|     $this->cal = new VCalendar();
 | |
| 
 | |
|     $this->mockTaskCalEvent->expects($this->once())
 | |
|       ->method('buildVEVENTForTW')
 | |
|       ->with($this->cal->VEVENT);
 | |
|     $this->mockTaskCalEvent
 | |
|       ->method('buildVTODOForTW')
 | |
|       ->with($this->throwException(new BadRequest));
 | |
| 
 | |
| 
 | |
|     $this->plugin = new Plugin($this->mockTaskCalEvent);
 | |
|     $this->plugin->initialize($this->server);
 | |
|     try {
 | |
|       $this->plugin->processCalendarEventForTaskwarrior($this->cal);
 | |
|     } catch(BadRequest $e){
 | |
|       $this->assertInstanceOf(BadRequest::class, $e);
 | |
| 
 | |
|     }
 | |
| 
 | |
|   }
 | |
| 
 | |
|  */
 | |
| }
 | |
| 
 | |
| ?>
 |