diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-06-26 15:17:38 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-06-26 15:17:38 -0400 |
commit | f62112983635a281108575bb69bb90df6bed68b7 (patch) | |
tree | 6e5cf4713e0ba1f5301376f568f0229ddd27a520 /tests | |
parent | 3d34681610854474cb9dbdd93886dbcf0e208a99 (diff) |
Added new API calls for project attachements
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/docker/entrypoint.sh | 2 | ||||
-rw-r--r-- | tests/integration/ProjectFileProcedureTest.php | 66 | ||||
-rw-r--r-- | tests/integration/TaskFileProcedureTest.php | 2 |
3 files changed, 68 insertions, 2 deletions
diff --git a/tests/docker/entrypoint.sh b/tests/docker/entrypoint.sh index a88c7ed8..5a37ae4e 100755 --- a/tests/docker/entrypoint.sh +++ b/tests/docker/entrypoint.sh @@ -23,7 +23,7 @@ case "$1" in /var/www/html/vendor/phpunit/phpunit/phpunit -c /var/www/html/tests/integration.sqlite.xml ;; "integration-test-postgres") - wait_schema_creation 5 + wait_schema_creation 10 /var/www/html/vendor/phpunit/phpunit/phpunit -c /var/www/html/tests/integration.postgres.xml ;; "integration-test-mysql") diff --git a/tests/integration/ProjectFileProcedureTest.php b/tests/integration/ProjectFileProcedureTest.php new file mode 100644 index 00000000..8ac70d87 --- /dev/null +++ b/tests/integration/ProjectFileProcedureTest.php @@ -0,0 +1,66 @@ +<?php + +require_once __DIR__.'/BaseProcedureTest.php'; + +class ProjectFileProcedureTest extends BaseProcedureTest +{ + protected $projectName = 'My project to test project files'; + protected $fileId; + + public function testAll() + { + $this->assertCreateTeamProject(); + $this->assertCreateProjectFile(); + $this->assertGetProjectFile(); + $this->assertDownloadProjectFile(); + $this->assertGetAllFiles(); + $this->assertRemoveProjectFile(); + $this->assertRemoveAllProjectFiles(); + } + + public function assertCreateProjectFile() + { + $this->fileId = $this->app->createProjectFile($this->projectId, 'My file.txt', base64_encode('plain text file')); + $this->assertNotFalse($this->fileId); + } + + public function assertGetProjectFile() + { + $file = $this->app->getProjectFile($this->projectId, $this->fileId); + $this->assertNotEmpty($file); + $this->assertEquals('My file.txt', $file['name']); + } + + public function assertDownloadProjectFile() + { + $content = $this->app->downloadProjectFile($this->projectId, $this->fileId); + $this->assertNotEmpty($content); + $this->assertEquals('plain text file', base64_decode($content)); + } + + public function assertGetAllFiles() + { + $files = $this->app->getAllProjectFiles($this->projectId); + $this->assertCount(1, $files); + $this->assertEquals('My file.txt', $files[0]['name']); + } + + public function assertRemoveProjectFile() + { + $this->assertTrue($this->app->removeProjectFile($this->projectId, $this->fileId)); + + $files = $this->app->getAllProjectFiles($this->projectId); + $this->assertEmpty($files); + } + + public function assertRemoveAllProjectFiles() + { + $this->assertCreateProjectFile(); + $this->assertCreateProjectFile(); + + $this->assertTrue($this->app->removeAllProjectFiles($this->projectId)); + + $files = $this->app->getAllProjectFiles($this->projectId); + $this->assertEmpty($files); + } +} diff --git a/tests/integration/TaskFileProcedureTest.php b/tests/integration/TaskFileProcedureTest.php index 61155555..60909ecd 100644 --- a/tests/integration/TaskFileProcedureTest.php +++ b/tests/integration/TaskFileProcedureTest.php @@ -21,7 +21,7 @@ class TaskFileProcedureTest extends BaseProcedureTest public function assertCreateTaskFile() { - $this->fileId = $this->app->createTaskFile(1, $this->taskId, 'My file', base64_encode('plain text file')); + $this->fileId = $this->app->createTaskFile($this->projectId, $this->taskId, 'My file', base64_encode('plain text file')); $this->assertNotFalse($this->fileId); } |