recipes-contrib icon indicating copy to clipboard operation
recipes-contrib copied to clipboard

Adding 5.0

Open ThomasLandauer opened this issue 1 year ago • 1 comments

Q A
License MIT
Packagist https://packagist.org/packages/codeception/codeception

Still missing: This should be added to composer.json, right?:

"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    }
},

ThomasLandauer avatar Sep 05 '22 22:09 ThomasLandauer

Thanks for the PR 😍

How to test these changes in your application

  1. Define the SYMFONY_ENDPOINT environment variable:

    # On Unix-like (BSD, Linux and macOS)
    export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes-contrib/flex/pull-1432/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes-contrib/flex/pull-1432/index.json
    
  2. Install the package(s) related to this recipe:

    composer req 'symfony/flex:^1.16'
    composer req 'codeception/codeception:^5.0'
    
  3. Don't forget to unset the SYMFONY_ENDPOINT environment variable when done:

    # On Unix-like (BSD, Linux and macOS)
    unset SYMFONY_ENDPOINT
    # On Windows
    SET SYMFONY_ENDPOINT=
    

Diff between recipe versions

In order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes. I'm going keep this comment up to date with any updates of the attached patch.

codeception/codeception

2.3 vs 5.0
diff --git a/codeception/codeception/2.3/codeception.yml b/codeception/codeception/5.0/codeception.yml
index 3007d95c..eff10fc2 100644
--- a/codeception/codeception/2.3/codeception.yml
+++ b/codeception/codeception/5.0/codeception.yml
@@ -1,13 +1,12 @@
-namespace: App\Tests
+namespace: Tests
+support_namespace: Support
 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:
     enabled:
         - Codeception\Extension\RunFailed
-params:
-    - .env
diff --git a/codeception/codeception/2.3/post-install.txt b/codeception/codeception/5.0/post-install.txt
index 59f6b133..d2ed0e14 100644
--- a/codeception/codeception/2.3/post-install.txt
+++ b/codeception/codeception/5.0/post-install.txt
@@ -1,14 +1,14 @@
 File codeception.yml created        <- global configuration
-tests/unit created                  <- unit tests
-tests/unit.suite.yml written        <- unit tests suite configuration
-tests/functional created            <- functional tests
-tests/functional.suite.yml written  <- functional tests suite configuration
-tests/acceptance created            <- acceptance tests
-tests/acceptance.suite.yml written  <- acceptance tests suite configuration
+tests/Unit created                  <- unit tests
+tests/Unit.suite.yml written        <- unit tests suite configuration
+tests/Functional created            <- functional tests
+tests/Functional.suite.yml written  <- functional tests suite configuration
+tests/Acceptance created            <- acceptance tests
+tests/Acceptance.suite.yml written  <- acceptance tests suite configuration
 Codeception is installed for acceptance, functional, and unit testing
 Next steps:
-1. Edit tests/acceptance.suite.yml to set the url of your application. Change PhpBrowser to WebDriver to enable browser testing.
-2. Edit tests/functional.suite.yml to enable Doctrine module if needed.
+1. Edit tests/Acceptance.suite.yml to set the url of your application. Change PhpBrowser to WebDriver to enable browser testing.
+2. Edit tests/Functional.suite.yml to enable Doctrine module if needed.
 3. Create your first acceptance test using vendor/bin/codecept g:cest Acceptance First
-4. Write your first test in tests/acceptance/FirstCest.php
+4. Write your first test in tests/Acceptance/FirstCest.php
 5. Run tests using: vendor/bin/codecept run
diff --git a/codeception/codeception/2.3/tests/_data/.gitignore b/codeception/codeception/5.0/tests/Acceptance/.gitignore
similarity index 100%
rename from codeception/codeception/2.3/tests/_data/.gitignore
rename to codeception/codeception/5.0/tests/Acceptance/.gitignore
diff --git a/codeception/codeception/2.3/tests/acceptance.suite.yml b/codeception/codeception/5.0/tests/Acceptance.suite.yml
similarity index 88%
rename from codeception/codeception/2.3/tests/acceptance.suite.yml
rename to codeception/codeception/5.0/tests/Acceptance.suite.yml
index 4733290f..38ba206e 100644
--- a/codeception/codeception/2.3/tests/acceptance.suite.yml
+++ b/codeception/codeception/5.0/tests/Acceptance.suite.yml
@@ -9,4 +9,4 @@ modules:
     enabled:
         - PhpBrowser:
             url: http://localhost:8000
