Fix: Move tests one up

This commit is contained in:
Andreas Möller
2016-09-15 08:31:27 +02:00
parent 8d2bab3c17
commit 7ff6fff06d
31 changed files with 2 additions and 2 deletions
+73
View File
@@ -0,0 +1,73 @@
<?php
namespace Ramsey\Uuid\Test\Generator;
use Ramsey\Uuid\Generator\RandomLibAdapter;
use Ramsey\Uuid\Test\TestCase;
use Mockery;
/**
* Class RandomLibAdapterTest
* @package Ramsey\Uuid\Test\Generator
* @covers Ramsey\Uuid\Generator\RandomLibAdapter
*/
class RandomLibAdapterTest extends TestCase
{
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testAdapterWithGeneratorDoesNotCreateGenerator()
{
$factory = Mockery::mock('overload:RandomLib\Factory');
$factory->shouldNotReceive('getMediumStrengthGenerator')
->getMock();
$generator = $this->getMockBuilder('RandomLib\Generator')
->disableOriginalConstructor()
->getMock();
new RandomLibAdapter($generator);
}
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testAdapterWithoutGeneratorGreatesGenerator()
{
$factory = Mockery::mock('overload:RandomLib\Factory');
$factory->shouldReceive('getMediumStrengthGenerator')
->once()
->getMock();
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);
}
}