Skip to content

Commit

Permalink
Merge pull request #3 from likesistemas/feature/config-seed
Browse files Browse the repository at this point in the history
✨ [EIC-881] Adicionando configuração para desativar seed
  • Loading branch information
ricardoapaes authored Sep 10, 2024
2 parents 35be2ce + bef5bb3 commit 9ac2b8a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
GITHUB_TOKEN=
PHP_VERSION=56|73|74|80
PHP_VERSION=56|73|74|80|81|82|83
DB_ENGINE=
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
test:
strategy:
matrix:
PHP: [56, 73, 74, 80, 81]
PHP: [56, 74, 80, 81, 82, 83]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Prepare code
env:
Expand All @@ -28,21 +28,21 @@ jobs:
- name: Prepare environment
run: |
docker-compose up -d
docker compose up -d
echo $(docker run -t --network github jwilder/dockerize -wait tcp://php:9000 -timeout 120s)
docker-compose ps
docker-compose logs php
docker compose ps
docker compose logs php
- name: Run PHP Unit
run: |
docker-compose exec -T php composer test
docker compose exec -T php composer test
- name: Run PHP Stan
if: matrix.PHP != '56'
run: |
docker-compose exec -T php composer analyse
docker compose exec -T php composer analyse
- name: Run PHP CS Fixer
if: matrix.PHP != '56'
run: |
docker-compose exec -T php composer fix:ci
docker compose exec -T php composer fix:ci
9 changes: 5 additions & 4 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

$rules = [
'@PSR2' => true,
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'multiline_whitespace_before_semicolons' => false,
'echo_tag_syntax' => false,
Expand All @@ -22,10 +22,11 @@
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'braces' => [
'allow_single_line_closure' => true,
'position_after_functions_and_oop_constructs' => 'same',
'curly_braces_position' => [
'classes_opening_brace' => 'same_line',
'functions_opening_brace' => 'same_line',
],
'visibility_required' => ['elements' => ['property', 'method']],
];

$excludes = [
Expand Down
22 changes: 17 additions & 5 deletions src/Phinx.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,35 @@ public function _before(TestInterface $test) {
$populate = $this->getModule('Db')->_getConfig('populate');

if ($populate) {
$this->phinx();
$this->phinx($this->getSeedConfig());
}
}

private function phinx() {
private function getSeedConfig() {
$seed = $this->_getConfig('seed');
if($seed === null) {
$seed = true;
}

return boolval($seed);
}

private function phinx($seed) {
$config = $this->findConfigPath();

$app = new PhinxApplication();
$app->setAutoExit(false);

$output = new BufferedOutput();

$this->run($app, $output, 'migrate', $config);
$this->run($app, $output, 'seed:run', $config);

if($seed) {
$this->run($app, $output, 'seed:run', $config);
}
}

private function run(PhinxApplication $phinx, BufferedOutput $output, $commandName, $config, $environment='production') {
private function run(PhinxApplication $phinx, BufferedOutput $output, $commandName, $config, $environment = 'production') {
$arguments = [
'command' => $commandName,
'--environment' => $environment,
Expand Down

0 comments on commit 9ac2b8a

Please sign in to comment.