Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test seeding and repeat #134

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ name: Tests

jobs:
phpunit:
name: PHPUnit on ${{ matrix.operating-system }} with PHP ${{ matrix.php-version }}
name: PHPUnit on ${{ matrix.operating-system }} with PHP ${{ matrix.php-version }} ${{ matrix.phpunit-flags }}

strategy:
matrix:
phpunit-flags: ['-v']
operating-system:
- 'ubuntu-latest'
php-version:
Expand All @@ -26,6 +27,10 @@ jobs:
include:
- operating-system: 'windows-latest'
php-version: '7.1'
phpunit-flags: '-v'
- php-version: '8.0'
operating-system: 'ubuntu-latest'
phpunit-flags: '--repeat 100 --exclude-group external,seed'

runs-on: ${{ matrix.operating-system }}

Expand Down Expand Up @@ -61,4 +66,4 @@ jobs:

- name: Run tests with PHPUnit
run: |
./vendor/bin/simple-phpunit
./vendor/bin/simple-phpunit ${{ matrix.phpunit-flags }}
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
cacheResultFile=".build/.phpunit.result.cache"
colors="true"
columns="max"
verbose="true"
IonBazan marked this conversation as resolved.
Show resolved Hide resolved
>
<testsuites>
<testsuite name="Faker Test Suite">
Expand Down
10 changes: 8 additions & 2 deletions test/Faker/Provider/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ public function testShuffleArrayReturnsAnArrayWithSameElements()
self::assertContains(10, $shuffleArray);
}

/**
* @group seed
*/
public function testShuffleArrayReturnsADifferentArrayThanTheOriginal()
{
$arr = [1, 2, 3, 4, 5];
Expand Down Expand Up @@ -229,6 +232,9 @@ public function testShuffleStringReturnsAnStringWithSameElements()
self::assertStringContainsString('i', $shuffleString);
}

/**
* @group seed
*/
public function testShuffleStringReturnsADifferentStringThanTheOriginal()
{
$string = 'abcdef';
Expand Down Expand Up @@ -424,8 +430,8 @@ public function testOptionalPercentageAndWeight()
}

self::assertEquals(
round(array_sum($valuesOld) / 10000, 2),
round(array_sum($valuesNew) / 10000, 2)
round(array_sum($valuesOld) / 10000, 1),
round(array_sum($valuesNew) / 10000, 1)
);
}

Expand Down
1 change: 1 addition & 0 deletions test/Faker/Provider/BiasedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Faker\Test\TestCase;

/**
* @group seed
* @group legacy
*/
final class BiasedTest extends TestCase
Expand Down
4 changes: 2 additions & 2 deletions test/Faker/Provider/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ public function testDateTimeBetween($start, $end)
{
$date = DateTimeProvider::dateTimeBetween($start, $end);
self::assertInstanceOf('\DateTime', $date);
self::assertGreaterThanOrEqual(new \DateTime($start), $date);
self::assertLessThanOrEqual(new \DateTime($end), $date);
self::assertGreaterThanOrEqual((new \DateTime($start))->getTimestamp(), $date->getTimestamp());
self::assertLessThanOrEqual((new \DateTime($end))->getTimestamp(), $date->getTimestamp());
self::assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
}

Expand Down
3 changes: 3 additions & 0 deletions test/Faker/Provider/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public function testImageUrlAddsARandomGetParameterByDefault()
self::assertMatchesRegularExpression('#\w*#', $splitUrl[1]);
}

/**
* @group external
*/
public function testDownloadWithDefaults()
{
$curlPing = curl_init(Image::BASE_URL);
Expand Down
1 change: 1 addition & 0 deletions test/Faker/Provider/ja_JP/InternetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Faker\Test\TestCase;

/**
* @group seed
* @group legacy
*/
final class InternetTest extends TestCase
Expand Down
1 change: 1 addition & 0 deletions test/Faker/Provider/ja_JP/PersonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Faker\Test\TestCase;

/**
* @group seed
* @group legacy
*/
final class PersonTest extends TestCase
Expand Down
4 changes: 2 additions & 2 deletions test/Faker/Provider/mn_MN/PersonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ final class PersonTest extends TestCase
{
public function testName()
{
self::assertMatchesRegularExpression('/^[А-Я]{1}\.[\w\W]+$/u', $this->faker->name);
self::assertMatchesRegularExpression('/^[\p{Cyrillic}]\.[\w\W]+$/u', $this->faker->name);
IonBazan marked this conversation as resolved.
Show resolved Hide resolved
}

public function testIdNumber()
{
self::assertMatchesRegularExpression('/^[А-Я]{2}\d{8}$/u', $this->faker->idNumber);
self::assertMatchesRegularExpression('/^[\p{Cyrillic}]{2}\d{8}$/u', $this->faker->idNumber);
IonBazan marked this conversation as resolved.
Show resolved Hide resolved
}

protected function getProviders(): iterable
Expand Down
1 change: 1 addition & 0 deletions test/Faker/Provider/uk_UA/PersonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Faker\Test\TestCase;

/**
* @group seed
* @group legacy
*/
final class PersonTest extends TestCase
Expand Down
5 changes: 4 additions & 1 deletion test/Faker/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ abstract class TestCase extends BaseTestCase
protected function setUp(): void
{
$this->faker = new Generator();
$this->faker->seed(1);

if (in_array('seed', $this->getGroups(), true)) {
$this->faker->seed(1);
}

foreach ($this->getProviders() as $provider) {
$this->faker->addProvider($provider);
Expand Down