diff options
| author | i00171 <anton.delitsch@implema.se> | 2016-06-26 18:35:25 +0200 | 
|---|---|---|
| committer | i00171 <anton.delitsch@implema.se> | 2016-06-26 18:35:25 +0200 | 
| commit | 47039d32c84ba699867920d2c3cb47a34b199b9d (patch) | |
| tree | 4fbc2ec34889baeab00085e0509055dca7daee6a /tests/integration/TaskFileProcedureTest.php | |
| parent | 911be6ed00c1ece5d9ef2c16e80899bb7bffad67 (diff) | |
| parent | c110dffefe259c13e60193fb81ebb9d4b79504de (diff) | |
Merge branch 'master' of https://github.com/fguillot/kanboard
Diffstat (limited to 'tests/integration/TaskFileProcedureTest.php')
| -rw-r--r-- | tests/integration/TaskFileProcedureTest.php | 67 | 
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/integration/TaskFileProcedureTest.php b/tests/integration/TaskFileProcedureTest.php new file mode 100644 index 00000000..61155555 --- /dev/null +++ b/tests/integration/TaskFileProcedureTest.php @@ -0,0 +1,67 @@ +<?php + +require_once __DIR__.'/BaseProcedureTest.php'; + +class TaskFileProcedureTest extends BaseProcedureTest +{ +    protected $projectName = 'My project to test task files'; +    protected $fileId; + +    public function testAll() +    { +        $this->assertCreateTeamProject(); +        $this->assertCreateTask(); +        $this->assertCreateTaskFile(); +        $this->assertGetTaskFile(); +        $this->assertDownloadTaskFile(); +        $this->assertGetAllFiles(); +        $this->assertRemoveTaskFile(); +        $this->assertRemoveAllTaskFiles(); +    } + +    public function assertCreateTaskFile() +    { +        $this->fileId = $this->app->createTaskFile(1, $this->taskId, 'My file', base64_encode('plain text file')); +        $this->assertNotFalse($this->fileId); +    } + +    public function assertGetTaskFile() +    { +        $file = $this->app->getTaskFile($this->fileId); +        $this->assertNotEmpty($file); +        $this->assertEquals('My file', $file['name']); +    } + +    public function assertDownloadTaskFile() +    { +        $content = $this->app->downloadTaskFile($this->fileId); +        $this->assertNotEmpty($content); +        $this->assertEquals('plain text file', base64_decode($content)); +    } + +    public function assertGetAllFiles() +    { +        $files = $this->app->getAllTaskFiles(array('task_id' => $this->taskId)); +        $this->assertCount(1, $files); +        $this->assertEquals('My file', $files[0]['name']); +    } + +    public function assertRemoveTaskFile() +    { +        $this->assertTrue($this->app->removeTaskFile($this->fileId)); + +        $files = $this->app->getAllTaskFiles(array('task_id' => $this->taskId)); +        $this->assertEmpty($files); +    } + +    public function assertRemoveAllTaskFiles() +    { +        $this->assertCreateTaskFile(); +        $this->assertCreateTaskFile(); + +        $this->assertTrue($this->app->removeAllTaskFiles($this->taskId)); + +        $files = $this->app->getAllTaskFiles(array('task_id' => $this->taskId)); +        $this->assertEmpty($files); +    } +}  | 
