summaryrefslogtreecommitdiff
path: root/tests/integration/TaskFileTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/TaskFileTest.php')
-rw-r--r--tests/integration/TaskFileTest.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/integration/TaskFileTest.php b/tests/integration/TaskFileTest.php
new file mode 100644
index 00000000..7e9e943b
--- /dev/null
+++ b/tests/integration/TaskFileTest.php
@@ -0,0 +1,67 @@
+<?php
+
+require_once __DIR__.'/BaseIntegrationTest.php';
+
+class TaskFileTest extends BaseIntegrationTest
+{
+ 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);
+ }
+}