|
31 | 31 | use OCP\IUserManager; |
32 | 32 | use OCP\Server; |
33 | 33 | use OCP\Share\IShare; |
| 34 | +use PHPUnit\Framework\Attributes\DataProvider; |
34 | 35 |
|
35 | 36 | /** |
36 | 37 | * Class Test_Encryption |
@@ -707,6 +708,32 @@ public static function loginHelper($user, $create = false) { |
707 | 708 | \OC_Util::setupFS($user); |
708 | 709 | Server::get(IRootFolder::class)->getUserFolder($user); |
709 | 710 | } |
| 711 | + |
| 712 | + public static function trashFilenameProvider(): array { |
| 713 | + return [ |
| 714 | + ['foo.txt', 'foo.txt.d1234'], |
| 715 | + [ |
| 716 | + 'a_very_long_filename_with_a_lot_a_characters_such_that_it_reaches_the_file_length_limit_and_would_cause_issues_if_we_just_appended_the_' |
| 717 | + . 'timestamp_because_then_the_combined_length_would_overflow_the_column_limit_of_the_filecache_and_truncate_in_db.txt', |
| 718 | + 'a_very_long_filename_with_a_lot_a_characters_such_that_it_reaches_the_file_length_limit_and_would_cause_issues_if_we_just_ded_the_' |
| 719 | + . 'timestamp_because_then_the_combined_length_would_overflow_the_column_limit_of_the_filecache_and_truncate_in_db.txt.d1234' |
| 720 | + ], |
| 721 | + [ |
| 722 | + 'a_very_long_filename_with_a_lot_a_characters_such_that_it_reaches_the_file_length_limit_and_would_cause_issues_if_we_just_äøšá_the_' |
| 723 | + . 'timestamp_because_then_the_combined_length_would_overflow_the_column_limit_of_the_filecache_and_truncate_in_db.txt', |
| 724 | + 'a_very_long_filename_with_a_lot_a_characters_such_that_it_reaches_the_file_length_limit_and_would_cause_issues_if_we_ju_á_the_' |
| 725 | + . 'timestamp_because_then_the_combined_length_would_overflow_the_column_limit_of_the_filecache_and_truncate_in_db.txt.d1234' |
| 726 | + ], |
| 727 | + ]; |
| 728 | + } |
| 729 | + |
| 730 | + #[DataProvider(methodName: 'trashFilenameProvider')] |
| 731 | + public function testGetTrashFilename(string $filename, string $expected): void { |
| 732 | + $result = Trashbin::getTrashFilename($filename, 1234); |
| 733 | + $this->assertTrue(mb_check_encoding($result, 'UTF-8')); |
| 734 | + $this->assertEquals($expected, $result); |
| 735 | + $this->assertTrue(strlen($result) <= 250); |
| 736 | + } |
710 | 737 | } |
711 | 738 |
|
712 | 739 |
|
|
0 commit comments