Skip to content

Commit

Permalink
Merge pull request #930 from loic425/phpunit-2-phpspec/generator
Browse files Browse the repository at this point in the history
[phpspec-2-phpunit] migration of tests (Generator)
  • Loading branch information
GSadee authored Sep 23, 2024
2 parents 7ddeed2 + cdfd0ea commit 14e5788
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 100 deletions.
37 changes: 0 additions & 37 deletions src/Component/legacy/spec/Generator/RandomnessGeneratorSpec.php

This file was deleted.

63 changes: 0 additions & 63 deletions src/Component/spec/Generator/RandomnessGeneratorSpec.php

This file was deleted.

63 changes: 63 additions & 0 deletions src/Component/tests/Generator/RandomnessGeneratorTest.php
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);
}
}

0 comments on commit 14e5788

Please sign in to comment.