diff options
author | Teamjungla{CODE} <junglacode@gmail.com> | 2016-08-20 13:47:12 -0500 |
---|---|---|
committer | Teamjungla{CODE} <junglacode@gmail.com> | 2016-08-20 13:47:12 -0500 |
commit | fe8e9cdcfe3afc1475c7e7f4392d2b2cc601a12b (patch) | |
tree | 001403874e9e3716de7c6d51a9f536e9b3c3be5e /tests/integration/ProjectFileProcedureTest.php | |
parent | b1e795fc5b45369f7b9b565b1e106d2673361977 (diff) | |
parent | 98efcf21e355ed6ac3827058b99df86ca67c75bb (diff) |
Merge branch 'stable' of https://github.com/kanboard/kanboard
Diffstat (limited to 'tests/integration/ProjectFileProcedureTest.php')
-rw-r--r-- | tests/integration/ProjectFileProcedureTest.php | 66 |
1 files changed, 66 insertions, 0 deletions
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); + } +} |