-        - \App\Tests\Helper\Acceptance
+        - Tests\Support\Helper\Acceptance
diff --git a/codeception/codeception/2.3/tests/acceptance/.gitignore b/codeception/codeception/5.0/tests/Functional/.gitignore
similarity index 100%
rename from codeception/codeception/2.3/tests/acceptance/.gitignore
rename to codeception/codeception/5.0/tests/Functional/.gitignore
diff --git a/codeception/codeception/2.3/tests/functional.suite.yml b/codeception/codeception/5.0/tests/Functional.suite.yml
similarity index 91%
rename from codeception/codeception/2.3/tests/functional.suite.yml
rename to codeception/codeception/5.0/tests/Functional.suite.yml
index ccd2a252..54adb532 100644
--- a/codeception/codeception/2.3/tests/functional.suite.yml
+++ b/codeception/codeception/5.0/tests/Functional.suite.yml
@@ -14,4 +14,4 @@ modules:
 #        - Doctrine2:
 #            depends: Symfony
 #            cleanup: true
-        - \App\Tests\Helper\Functional
+        - Tests\Support\Helper\Functional
diff --git a/codeception/codeception/2.3/tests/_support/AcceptanceTester.php b/codeception/codeception/5.0/tests/Support/AcceptanceTester.php
similarity index 96%
rename from codeception/codeception/2.3/tests/_support/AcceptanceTester.php
rename to codeception/codeception/5.0/tests/Support/AcceptanceTester.php
index e0b036bc..050200ed 100644
--- a/codeception/codeception/2.3/tests/_support/AcceptanceTester.php
+++ b/codeception/codeception/5.0/tests/Support/AcceptanceTester.php
@@ -1,5 +1,5 @@
 <?php
