-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1cd6d63
commit 25e5c4d
Showing
1 changed file
with
43 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,46 @@ | ||
<?php | ||
|
||
test('example', function () { | ||
expect(true)->toBeTrue(); | ||
use Leaf\Anchor; | ||
|
||
test('set config', function () { | ||
Anchor::config(['SECRET' => 'item']); | ||
$config = Anchor::config(); | ||
|
||
expect($config['SECRET'])->toBe('item'); | ||
}); | ||
|
||
test('sanitize', function () { | ||
$html = '<b>Hello World</b>'; | ||
|
||
expect(Anchor::sanitize($html))->toBe(htmlspecialchars($html)); | ||
}); | ||
|
||
test('sanitize array', function () { | ||
$html = ['<b>Hello World</b>', '<b>Hello World</b>']; | ||
|
||
expect(Anchor::sanitize($html))->toBe([ | ||
htmlspecialchars('<b>Hello World</b>'), | ||
htmlspecialchars('<b>Hello World</b>'), | ||
]); | ||
}); | ||
|
||
test('sanitize assoc array', function () { | ||
$html = ['key' => '<b>Hello World</b>']; | ||
|
||
expect(Anchor::sanitize($html))->toBe(['key' => htmlspecialchars('<b>Hello World</b>')]); | ||
}); | ||
|
||
test('generate token', function () { | ||
expect(Anchor::generateToken())->toBeString(); | ||
}); | ||
|
||
test('secret in token', function () { | ||
$anchorSecret = 'SOMETHING'; | ||
Anchor::config(['SECRET' => $anchorSecret]); | ||
|
||
expect(strpos(hex2bin(Anchor::generateToken()), $anchorSecret))->toBe(0); | ||
}); | ||
|
||
test('errors', function () { | ||
expect(Anchor::errors())->toBeArray(); | ||
}); |