Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Laravel 11 and phpunit 9 #59

Merged
merged 12 commits into from
Mar 15, 2024
Merged

Update for Laravel 11 and phpunit 9 #59

merged 12 commits into from
Mar 15, 2024

Conversation

abkrim
Copy link
Contributor

@abkrim abkrim commented Mar 15, 2024

Description

  • Changed composer.json for support Laravale 11
  • Change phpunit.xml modifying coverage in another file. (Show me an error when using actual Pest and PHPUnit)

Motivation and context

Use this great package in Laravel 11

How has this been tested?

vendor/bin/pest

   PASS  Tests\Feature\Controllers\LangCountrySwitchControllerTest
  ✓ it should switch for non logged in user                                                                                                                                                                                                                                                                          0.28s  
  ✓ it should switch for logged in user without lang country setting                                                                                                                                                                                                                                                 0.09s  
  ✓ it should switch for logged in user with lang country setting                                                                                                                                                                                                                                                    0.08s  
  ✓ it should redirect back without changes if a lang country is not allowed                                                                                                                                                                                                                                         0.08s  

   PASS  Tests\Feature\LangCountry\LangCountryTest
  ✓ it should get lang_country based on app locale, lang_country session and fallback_based_on_current_locale setting with (true, null, 'en', …)                                                                                                                                                                     0.02s  
  ✓ it should get lang_country based on app locale, lang_country session and fallback_based_on_current_locale setting with (true, null, 'nl', …)                                                                                                                                                                     0.01s  
  ✓ it should get lang_country based on app locale, lang_country session and fallback_based_on_current_locale setting with (false, 'en-US', 'en', …)                                                                                                                                                                 0.01s  
  ✓ it should get lang_country based on app locale, lang_country session and fallback_based_on_current_locale setting with (false, null, 'nl', …)                                                                                                                                                                    0.01s  
  ✓ it should return the right values for nl-nl                                                                                                                                                                                                                                                                      0.02s  
  ✓ it returns the right values for en-US                                                                                                                                                                                                                                                                            0.01s  
  ✓ it should return the right values for enUS while session is nl-NL but is overruled                                                                                                                                                                                                                               0.01s  
  ✓ it should return all the available languages                                                                                                                                                                                                                                                                     0.01s  
  ✓ it should use the override when available                                                                                                                                                                                                                                                                        0.01s  
  ✓ it should return the language for an override lang country code                                                                                                                                                                                                                                                  0.01s  
  ✓ it should accept the withTime method                                                                                                                                                                                                                                                                             0.02s  

   PASS  Tests\Feature\LangCountryData\LangCountryDataTest
  ✓ it should contain all attributes as given in the template file                                                                                                                                                                                                                                                   0.03s  

   PASS  Tests\Feature\Listeners\UserAuthenticatedTest
  ✓ it should set all sessions when the user is logged in by listening to the Login event                                                                                                                                                                                                                            0.08s  

   PASS  Tests\Feature\Middleware\MiddlewareTest
  ✓ it should call the setAllSessions method when there is no lang_country session and no logged in user                                                                                                                                                                                                             0.08s  
  ✓ it should not call the setAllSessions method when there is a lang_country session but no logged in user                                                                                                                                                                                                          0.08s  
  ✓ it should call the setAllSessions method with the browser locale when there is a lang_country session but there is a user without a lang_country value in the database                                                                                                                                           0.09s  
  ✓ it should call the setAllSessions method with the user lang_country value when there is a lang_country session but there is a user with a lang_country value in the database                                                                                                                                     0.08s  

   PASS  Tests\Feature\Services\PreferredLanguageTest
  ✓ it should get preferred languages in right order                                                                                                                                                                                                                                                                 0.01s  
  ✓ it prioritize more specific values                                                                                                                                                                                                                                                                               0.01s  
  ✓ it should return exact match with allowed lang country                                                                                                                                                                                                                                                           0.01s  
  ✓ it should match based on lang                                                                                                                                                                                                                                                                                    0.01s  
  ✓ it should return fallback when there is no match                                                                                                                                                                                                                                                                 0.01s  
  ✓ it should return country in lowercase                                                                                                                                                                                                                                                                            0.01s  
  ✓ it should override the default allowed languages from the config                                                                                                                                                                                                                                                 0.01s  
  ✓ it should fall back to only country two char if four char json not available                                                                                                                                                                                                                                     0.01s  
  ✓ it should use four char json when available                                                                                                                                                                                                                                                                      0.02s  
  ✓ it should should be able to override the lang_country session                                                                                                                                                                                                                                                    0.02s  
  ✓ it should throw an error when the lang_country session is null                                                                                                                                                                                                                                                   0.03s  
  ✓ it should use the fallback when the preferred_languages is null                                                                                                                                                                                                                                                  0.02s  
  ✓ it should use the fallback when the preferred_languages is an empty string                                                                                                                                                                                                                                       0.01s  

  Tests:    34 passed (1251 assertions)
  Duration: 1.42s

