-
Notifications
You must be signed in to change notification settings - Fork 14
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
Mathias STRASSER
committed
Sep 22, 2017
1 parent
644ba8b
commit 49d8fd9
Showing
1 changed file
with
37 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace spec\Roukmoute\HashidsBundle; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Roukmoute\HashidsBundle\Hashids; | ||
|
||
class HashidsSpec extends ObjectBehavior | ||
{ | ||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(Hashids::class); | ||
} | ||
|
||
public function it_sets_min_hashs_length() | ||
{ | ||
expect($this->encode(1)->getWrappedObject())->toBe('jR'); | ||
$this->setMinHashLength(4); | ||
expect($this->encode(1)->getWrappedObject())->toBe('ejRe'); | ||
$this->setMinHashLength(15); | ||
expect($this->encode(1)->getWrappedObject())->toBe('4q2VolejRejNmGQ'); | ||
} | ||
|
||
public function it_encodes_with_custom_hash_length() | ||
{ | ||
expect($this->encode(1)->getWrappedObject())->toBe('jR'); | ||
expect($this->encodeWithCustomHashLength(4, 1)->getWrappedObject())->toBe('ejRe'); | ||
expect($this->encode(1)->getWrappedObject())->toBe('jR'); | ||
} | ||
|
||
public function it_decodes_with_custom_hash_length() | ||
{ | ||
expect($this->decode('jR')->getWrappedObject())->toBe([1]); | ||
expect($this->decodeWithCustomHashLength(4, 'ejRe')->getWrappedObject())->toBe([1]); | ||
expect($this->decode('jR')->getWrappedObject())->toBe([1]); | ||
} | ||
} |