Skip to content

Commit

Permalink
[phpspec-2-phpunit] First migrated tests (Generator)
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Sep 10, 2024
1 parent 233b7f7 commit ebda6c0
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 63 deletions.
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 ebda6c0

Please sign in to comment.