Skip to content

Commit 5b9a90e

Browse files
committed
Fix tests
1 parent 826e282 commit 5b9a90e

5 files changed

Lines changed: 7 additions & 11 deletions

File tree

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"php": "^7.4 || ^8.0",
2424
"codeigniter4/authentication-implementation": "^1.0",
2525
"enyo/dropzone": "^6.0",
26-
"tatter/alerts": "^2.0",
2726
"tatter/exports": "^3.0",
2827
"tatter/frontend": "^1.0",
2928
"tatter/permits": "^3.0",

src/Models/FileModel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public function createFromFile(CIFile $file, array $data = []): File
9393
// Gather file info
9494
$row = [
9595
'filename' => $file->getFilename(),
96-
'localname' => $file->getRandomName(),
9796
'clientname' => $file->getFilename(),
9897
'type' => Mimes::guessTypeFromExtension($file->getExtension()) ?? $file->getMimeType(),
9998
'size' => $file->getSize(),
@@ -109,9 +108,10 @@ public function createFromFile(CIFile $file, array $data = []): File
109108
// Determine if we need to move the file
110109
if (strpos($filePath, $storage) === false) {
111110
// Move the file
112-
$file = $file->move($storage, $row['localname']);
111+
$file = $file->move($storage, $file->getRandomName());
113112
chmod((string) $file, 0664);
114113
}
114+
$row['localname'] = $file->getFilename();
115115

116116
// Record it in the database
117117
$fileId = $this->insert($row);
@@ -133,7 +133,7 @@ public function createFromFile(CIFile $file, array $data = []): File
133133

134134
try {
135135
$result = service('thumbnails')->create($entity->getPath());
136-
rename($result, $output);
136+
copy($result, $output);
137137

138138
// If it succeeds then update the database
139139
$entity->thumbnail = $thumbnail;

tests/_support/TestCase.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ abstract class TestCase extends CIUnitTestCase
3030
*/
3131
protected string $testPath;
3232

33-
/**
34-
* @var FileModel
35-
*/
36-
protected $model;
33+
protected FileModel $model;
3734

3835
public static function setUpBeforeClass(): void
3936
{

tests/feature/DisplayTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function testNoFiles()
1616
$result = $this->get('files');
1717

1818
$result->assertStatus(200);
19-
$result->assertSee('You have no files');
19+
$result->assertSee('No files to display');
2020
}
2121

2222
public function testDefaultDisplaysCards()

tests/feature/PermissionsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testDenyListRedirects()
6565
$result = $this->get('files');
6666

6767
$result->assertStatus(302);
68-
$result->assertSessionHas('error', lang('Permits.notPermitted'));
68+
$result->assertSessionHas('error', lang('Files.notPermitted'));
6969
}
7070

7171
public function testDenyAjaxReturnsError()
@@ -76,7 +76,7 @@ public function testDenyAjaxReturnsError()
7676
$result = $this->withHeaders(['X-Requested-With' => 'XMLHttpRequest'])->get('files');
7777

7878
$result->assertStatus(403);
79-
$result->assertJSONFragment(['error' => lang('Permits.notPermitted')]);
79+
$result->assertJSONFragment(['error' => lang('Files.notPermitted')]);
8080
}
8181

8282
public function testUploadMissingFile()

0 commit comments

Comments
 (0)