-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #930 from loic425/phpunit-2-phpspec/generator
[phpspec-2-phpunit] migration of tests (Generator)
- Loading branch information
Showing
3 changed files
with
63 additions
and
100 deletions.
There are no files selected for viewing
37 changes: 0 additions & 37 deletions
37
src/Component/legacy/spec/Generator/RandomnessGeneratorSpec.php
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,63 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Resource\Tests\Generator; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Sylius\Resource\Generator\RandomnessGenerator; | ||
use Sylius\Resource\Generator\RandomnessGeneratorInterface; | ||
|
||
final class RandomnessGeneratorTest extends TestCase | ||
{ | ||
private RandomnessGeneratorInterface $generator; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->generator = new RandomnessGenerator(); | ||
} | ||
|
||
public function testItImplementsRandomnessGeneratorInterface(): void | ||
{ | ||
$this->assertInstanceOf(RandomnessGeneratorInterface::class, $this->generator); | ||
} | ||
|
||
public function testItGeneratesRandomUriSafeStringOfLength(): void | ||
{ | ||
$length = 9; | ||
$result = $this->generator->generateUriSafeString($length); | ||
|
||
$this->assertIsString($result); | ||
$this->assertSame($length, strlen($result)); | ||
} | ||
|
||
public function testItGeneratesRandomNumericStringOfLength(): void | ||
{ | ||
$length = 12; | ||
$result = $this->generator->generateNumeric($length); | ||
|
||
$this->assertIsString($result); | ||
$this->assertIsNumeric($result); | ||
$this->assertSame($length, strlen($result)); | ||
} | ||
|
||
public function testItGeneratesRandomIntInRange(): void | ||
{ | ||
$min = 12; | ||
$max = 2000000; | ||
$result = $this->generator->generateInt($min, $max); | ||
|
||
$this->assertIsInt($result); | ||
$this->assertGreaterThanOrEqual($min, $result); | ||
$this->assertLessThanOrEqual($max, $result); | ||
} | ||
} |