Skip to content

Commit 89d3d5d

Browse files
committed
test: fix broken test cases
1 parent 8b190dc commit 89d3d5d

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

tests/LfmItemTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class LfmItemTest extends TestCase
1313
private $lfm_path;
1414
private $lfm;
1515

16-
public function setUp()
16+
public function setUp(): void
1717
{
1818
$this->lfm = m::mock(Lfm::class);
1919

@@ -24,7 +24,7 @@ public function setUp()
2424
->andReturn(['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url']);
2525
}
2626

27-
public function tearDown()
27+
public function tearDown(): void
2828
{
2929
m::close();
3030

tests/LfmPathTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class LfmPathTest extends TestCase
1313
{
14-
public function tearDown()
14+
public function tearDown(): void
1515
{
1616
m::close();
1717

tests/LfmStorageRepositoryTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class LfmStorageRepositoryTest extends TestCase
1313
{
1414
private $storage;
1515

16-
public function setUp()
16+
public function setUp(): void
1717
{
1818
parent::setUp();
1919

@@ -24,6 +24,7 @@ public function setUp()
2424
$disk->shouldReceive('functionToCall')->with('foo/bar')->andReturn('baz');
2525
$disk->shouldReceive('directories')->with('foo')->andReturn(['foo/bar']);
2626
$disk->shouldReceive('move')->with('foo/bar', 'foo/bar/baz')->andReturn(true);
27+
$disk->shouldReceive('path')->andReturn('foo/bar');
2728

2829
$helper = m::mock(Lfm::class);
2930
$helper->shouldReceive('config')->with('disk')->andReturn('local');
@@ -33,7 +34,7 @@ public function setUp()
3334
$this->storage = new LfmStorageRepository('foo/bar', $helper);
3435
}
3536

36-
public function tearDown()
37+
public function tearDown(): void
3738
{
3839
m::close();
3940
}

tests/LfmTest.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class LfmTest extends TestCase
1414
{
15-
public function tearDown()
15+
public function tearDown(): void
1616
{
1717
m::close();
1818

@@ -50,8 +50,13 @@ public function testAllowFolderType()
5050
$config->shouldReceive('get')->with('lfm.allow_private_folder')->once()->andReturn(false);
5151
$config->shouldReceive('get')->with('lfm.allow_private_folder')->once()->andReturn(true);
5252
$config->shouldReceive('get')->with('lfm.allow_shared_folder')->once()->andReturn(false);
53+
$config->shouldReceive('get')->with('lfm.folder_categories')->andReturn([]);
54+
$config->shouldReceive('has')->andReturn(false);
5355

54-
$lfm = new Lfm($config);
56+
$request = m::mock(Request::class);
57+
$request->shouldReceive('input')->with('type')->andReturn('');
58+
59+
$lfm = new Lfm($config, $request);
5560

5661
$this->assertTrue($lfm->allowFolderType('user'));
5762
$this->assertTrue($lfm->allowFolderType('shared'));
@@ -155,8 +160,13 @@ public function testAllowMultiUser()
155160
{
156161
$config = m::mock(Config::class);
157162
$config->shouldReceive('get')->with('lfm.allow_private_folder')->once()->andReturn(true);
163+
$config->shouldReceive('get')->with('lfm.folder_categories')->andReturn([]);
164+
$config->shouldReceive('has')->andReturn(false);
158165

159-
$lfm = new Lfm($config);
166+
$request = m::mock(Request::class);
167+
$request->shouldReceive('input')->with('type')->andReturn('');
168+
169+
$lfm = new Lfm($config, $request);
160170

161171
$this->assertTrue($lfm->allowMultiUser());
162172
}
@@ -167,8 +177,13 @@ public function testAllowShareFolder()
167177
$config->shouldReceive('get')->with('lfm.allow_private_folder')->once()->andReturn(false);
168178
$config->shouldReceive('get')->with('lfm.allow_private_folder')->once()->andReturn(true);
169179
$config->shouldReceive('get')->with('lfm.allow_shared_folder')->once()->andReturn(false);
180+
$config->shouldReceive('get')->with('lfm.folder_categories')->andReturn([]);
181+
$config->shouldReceive('has')->andReturn(false);
170182

171-
$lfm = new Lfm($config);
183+
$request = m::mock(Request::class);
184+
$request->shouldReceive('input')->with('type')->andReturn('');
185+
186+
$lfm = new Lfm($config, $request);
172187

173188
$this->assertTrue($lfm->allowShareFolder());
174189
$this->assertFalse($lfm->allowShareFolder());

tests/LfmUploadValidatorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,17 @@ public function testFailsNameIsNotDuplicate()
9292
$validator->nameIsNotDuplicate('new_file_name', $lfm_path);
9393
}
9494

95-
public function testPassesIsNotExcutable()
95+
public function testPassesMimetypeIsNotExcutable()
9696
{
9797
$uploaded_file = m::mock(UploadedFile::class);
9898
$uploaded_file->shouldReceive('getMimeType')->andReturn('image/jpeg');
9999

100100
$validator = new LfmUploadValidator($uploaded_file);
101101

102-
$this->assertEquals($validator->isNotExcutable(), $validator);
102+
$this->assertEquals($validator->mimetypeIsNotExcutable(['text/x-php']), $validator);
103103
}
104104

105-
public function testFailsIsNotExcutable()
105+
public function testFailsMimetypeIsNotExcutable()
106106
{
107107
$uploaded_file = m::mock(UploadedFile::class);
108108
$uploaded_file->shouldReceive('getMimeType')->andReturn('text/x-php');
@@ -111,7 +111,7 @@ public function testFailsIsNotExcutable()
111111

112112
$this->expectException(ExcutableFileException::class);
113113

114-
$validator->isNotExcutable();
114+
$validator->mimetypeIsNotExcutable(['text/x-php']);
115115
}
116116

117117
public function testPassesMimeTypeIsValid()

0 commit comments

Comments
 (0)