❯ ga && gc 'Upodate for Laravel 11 and phpunit 9' && gp
❯ g status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   composer.json
        modified:   composer.lock
        modified:   phpunit.xml

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .phpunit.cache/
        phpunit.xml.coverage

no changes added to commit (use "git add" and/or "git commit -a")
❯ g status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   .gitignore
        modified:   composer.json
        modified:   composer.lock
        modified:   phpunit.xml

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        phpunit.xml.coverage

no changes added to commit (use "git add" and/or "git commit -a")
❯ ga && gc 'Upodate for Laravel 11 and phpunit 9' && gp
[master f26711a] Upodate for Laravel 11 and phpunit 9
 5 files changed, 382 insertions(+), 369 deletions(-)
 create mode 100644 phpunit.xml.coverage
Enumerating objects: 12, done.
Counting objects: 100% (12/12), done.
Delta compression using up to 8 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 6.47 KiB | 2.16 MiB/s, done.
Total 7 (delta 6), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (6/6), completed with 5 local objects.
To github.com:abkrim/laravel-lang-country.git
   d571948..f26711a  master -> master

    ~/Sites/laravel-lang-country    master                              

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

Please, please, please, don't send your pull request until all of the boxes are ticked. Once your pull request is created, it will trigger a build on our continuous integration server to make sure your tests and code style pass.

  • I have read the CONTRIBUTING document.
  • My pull request addresses exactly one patch/feature.
  • [] I have created a branch for this patch/feature.
  • [] Each individual commit in the pull request is meaningful.
  • I have added tests to cover my changes.
  • I ran tests locally with composer test:coverage and it passed.
  • If my change requires a change to the documentation, I have updated it accordingly.

If you're unsure about any of these, don't hesitate to ask. We're here to help!

stefro
stefro previously approved these changes Mar 15, 2024
Copy link
Owner

@stefro stefro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution @abkrim!

@stefro
Copy link
Owner

stefro commented Mar 15, 2024

@abkrim I approved it too soon. I found out the CI did not run because I had to approve it for pull requests by you. I've just did that and CI is not completing on the coverage parts (https://github.com/stefro/laravel-lang-country/actions/runs/8296673488/job/22708822850?pr=59).

So I'm not able to merge it. I'm not familiar with the 'phpunit.xml.coverage' file, can you see if something needs to be changed? (If it works, the CI should run as soon as you make a new commit to this PR.)

@stefro stefro dismissed their stale review March 15, 2024 14:30

CI tests fail

@abkrim
Copy link
Contributor Author

abkrim commented Mar 15, 2024

I lost.

Error for coverage in my mac, because not use usually.

Now, after install in mi mac pcov y can run test a test:coverage.

Castrislaravel-lang-country – composer json0315170321
Castrislaravel-lang-country – composer json0315170311
Castrislaravel-lang-country – composer json0315170252

Now I lost. I don't know request in uploaded, if is correct.

I'm not sure with github, since I always use gitlab, plus I don't usually work with other people. I am new to the topic of PR that I don't know in my area.

I'm sorry, if the last PR that I uploaded is not valid (it happens to me but it keeps giving a wraning, which is what I wanted to fix)

composer test

vendor/bin/pest

WARN Test results may not be as expected because the XML configuration file did not pass validation:

Line 18:

  • Element 'include': This element is not expected.

@stefro
Copy link
Owner

stefro commented Mar 15, 2024

@abkrim No problem! Configuring GH actions and phpunit is also not in my comfort zone.

Your changes have solved the issue, but we need to get Laravel 11 into the test matrix in main.xml. I need to figure that out since it is failing right now. (I understand it is failing on PHP 8.1, since L11 required 8.2).

I'm very limited in time. I will get back to it asap!

@abkrim
Copy link
Contributor Author

abkrim commented Mar 15, 2024

Not problem. I'm using a fork in my new project with L11. I'm sorry I'm not more of an expert on the subject. But I needed to install the package now... it's very good:

Best regards.

Copy link
Owner

@stefro stefro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abkrim Thank you for your contribution!

@stefro stefro merged commit 03eac0c into stefro:master Mar 15, 2024
10 checks passed
@stefro
Copy link
Owner

stefro commented Mar 15, 2024

Thanks @abkrim !
I was finally able to figure it out. The version numbers for the dev dependencies in composer.json were not Laravel 11 compatible. I will tag a new version number for the package shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants