Skip to content

Commit

Permalink
🚑️ Fix phinx config path (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoapaes authored Sep 6, 2022
1 parent 9b5b52e commit 35be2ce
Show file tree
Hide file tree
Showing 23 changed files with 62 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
test:
strategy:
matrix:
PHP: [56, 73, 74, 80]
PHP: [56, 73, 74, 80, 81]
runs-on: ubuntu-latest

steps:
Expand Down
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'.vscode',
'.github',
'.devcontainer',
'tests/_support/_generated/',
'tests/Support/_generated/',
];

$finder = PhpCsFixer\Finder::create()
Expand Down
6 changes: 4 additions & 2 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace: Tests

paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
data: tests/Support/Data
support: tests/Support
envs: tests/_envs
actor_suffix: Tester
extensions:
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"codeception/codeception": "^4.0 || ^5.0",
"codeception/module-phpbrowser": "^1.0 || ^2.0",
"codeception/module-asserts": "^1.3 || ^2.0",
"codeception/module-db": "^1.1 || ^2.0"
"codeception/module-db": "^1.1 || ^2.0 || ^3.0"
},
"autoload": {
"psr-4": {
Expand All @@ -23,7 +23,7 @@
},
"autoload-dev": {
"psr-4": {
"Like\\Codeception\\Tests\\": "tests/"
"Tests\\": ["tests/", "tests/Support/"]
}
},
"authors": [
Expand All @@ -36,7 +36,10 @@
"scripts": {
"fix": "php-cs-fixer fix --show-progress=dots",
"fix:ci": "php-cs-fixer fix --dry-run --stop-on-violation --show-progress=dots",
"test": "codecept run",
"test": [
"codecept build",
"codecept run"
],
"analyse": "phpstan analyse"
}
}
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ parameters:
- src
- tests
scanDirectories:
- tests/_support/_generated/
- tests/Support/_generated/
excludePaths:
analyse:
- tests/_support/_generated/
- tests/Support/_generated/
24 changes: 23 additions & 1 deletion src/Phinx.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function _before(TestInterface $test) {
}

private function phinx() {
$config = realpath(__DIR__ . '/../../phinx.php');
$config = $this->findConfigPath();

$app = new PhinxApplication();
$app->setAutoExit(false);
Expand All @@ -42,4 +42,26 @@ private function run(PhinxApplication $phinx, BufferedOutput $output, $commandNa
trigger_error("Error on phinx execution.\n\n" . $output->fetch(), E_USER_ERROR);
}
}

private function findConfigPath() {
$paths = [
'../../../../tests/phinx.php',
'../../../../phinx.php',
'../../phinx.php',
'../phinx.php', // To use inside library tests
];

$notFound = [];

foreach ($paths as $path) {
$src = __DIR__ . '/' . $path;
if (file_exists($src)) {
return realpath($src);
}

$notFound[] = $src;
}

trigger_error('Phinx configuration not found. Paths: `' . join('`, `', $notFound) . '`', E_USER_NOTICE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ modules:
enabled:
- PhpBrowser:
url: http://localhost/myapp
- \Helper\Acceptance
step_decorators: ~
step_decorators: ~
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
#
# Suite for functional tests
# Emulate web requests and make application process them
# Include one of framework modules (Symfony2, Yii2, Laravel5, Phalcon4) to use it
# Include one of framework modules (Symfony, Yii2, Laravel, Phalcon5) to use it
# Remove this suite if you don't use frameworks

actor: FunctionalTester
modules:
enabled:
# add a framework module here
- \Helper\Functional
step_decorators: ~
step_decorators: ~
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

namespace Tests;

use Tests\_generated\AcceptanceTesterActions;

/**
* Inherited Methods
Expand All @@ -13,12 +16,12 @@
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause()
* @method void pause($vars = [])
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor {
use _generated\AcceptanceTesterActions;
use AcceptanceTesterActions;

/*
* Define custom actions here
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

namespace Tests;

use Tests\_generated\FunctionalTesterActions;

/**
* Inherited Methods
Expand All @@ -13,12 +16,12 @@
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause()
* @method void pause($vars = [])
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor {
use _generated\FunctionalTesterActions;
use FunctionalTesterActions;

/*
* Define custom actions here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

namespace Tests;

use Tests\_generated\UnitTesterActions;

/**
* Inherited Methods
Expand All @@ -13,12 +16,12 @@
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause()
* @method void pause($vars = [])
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor {
use _generated\UnitTesterActions;
use UnitTesterActions;

/*
* Define custom actions here
Expand Down
2 changes: 2 additions & 0 deletions tests/Support/_generated/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
1 change: 0 additions & 1 deletion tests/unit.suite.yml → tests/Unit.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ modules:
enabled:
- Asserts
- Db
- \Helper\Unit
- Like\Codeception\Phinx
step_decorators: ~
config:
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/FirstCest.php → tests/Unit/FirstCest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

namespace Tests\Unit;

use Tests\UnitTester;

class FirstCest {
public function tryToTest(UnitTester $I) {
$I->seeNumRecords(0, 'user_logins');
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/_output/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*
!.gitignore
!.gitignore
8 changes: 0 additions & 8 deletions tests/_support/Helper/Acceptance.php

This file was deleted.

8 changes: 0 additions & 8 deletions tests/_support/Helper/Functional.php

This file was deleted.

8 changes: 0 additions & 8 deletions tests/_support/Helper/Unit.php

This file was deleted.

2 changes: 0 additions & 2 deletions tests/_support/_generated/.gitignore

This file was deleted.

0 comments on commit 35be2ce

Please sign in to comment.