TaskwarriorPlugin/tests/Processors/TodoTest.php

60 lines
1.5 KiB
PHP

<?php
use Sabre\DAV\Exception\BadRequest;
use Monolog\Logger;
use Aerex\TaskwarriorPlugin\TaskwarriorManager;
use Aerex\TaskwarriorPlugin\Processors\ToDo;
use Sabre\VObject\Component\VCalendar;
use DavidBadura\Taskwarrior\Task;
use DateTime;
class TodoTest extends \PHPUnit\Framework\TestCase {
/**
* @var \PHPUnit_Framework_MockObject_MockObject
* */
private $mockTaskwarriorManager;
function setup(){
$this->mockTaskwarriorManager = $this->createMock(TaskwarriorManager::class);
}
function testImportAndAddTask(){
$uuid = '9f353281-1051-4c45-92db-462f5d353c76';
$mockVCalendar = new VCalendar();
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
$this->mockTaskwarriorManager->expects($this->once())->method('exists')->with($this->equalTo($uuid))
->willReturn(false);
$this->mockTaskwarriorManager->expects($this->once())->method('addTask')->with($this->equalTo($mockVTodo));
$todo = new ToDo($this->mockTaskwarriorManager);
$todo->import($mockVTodo);
}
function testImportAndUpdateTask(){
$uuid = '9f353281-1051-4c45-92db-462f5d353c76';
$mockVCalendar = new VCalendar();
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
$this->mockTaskwarriorManager->expects($this->once())->method('exists')
->willReturn(true);
$this->mockTaskwarriorManager->expects($this->once())->method('updateTask');
$todo = new ToDo($this->mockTaskwarriorManager);
$todo->import($mockVTodo);
}
}
?>