|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* ownCloud |
|
4
|
|
|
* |
|
5
|
|
|
* @author Robin Appelman |
|
6
|
|
|
* @copyright 2012 Robin Appelman [email protected] |
|
7
|
|
|
* |
|
8
|
|
|
* This library is free software; you can redistribute it and/or |
|
9
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
10
|
|
|
* License as published by the Free Software Foundation; either |
|
11
|
|
|
* version 3 of the License, or any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* This library is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Affero General Public |
|
19
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace Test\Files\Storage; |
|
24
|
|
|
|
|
25
|
|
|
class Local extends Storage { |
|
26
|
|
|
/** |
|
27
|
|
|
* @var string tmpDir |
|
28
|
|
|
*/ |
|
29
|
|
|
private $tmpDir; |
|
30
|
|
|
|
|
31
|
|
|
protected function setUp() { |
|
32
|
|
|
parent::setUp(); |
|
33
|
|
|
|
|
34
|
|
|
$this->tmpDir = \OC_Helper::tmpFolder(); |
|
35
|
|
|
$this->instance = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
protected function tearDown() { |
|
39
|
|
|
\OC_Helper::rmdirr($this->tmpDir); |
|
40
|
|
|
parent::tearDown(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testStableEtag() { |
|
44
|
|
|
if (\OC_Util::runningOnWindows()) { |
|
45
|
|
|
$this->markTestSkipped('[Windows] On Windows platform we have no stable etag generation - yet'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
$this->instance->file_put_contents('test.txt', 'foobar'); |
|
49
|
|
|
$etag1 = $this->instance->getETag('test.txt'); |
|
50
|
|
|
$etag2 = $this->instance->getETag('test.txt'); |
|
51
|
|
|
$this->assertEquals($etag1, $etag2); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function testEtagChange() { |
|
55
|
|
|
if (\OC_Util::runningOnWindows()) { |
|
56
|
|
|
$this->markTestSkipped('[Windows] On Windows platform we have no stable etag generation - yet'); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$this->instance->file_put_contents('test.txt', 'foo'); |
|
60
|
|
|
$this->instance->touch('test.txt', time() - 2); |
|
61
|
|
|
$etag1 = $this->instance->getETag('test.txt'); |
|
62
|
|
|
$this->instance->file_put_contents('test.txt', 'bar'); |
|
63
|
|
|
$etag2 = $this->instance->getETag('test.txt'); |
|
64
|
|
|
$this->assertNotEquals($etag1, $etag2); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @expectedException \InvalidArgumentException |
|
69
|
|
|
*/ |
|
70
|
|
|
public function testInvalidArgumentsEmptyArray() { |
|
71
|
|
|
new \OC\Files\Storage\Local([]); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @expectedException \InvalidArgumentException |
|
76
|
|
|
*/ |
|
77
|
|
|
public function testInvalidArgumentsNoArray() { |
|
78
|
|
|
new \OC\Files\Storage\Local(null); |
|
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: