diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33cae43..96f5f90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: test: strategy: matrix: - PHP: [56, 73, 74, 80] + PHP: [56, 73, 74, 80, 81] runs-on: ubuntu-latest steps: diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index a04fa3d..0d7bd20 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -33,7 +33,7 @@ '.vscode', '.github', '.devcontainer', - 'tests/_support/_generated/', + 'tests/Support/_generated/', ]; $finder = PhpCsFixer\Finder::create() diff --git a/codeception.yml b/codeception.yml index f0446cc..1a7adb4 100644 --- a/codeception.yml +++ b/codeception.yml @@ -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: diff --git a/composer.json b/composer.json index 6dacce9..0265f68 100644 --- a/composer.json +++ b/composer.json @@ -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": { @@ -23,7 +23,7 @@ }, "autoload-dev": { "psr-4": { - "Like\\Codeception\\Tests\\": "tests/" + "Tests\\": ["tests/", "tests/Support/"] } }, "authors": [ @@ -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" } } diff --git a/phpstan.neon b/phpstan.neon index 89943b5..7fe1b3c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,7 +4,7 @@ parameters: - src - tests scanDirectories: - - tests/_support/_generated/ + - tests/Support/_generated/ excludePaths: analyse: - - tests/_support/_generated/ \ No newline at end of file + - tests/Support/_generated/ \ No newline at end of file diff --git a/src/Phinx.php b/src/Phinx.php index f70f43e..52ff469 100644 --- a/src/Phinx.php +++ b/src/Phinx.php @@ -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); @@ -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); + } } diff --git a/tests/acceptance.suite.yml b/tests/Acceptance.suite.yml similarity index 85% rename from tests/acceptance.suite.yml rename to tests/Acceptance.suite.yml index 6539b99..9229b1f 100644 --- a/tests/acceptance.suite.yml +++ b/tests/Acceptance.suite.yml @@ -9,5 +9,4 @@ modules: enabled: - PhpBrowser: url: http://localhost/myapp - - \Helper\Acceptance -step_decorators: ~ \ No newline at end of file +step_decorators: ~ diff --git a/tests/_data/.gitkeep b/tests/Acceptance/.gitkeep similarity index 100% rename from tests/_data/.gitkeep rename to tests/Acceptance/.gitkeep diff --git a/tests/functional.suite.yml b/tests/Functional.suite.yml similarity index 64% rename from tests/functional.suite.yml rename to tests/Functional.suite.yml index 303c8ac..4ec7b28 100644 --- a/tests/functional.suite.yml +++ b/tests/Functional.suite.yml @@ -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: ~ \ No newline at end of file + step_decorators: ~ diff --git a/tests/acceptance/.gitkeep b/tests/Functional/.gitkeep similarity index 100% rename from tests/acceptance/.gitkeep rename to tests/Functional/.gitkeep diff --git a/tests/_support/AcceptanceTester.php b/tests/Support/AcceptanceTester.php similarity index 79% rename from tests/_support/AcceptanceTester.php rename to tests/Support/AcceptanceTester.php index d8c661f..89caca0 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/Support/AcceptanceTester.php @@ -1,5 +1,8 @@ seeNumRecords(0, 'user_logins'); diff --git a/tests/unit/PhinxTest.php b/tests/Unit/PhinxTest.php similarity index 100% rename from tests/unit/PhinxTest.php rename to tests/Unit/PhinxTest.php diff --git a/tests/_output/.gitignore b/tests/_output/.gitignore index c96a04f..d6b7ef3 100644 --- a/tests/_output/.gitignore +++ b/tests/_output/.gitignore @@ -1,2 +1,2 @@ * -!.gitignore \ No newline at end of file +!.gitignore diff --git a/tests/_support/Helper/Acceptance.php b/tests/_support/Helper/Acceptance.php deleted file mode 100644 index 90f4bfb..0000000 --- a/tests/_support/Helper/Acceptance.php +++ /dev/null @@ -1,8 +0,0 @@ -