Skip to content

Commit

Permalink
add unit tests for PR #3031
Browse files Browse the repository at this point in the history
  • Loading branch information
patinthehat committed Nov 22, 2022
1 parent 09cfe0a commit 1869dda
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/MediaCollections/FileAdderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Spatie\MediaLibrary\Tests\MediaCollections;

use Spatie\MediaLibrary\MediaCollections\FileAdder;

it('sanitizes filenames correctly', function () {
/** @var FileAdder $adder */
$adder = app(FileAdder::class);

expect($adder->defaultSanitizer('valid-filename.jpg'))
->toEqual('valid-filename.jpg');

expect($adder->defaultSanitizer('test one.pdf'))
->toEqual('test-one.pdf');

expect($adder->defaultSanitizer('test#one.pdf'))
->toEqual('test-one.pdf');

expect($adder->defaultSanitizer('some/test/file.pdf'))
->toEqual('some-test-file.pdf');

expect($adder->defaultSanitizer('Scan-‎9‎.‎14‎.‎2022-‎7‎.‎23‎.‎28.pdf'))
->toEqual('Scan-9.14.2022-7.23.28.pdf');
});

0 comments on commit 1869dda

Please sign in to comment.