mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-19 16:47:23 +03:00
Add coverage of generate method
This commit is contained in:
@@ -39,4 +39,32 @@ class RandomLibAdapterTest extends TestCase
|
||||
|
||||
new RandomLibAdapter();
|
||||
}
|
||||
|
||||
public function testGenerateUsesGenerator()
|
||||
{
|
||||
$length = 10;
|
||||
$generator = $this->getMockBuilder('RandomLib\Generator')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$generator->expects($this->once())
|
||||
->method('generate')
|
||||
->with($length);
|
||||
|
||||
$adapter = new RandomLibAdapter($generator);
|
||||
$adapter->generate($length);
|
||||
}
|
||||
|
||||
public function testGenerateReturnsString()
|
||||
{
|
||||
$generator = $this->getMockBuilder('RandomLib\Generator')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$generator->expects($this->once())
|
||||
->method('generate')
|
||||
->willReturn('random-string');
|
||||
|
||||
$adapter = new RandomLibAdapter($generator);
|
||||
$result = $adapter->generate(1);
|
||||
$this->assertEquals('random-string', $result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user