Skip to content

Commit

Permalink
tec: Add Faker to be used in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marienfressinaud committed May 12, 2020
1 parent 6138dc4 commit c992eca
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"require-dev": {
"phpunit/phpunit": "^9.1",
"squizlabs/php_codesniffer": "^3.5"
"squizlabs/php_codesniffer": "^3.5",
"fzaninotto/faker": "^1.9"
}
}
52 changes: 51 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ services:
volumes:
- ..:/var/www/html:z
- composer:/tmp
environment:
SEED: $SEED
user: $USER
links:
- database
Expand Down
2 changes: 2 additions & 0 deletions env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ SMTP_AUTH_TYPE=LOGIN
SMTP_USERNAME=noreply
SMTP_PASSWORD=secret
SMTP_SECURE=tls

SEED=
12 changes: 12 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@
\Minz\Configuration::load('test', $app_path);
\Minz\Environment::initialize();
\Minz\Environment::startSession();

$faker = \Faker\Factory::create();

$faker_seed = getenv('SEED');
if ($faker_seed) {
$faker_seed = intval($faker_seed);
} else {
$faker_seed = random_int(PHP_INT_MIN, PHP_INT_MAX);
}

$faker->seed($faker_seed);
echo 'Use SEED=' . $faker_seed . " to reproduce this suite.\n";

0 comments on commit c992eca

Please sign in to comment.