diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-05-21 14:45:53 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-05-21 18:43:13 +0200 |
commit | 77198abd94437eb418f11957695986470b1afc9a (patch) | |
tree | 710b0285a00aa3f54db274ff01a9eb21017c2164 /application/tests/test_service_files_valid_id.php | |
parent | eb9daf07b1a118b473d352c98c5822c3063e598d (diff) |
tests: Make prove --state work; Restructure tests
This moves all tests into a subdirectory and lets prove itself figure
out which tests exist. It seems if you supply the testlist via
arguments or stdin --state won't affect the order.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/tests/test_service_files_valid_id.php')
-rw-r--r-- | application/tests/test_service_files_valid_id.php | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/application/tests/test_service_files_valid_id.php b/application/tests/test_service_files_valid_id.php deleted file mode 100644 index c090dcbd9..000000000 --- a/application/tests/test_service_files_valid_id.php +++ /dev/null @@ -1,115 +0,0 @@ -<?php -/* - * Copyright 2015 Florian "Bluewind" Pritz <bluewind@server-speed.net> - * - * Licensed under AGPLv3 - * (see COPYING for full license text) - * - */ - -namespace tests; - -class test_service_files_valid_id extends Test { - private $model; - private $filedata; - private $config; - - public function __construct() - { - parent::__construct(); - - $CI =& get_instance(); - $CI->load->model("muser"); - $CI->load->model("mfile"); - - } - - public function init() - { - $this->model = \Mockery::mock("Mfile"); - $this->model->shouldReceive("delete_id")->never()->byDefault(); - $this->model->shouldReceive("delete_data_id")->never()->byDefault(); - $this->model->shouldReceive("file")->with("file-hash-1-1")->andReturn("/invalid/path/file-1")->byDefault(); - $this->model->shouldReceive("filemtime")->with("/invalid/path/file-1")->andReturn(500)->byDefault(); - $this->model->shouldReceive("filesize")->with("/invalid/path/file-1")->andReturn(50*1024)->byDefault(); - $this->model->shouldReceive("file_exists")->with("/invalid/path/file-1")->andReturn(true)->byDefault(); - - $this->filedata = array( - "data_id" => "file-hash-1-1", - "hash" => "file-hash-1", - "id" => "file-id-1", - "user" => 2, - "date" => 500, - ); - - $this->config = array( - "upload_max_age" => 20, - "sess_expiration" => 10, - "small_upload_size" => 10*1024, - ); - } - - public function cleanup() - { - \Mockery::close(); - } - - public function test_valid_id_keepNormalUpload() - { - $ret = \service\files::valid_id($this->filedata, $this->config, $this->model, 505); - $this->t->is($ret, true, "normal case should be valid"); - } - - public function test_valid_id_keepSmallUpload() - { - $this->model->shouldReceive("filesize")->with("/invalid/path/file-1")->once()->andReturn(50); - - $ret = \service\files::valid_id($this->filedata, $this->config, $this->model, 550); - $this->t->is($ret, true, "file is old, but small and should be kept"); - } - - public function test_valid_id_removeOldFile() - { - $this->model->shouldReceive("delete_data_id")->with("file-hash-1-1")->once(); - - $ret = \service\files::valid_id($this->filedata, $this->config, $this->model, 550); - $this->t->is($ret, false, "file is old and should be removed"); - } - - public function test_valid_id_removeOldUpload() - { - $this->model->shouldReceive("delete_id")->with("file-id-1")->once(); - $this->model->shouldReceive("filemtime")->with("/invalid/path/file-1")->once()->andReturn(540); - - $ret = \service\files::valid_id($this->filedata, $this->config, $this->model, 550); - $this->t->is($ret, false, "upload is old and should be removed"); - } - - public function test_valid_id_keepNormalUnownedFile() - { - $this->filedata["user"] = 0; - - $ret = \service\files::valid_id($this->filedata, $this->config, $this->model, 505); - $this->t->is($ret, true, "upload is unowned and should be kept"); - } - - public function test_valid_id_removeOldUnownedFile() - { - $this->model->shouldReceive("delete_id")->with("file-id-1")->once(); - $this->filedata["user"] = 0; - - $ret = \service\files::valid_id($this->filedata, $this->config, $this->model, 515); - $this->t->is($ret, false, "upload is old, unowned and should be removed"); - } - - public function test_valid_id_removeMissingFile() - { - $this->model->shouldReceive("file_exists")->with("/invalid/path/file-1")->once()->andReturn(false); - $this->model->shouldReceive("delete_data_id")->with("file-hash-1-1")->once(); - - $ret = \service\files::valid_id($this->filedata, $this->config, $this->model, 505); - $this->t->is($ret, false, "missing file should be removed"); - } - -} - |