-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix alt text stripping accents and single quotes (#2514)
* Fix alt text stripping accents and single quotes The altTextFrom method doesn't work well for non english characters and accents, it also uppercases every word which is weird * Add tests and fix replace accents
- Loading branch information
Showing
4 changed files
with
45 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace A17\Twill\Tests\Unit\Helpers; | ||
|
||
use A17\Twill\Tests\Unit\TestCase; | ||
|
||
class MediaLibraryHelpersTest extends TestCase | ||
{ | ||
public function testReplaceAccents() | ||
{ | ||
$this->assertEquals('aeeiou', replaceAccents('àéèïôû')); | ||
} | ||
|
||
public function testSanitizeFilename() | ||
{ | ||
$this->assertEquals('happy-paques-xo-png.jpg', sanitizeFilename('Happy_Pâques - XO.png.jpg')); | ||
} | ||
|
||
} |
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,18 @@ | ||
<?php | ||
|
||
namespace A17\Twill\Tests\Unit\Models; | ||
|
||
use A17\Twill\Models\Media; | ||
use A17\Twill\Tests\Unit\TestCase; | ||
|
||
class MediaTest extends TestCase | ||
{ | ||
public function testAltText() | ||
{ | ||
$m = new Media(); | ||
|
||
$this->assertEquals("Happy Holidays", $m->altTextFrom('Happy_Holidays.jpg')); | ||
$this->assertEquals("Happy Holidays", $m->altTextFrom('[email protected]')); | ||
$this->assertEquals("J'aime la pièce", $m->altTextFrom('J\'aime-la-pièce.jpg')); | ||
} | ||
} |