|
30 | 30 | use OCP\IUserManager; |
31 | 31 | use OCP\Server; |
32 | 32 | use OCP\Share\IShare; |
| 33 | +use PHPUnit\Framework\Attributes\DataProvider; |
33 | 34 |
|
34 | 35 | /** |
35 | 36 | * Class Test_Encryption |
@@ -697,6 +698,32 @@ public static function loginHelper($user, $create = false) { |
697 | 698 | \OC_Util::setupFS($user); |
698 | 699 | Server::get(IRootFolder::class)->getUserFolder($user); |
699 | 700 | } |
| 701 | + |
| 702 | + public static function trashFilenameProvider(): array { |
| 703 | + return [ |
| 704 | + ['foo.txt', 'foo.txt.d1234'], |
| 705 | + [ |
| 706 | + '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_' |
| 707 | + . 'timestamp_because_then_the_combined_length_would_overflow_the_column_limit_of_the_filecache_and_truncate_in_db.txt', |
| 708 | + '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_' |
| 709 | + . 'timestamp_because_then_the_combined_length_would_overflow_the_column_limit_of_the_filecache_and_truncate_in_db.txt.d1234' |
| 710 | + ], |
| 711 | + [ |
| 712 | + '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_' |
| 713 | + . 'timestamp_because_then_the_combined_length_would_overflow_the_column_limit_of_the_filecache_and_truncate_in_db.txt', |
| 714 | + '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_' |
| 715 | + . 'timestamp_because_then_the_combined_length_would_overflow_the_column_limit_of_the_filecache_and_truncate_in_db.txt.d1234' |
| 716 | + ], |
| 717 | + ]; |
| 718 | + } |
| 719 | + |
| 720 | + #[DataProvider(methodName: 'trashFilenameProvider')] |
| 721 | + public function testGetTrashFilename(string $filename, string $expected): void { |
| 722 | + $result = Trashbin::getTrashFilename($filename, 1234); |
| 723 | + $this->assertTrue(mb_check_encoding($result, 'UTF-8')); |
| 724 | + $this->assertEquals($expected, $result); |
| 725 | + $this->assertTrue(strlen($result) <= 250); |
| 726 | + } |
700 | 727 | } |
701 | 728 |
|
702 | 729 |
|
|
0 commit comments