Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mokhosh committed Nov 3, 2024
1 parent 855a132 commit 9c12f20
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Attributes/Unsafe.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
use Attribute;

#[Attribute(Attribute::TARGET_CLASS)]
final readonly class Unsafe {}
readonly class Unsafe {}
19 changes: 6 additions & 13 deletions tests/Laravel/MuddleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
use Mokhosh\Muddle\Strategies\Link;
use Mokhosh\Muddle\Strategies\Text;

it('works with basic unsafe strategies', function () {
expect(Muddle::text('[email protected]'))
->toBe('[email protected]')
->and(Muddle::link('[email protected]'))
->toBe('<a href="mailto:[email protected]">[email protected]</a>');
});

it('gets strategies from config', function () {
Config::set('muddle.strategy.text', Text\Entities::class);
Config::set('muddle.strategy.link', Link\Entities::class);
Expand All @@ -20,22 +13,22 @@
->not->toBe('[email protected]')
->and((new Text\Entities)->unmuddle($entitizedText))
->toBe('[email protected]')
->and($entitizedLink = Muddle::link('[email protected]'))
->not->toBe('<a href="mailto:[email protected]">[email protected]</a>')
->and($entitizedLink = Muddle::link('[email protected]', 'email'))
->not->toBe('<a href="mailto:[email protected]">email</a>')
->and(html_entity_decode($entitizedLink))
->toBe('<a href="mailto:[email protected]">[email protected]</a>');
->toBe('<a href="mailto:[email protected]">email</a>');
});

it('can change strategies on the fly', function () {
$entitizedText = Muddle::strategy(text: new Text\Entities)->text('[email protected]');
$entitizedLink = Muddle::strategy(link: new Link\Entities)->link('[email protected]');
$entitizedLink = Muddle::strategy(link: new Link\Entities)->link('[email protected]', 'email');

expect($entitizedText)
->not->toBe('[email protected]')
->and((new Text\Entities)->unmuddle($entitizedText))
->toBe('[email protected]')
->and($entitizedLink)
->not->toBe('<a href="mailto:[email protected]">[email protected]</a>')
->not->toBe('<a href="mailto:[email protected]">email</a>')
->and(html_entity_decode($entitizedLink))
->toBe('<a href="mailto:[email protected]">[email protected]</a>');
->toBe('<a href="mailto:[email protected]">email</a>');
});
4 changes: 2 additions & 2 deletions tests/Php/MuddleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

expect($muddle->text('[email protected]'))
->toBe('[email protected]')
->and($muddle->link('[email protected]'))
->toBe('<a href="mailto:[email protected]">[email protected]</a>');
->and($muddle->link('[email protected]', 'email'))
->toBe('<a href="mailto:[email protected]">email</a>');
});

0 comments on commit 9c12f20

Please sign in to comment.