-
-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4.x] Fix assets being deleted when renaming snake_case folder to keb…
…ab-case. (#8826)
- Loading branch information
1 parent
5b996ef
commit 8f5da38
Showing
8 changed files
with
190 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace Tests\Facades; | ||
|
||
use Statamic\Facades\Pattern; | ||
use Tests\TestCase; | ||
|
||
class PatternTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* | ||
* @dataProvider likeProvider | ||
*/ | ||
public function it_escapes_sql_like_syntax($string, $expected) | ||
{ | ||
$this->assertEquals($expected, Pattern::sqlLikeQuote($string)); | ||
} | ||
|
||
public function likeProvider() | ||
{ | ||
return collect([ | ||
'foo' => 'foo', | ||
'%foo' => '\%foo', | ||
'foo%' => 'foo\%', | ||
'%foo%' => '\%foo\%', | ||
'_foo' => '\_foo', | ||
'foo_' => 'foo\_', | ||
'_foo_' => '\_foo\_', | ||
'f_o' => 'f\_o', | ||
])->mapWithKeys(fn ($expected, $string) => [$string => [$string, $expected]])->all(); | ||
} | ||
|
||
/** | ||
* @test | ||
* | ||
* @dataProvider likeRegexProvider | ||
*/ | ||
public function it_converts_sql_like_syntax_to_regex($string, $expected) | ||
{ | ||
$this->assertEquals($expected, Pattern::sqlLikeToRegex($string)); | ||
} | ||
|
||
public function likeRegexProvider() | ||
{ | ||
return collect([ | ||
'foo' => '^foo$', | ||
'foo%' => '^foo.*$', | ||
'%world' => '^.*world$', | ||
'%world%' => '^.*world.*$', | ||
'_oo' => '^.oo$', | ||
'o_' => '^o.$', | ||
'foo_bar' => '^foo.bar$', | ||
'foo__bar' => '^foo..bar$', | ||
'fo__bar' => '^fo..bar$', | ||
'foo\_bar' => '^foo_bar$', | ||
'20\%' => '^20%$', | ||
'20\%%' => '^20%.*$', | ||
'%3.14%' => '^.*3\.14.*$', | ||
'%[4%' => '^.*\[4.*$', | ||
'/' => '^\/$', | ||
'%/' => '^.*\/$', | ||
'/%' => '^\/.*$', | ||
'%/%' => '^.*\/.*$', | ||
])->mapWithKeys(fn ($expected, $string) => [$string => [$string, $expected]])->all(); | ||
} | ||
} |