-namespace App\Tests;
+namespace Tests\Support;
 
 /**
  * Inherited Methods
diff --git a/codeception/codeception/2.3/tests/functional/.gitignore b/codeception/codeception/5.0/tests/Support/Data/.gitignore
similarity index 100%
rename from codeception/codeception/2.3/tests/functional/.gitignore
rename to codeception/codeception/5.0/tests/Support/Data/.gitignore
diff --git a/codeception/codeception/2.3/tests/_support/FunctionalTester.php b/codeception/codeception/5.0/tests/Support/FunctionalTester.php
similarity index 96%
rename from codeception/codeception/2.3/tests/_support/FunctionalTester.php
rename to codeception/codeception/5.0/tests/Support/FunctionalTester.php
index 48eaea91..af87d18e 100644
--- a/codeception/codeception/2.3/tests/_support/FunctionalTester.php
+++ b/codeception/codeception/5.0/tests/Support/FunctionalTester.php
@@ -1,5 +1,5 @@
 <?php
-namespace App\Tests;
+namespace Tests\Support;
 
 /**
  * Inherited Methods
diff --git a/codeception/codeception/2.3/tests/_support/UnitTester.php b/codeception/codeception/5.0/tests/Support/UnitTester.php
similarity index 95%
rename from codeception/codeception/2.3/tests/_support/UnitTester.php
rename to codeception/codeception/5.0/tests/Support/UnitTester.php
index 27870a86..f9abbaed 100644
--- a/codeception/codeception/2.3/tests/_support/UnitTester.php
+++ b/codeception/codeception/5.0/tests/Support/UnitTester.php
@@ -1,5 +1,5 @@
 <?php
-namespace App\Tests;
+namespace Tests\Support;
 
 /**
  * Inherited Methods
diff --git a/codeception/codeception/2.3/tests/_support/_generated/.gitignore b/codeception/codeception/5.0/tests/Support/_generated/.gitignore
similarity index 100%
rename from codeception/codeception/2.3/tests/_support/_generated/.gitignore
rename to codeception/codeception/5.0/tests/Support/_generated/.gitignore
diff --git a/codeception/codeception/2.3/tests/unit/.gitignore b/codeception/codeception/5.0/tests/Unit/.gitignore
similarity index 100%
rename from codeception/codeception/2.3/tests/unit/.gitignore
rename to codeception/codeception/5.0/tests/Unit/.gitignore
diff --git a/codeception/codeception/2.3/tests/unit.suite.yml b/codeception/codeception/5.0/tests/Unit.suite.yml
similarity index 79%
rename from codeception/codeception/2.3/tests/unit.suite.yml
rename to codeception/codeception/5.0/tests/Unit.suite.yml
index 56d5ea86..c5353fbf 100644
--- a/codeception/codeception/2.3/tests/unit.suite.yml
+++ b/codeception/codeception/5.0/tests/Unit.suite.yml
@@ -6,4 +6,4 @@ actor: UnitTester
 modules:
     enabled:
         - Asserts
-        - \App\Tests\Helper\Unit
+        - Tests\Support\Helper\Unit
diff --git a/codeception/codeception/2.3/tests/_support/Helper/Acceptance.php b/codeception/codeception/2.3/tests/_support/Helper/Acceptance.php
deleted file mode 100644
index 429488fa..00000000
--- a/codeception/codeception/2.3/tests/_support/Helper/Acceptance.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-namespace App\Tests\Helper;
-
-// here you can define custom actions
-// all public methods declared in helper class will be available in $I
-
-class Acceptance extends \Codeception\Module
-{
-
-}
diff --git a/codeception/codeception/2.3/tests/_support/Helper/Functional.php b/codeception/codeception/2.3/tests/_support/Helper/Functional.php
deleted file mode 100644
index 4b605322..00000000
--- a/codeception/codeception/2.3/tests/_support/Helper/Functional.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-namespace App\Tests\Helper;
-
-// here you can define custom actions
-// all public methods declared in helper class will be available in $I
-
-class Functional extends \Codeception\Module
-{
-
-}
diff --git a/codeception/codeception/2.3/tests/_support/Helper/Unit.php b/codeception/codeception/2.3/tests/_support/Helper/Unit.php
deleted file mode 100644
index 2038c094..00000000
--- a/codeception/codeception/2.3/tests/_support/Helper/Unit.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-namespace App\Tests\Helper;
-
-// here you can define custom actions
-// all public methods declared in helper class will be available in $I
-
-class Unit extends \Codeception\Module
-{
-
-}

github-actions[bot] avatar Sep 05 '22 22:09 github-actions[bot]

I am maintainer of Codeception.

This pull request is a bit better because it correctly uses .yml extension for all .suite.yml files (Codeception doesn't use .yaml extension) and enables Symfony module in Functional.suite.yml file. Also it correctly enables Helper files in module configuration.

Tester files must be added, but Helper files aren't necessary, I guess that they were added to reduce differences from the previous version of this recipe.

There is very little original work in either pull request (manifest.json). Other files can be generated by running vendor/bin/codecept bootstrap command. post-install.txt file contains output of codecept bootstrap command.

Symfony module is no longer a part of codeception/codeception package since 4.0. Is it possible to make codeception/module-symfony a dependency of this recipe or add suggestion to install it to post-install.txt ?

Naktibalda avatar Jan 07 '23 20:01 Naktibalda

Also it correctly enables Helper files in module configuration.

Is it OK to enable them, even if they don't exist? (as we just deleted them)

Is it possible to make codeception/module-symfony a dependency of this recipe or add suggestion to install it to post-install.txt ?

A somewhat stupid question: This recipe is run for all Codeception installations, right? (Not just for Symfony users?) Then suggesting Symfony module is probably not the best idea...

From above: This needs to be added to composer.json, right?:

"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    }
},

Can this be done through this recipe or someway else?

ThomasLandauer avatar Jan 08 '23 14:01 ThomasLandauer

I'm codeception/module-symfony maintainer.

I've submitted a PR that replaces the current one in #1583:

  • I've added @ThomasLandauer as a co-author in the commit.
  • Helpers are not necessary for a first run, it is better not to add them by default unless we want another first run error for the user.
  • Running vendor/bin/codecept run already suggests the user to install the modules that have been imported but are not installed through composer. That's the way it has worked up to this point and I don't consider it a 5.0 recipe blocker, we can move on.
  • This recipe is only for Symfony installations, not other frameworks. So I have taken the liberty to remove the previous step 1 in post-install.txt as the default url given corresponds to the default url in Symfony.
  • Finally, there's no need for the test namespace to be named Tests, since we can not modify the composer.json file to add the patch that @ThomasLandauer suggests, the simplest thing is to leave things as they were and that App\Tests remains the default namespace in this recipe.

cc. @Naktibalda , @fabpot

TavoNiievez avatar Jan 09 '24 13:01 TavoNiievez

OK, thanks @TavoNiievez, then I'm closing here.

ThomasLandauer avatar Jan 09 '24 16:01 ThomasLandauer