Skip to content

Commit 39da4f5

Browse files
come-ncartonge
authored andcommitted
fix(tests): Fix most obvious errors in ObjectStore tests
Some are still failing Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 56cfd19 commit 39da4f5

File tree

3 files changed

+60
-56
lines changed

3 files changed

+60
-56
lines changed

tests/lib/Files/ObjectStore/ObjectStoreStoragesDifferentBucketTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Test\Files\ObjectStore;
99

10+
use OC\Files\ObjectStore\StorageObjectStore;
11+
use OC\Files\Storage\Temporary;
1012
use Test\Files\Storage\StoragesTest;
1113

1214
/**

tests/lib/Files/ObjectStore/ObjectStoreStoragesSameBucketTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Test\Files\ObjectStore;
99

10+
use OC\Files\ObjectStore\StorageObjectStore;
11+
use OC\Files\Storage\Temporary;
1012
use Test\Files\Storage\StoragesTest;
1113

1214
/**

tests/lib/Files/Storage/StoragesTest.php

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -33,76 +33,76 @@ protected function tearDown(): void {
3333
public function testMoveFileFromStorage() {
3434
$source = 'source.txt';
3535
$target = 'target.txt';
36-
$storage2->file_put_contents($source, 'foo');
36+
$this->storage2->file_put_contents($source, 'foo');
3737

38-
$storage1->moveFromStorage($storage2, $source, $target);
38+
$this->storage1->moveFromStorage($this->storage2, $source, $target);
3939

40-
$this->assertTrue($storage1->file_exists($target), $target.' was not created');
41-
$this->assertFalse($storage2->file_exists($source), $source.' still exists');
42-
$this->assertEquals('foo', $storage1->file_get_contents($target));
40+
$this->assertTrue($this->storage1->file_exists($target), $target.' was not created');
41+
$this->assertFalse($this->storage2->file_exists($source), $source.' still exists');
42+
$this->assertEquals('foo', $this->storage1->file_get_contents($target));
4343
}
4444

4545
public function testMoveDirectoryFromStorage() {
46-
$storage2->mkdir('source');
47-
$storage2->file_put_contents('source/test1.txt', 'foo');
48-
$storage2->file_put_contents('source/test2.txt', 'qwerty');
49-
$storage2->mkdir('source/subfolder');
50-
$storage2->file_put_contents('source/subfolder/test.txt', 'bar');
51-
52-
$storage1->moveFromStorage($storage2, 'source', 'target');
53-
54-
$this->assertTrue($storage1->file_exists('target'));
55-
$this->assertTrue($storage1->file_exists('target/test1.txt'));
56-
$this->assertTrue($storage1->file_exists('target/test2.txt'));
57-
$this->assertTrue($storage1->file_exists('target/subfolder'));
58-
$this->assertTrue($storage1->file_exists('target/subfolder/test.txt'));
59-
60-
$this->assertFalse($storage2->file_exists('source'));
61-
$this->assertFalse($storage2->file_exists('source/test1.txt'));
62-
$this->assertFalse($storage2->file_exists('source/test2.txt'));
63-
$this->assertFalse($storage2->file_exists('source/subfolder'));
64-
$this->assertFalse($storage2->file_exists('source/subfolder/test.txt'));
65-
66-
$this->assertEquals('foo', $storage1->file_get_contents('target/test1.txt'));
67-
$this->assertEquals('qwerty', $storage1->file_get_contents('target/test2.txt'));
68-
$this->assertEquals('bar', $storage1->file_get_contents('target/subfolder/test.txt'));
46+
$this->storage2->mkdir('source');
47+
$this->storage2->file_put_contents('source/test1.txt', 'foo');
48+
$this->storage2->file_put_contents('source/test2.txt', 'qwerty');
49+
$this->storage2->mkdir('source/subfolder');
50+
$this->storage2->file_put_contents('source/subfolder/test.txt', 'bar');
51+
52+
$this->storage1->moveFromStorage($this->storage2, 'source', 'target');
53+
54+
$this->assertTrue($this->storage1->file_exists('target'));
55+
$this->assertTrue($this->storage1->file_exists('target/test1.txt'));
56+
$this->assertTrue($this->storage1->file_exists('target/test2.txt'));
57+
$this->assertTrue($this->storage1->file_exists('target/subfolder'));
58+
$this->assertTrue($this->storage1->file_exists('target/subfolder/test.txt'));
59+
60+
$this->assertFalse($this->storage2->file_exists('source'));
61+
$this->assertFalse($this->storage2->file_exists('source/test1.txt'));
62+
$this->assertFalse($this->storage2->file_exists('source/test2.txt'));
63+
$this->assertFalse($this->storage2->file_exists('source/subfolder'));
64+
$this->assertFalse($this->storage2->file_exists('source/subfolder/test.txt'));
65+
66+
$this->assertEquals('foo', $this->storage1->file_get_contents('target/test1.txt'));
67+
$this->assertEquals('qwerty', $this->storage1->file_get_contents('target/test2.txt'));
68+
$this->assertEquals('bar', $this->storage1->file_get_contents('target/subfolder/test.txt'));
6969
}
7070

7171
public function testCopyFileFromStorage() {
7272
$source = 'source.txt';
7373
$target = 'target.txt';
74-
$storage2->file_put_contents($source, 'foo');
74+
$this->storage2->file_put_contents($source, 'foo');
7575

76-
$storage1->copyFromStorage($storage2, $source, $target);
76+
$this->storage1->copyFromStorage($this->storage2, $source, $target);
7777

78-
$this->assertTrue($storage1->file_exists($target), $target.' was not created');
79-
$this->assertTrue($storage2->file_exists($source), $source.' was deleted');
80-
$this->assertEquals('foo', $storage1->file_get_contents($target));
78+
$this->assertTrue($this->storage1->file_exists($target), $target.' was not created');
79+
$this->assertTrue($this->storage2->file_exists($source), $source.' was deleted');
80+
$this->assertEquals('foo', $this->storage1->file_get_contents($target));
8181
}
8282

8383
public function testCopyDirectoryFromStorage() {
84-
$storage2->mkdir('source');
85-
$storage2->file_put_contents('source/test1.txt', 'foo');
86-
$storage2->file_put_contents('source/test2.txt', 'qwerty');
87-
$storage2->mkdir('source/subfolder');
88-
$storage2->file_put_contents('source/subfolder/test.txt', 'bar');
89-
90-
$storage1->copyFromStorage($storage2, 'source', 'target');
91-
92-
$this->assertTrue($storage1->file_exists('target'));
93-
$this->assertTrue($storage1->file_exists('target/test1.txt'));
94-
$this->assertTrue($storage1->file_exists('target/test2.txt'));
95-
$this->assertTrue($storage1->file_exists('target/subfolder'));
96-
$this->assertTrue($storage1->file_exists('target/subfolder/test.txt'));
97-
98-
$this->assertTrue($storage2->file_exists('source'));
99-
$this->assertTrue($storage2->file_exists('source/test1.txt'));
100-
$this->assertTrue($storage2->file_exists('source/test2.txt'));
101-
$this->assertTrue($storage2->file_exists('source/subfolder'));
102-
$this->assertTrue($storage2->file_exists('source/subfolder/test.txt'));
103-
104-
$this->assertEquals('foo', $storage1->file_get_contents('target/test1.txt'));
105-
$this->assertEquals('qwerty', $storage1->file_get_contents('target/test2.txt'));
106-
$this->assertEquals('bar', $storage1->file_get_contents('target/subfolder/test.txt'));
84+
$this->storage2->mkdir('source');
85+
$this->storage2->file_put_contents('source/test1.txt', 'foo');
86+
$this->storage2->file_put_contents('source/test2.txt', 'qwerty');
87+
$this->storage2->mkdir('source/subfolder');
88+
$this->storage2->file_put_contents('source/subfolder/test.txt', 'bar');
89+
90+
$this->storage1->copyFromStorage($this->storage2, 'source', 'target');
91+
92+
$this->assertTrue($this->storage1->file_exists('target'));
93+
$this->assertTrue($this->storage1->file_exists('target/test1.txt'));
94+
$this->assertTrue($this->storage1->file_exists('target/test2.txt'));
95+
$this->assertTrue($this->storage1->file_exists('target/subfolder'));
96+
$this->assertTrue($this->storage1->file_exists('target/subfolder/test.txt'));
97+
98+
$this->assertTrue($this->storage2->file_exists('source'));
99+
$this->assertTrue($this->storage2->file_exists('source/test1.txt'));
100+
$this->assertTrue($this->storage2->file_exists('source/test2.txt'));
101+
$this->assertTrue($this->storage2->file_exists('source/subfolder'));
102+
$this->assertTrue($this->storage2->file_exists('source/subfolder/test.txt'));
103+
104+
$this->assertEquals('foo', $this->storage1->file_get_contents('target/test1.txt'));
105+
$this->assertEquals('qwerty', $this->storage1->file_get_contents('target/test2.txt'));
106+
$this->assertEquals('bar', $this->storage1->file_get_contents('target/subfolder/test.txt'));
107107
}
108108
}

0 commit comments

Comments
 (0)