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

Wrong formatting of Pest's get method #354

Open
toddy15 opened this issue Feb 28, 2025 · 3 comments
Open

Wrong formatting of Pest's get method #354

toddy15 opened this issue Feb 28, 2025 · 3 comments

Comments

@toddy15
Copy link

toddy15 commented Feb 28, 2025

Pint Version

1.21.0

PHP Version

8.4.4

Description

I've noticed that pint creates wrongly formatted output for the Pest test method get. I suspect that this might be related to #352.

Below is a diff of a pint run of one of my tests:

 test('a guest can view the homepage', function () {
-    get('/')
-        ->assertOk()
-        ->assertViewIs('homepage');
-});
+get('/')
+->assertOk()
+->assertViewIs('homepage');
+    });

Steps To Reproduce

Create a Pest test and format it with pint.

Expected:

test('a guest can view the homepage', function () {
    get('/')
        ->assertOk()
        ->assertViewIs('homepage');
});

Actual output:

test('a guest can view the homepage', function () {
get('/')
->assertOk()
->assertViewIs('homepage');
    });
@stephanbouman
Copy link

We have the same problem. Some additional information:

We are running v1.21.0 with php 8.3, that gives no errors in styling.

php -v
PHP 8.3.17 (cli) (built: Feb 14 2025 00:21:15) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.17, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.17, Copyright (c), by Zend Technologies

and then run:

php vendor/bin/pint --test

  ...................................................................................................................................................................
  .................................................................................

  ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Laravel
    PASS   ................................................................................................................................................ 244 files

But when i use php8.4:

php -v
PHP 8.4.4 (cli) (built: Feb 14 2025 00:20:59) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.4, Copyright (c), by Zend Technologies

The output differs:

php vendor/bin/pint --test

  ...................................................................................................................................................................
  ...................................................⨯...⨯⨯⨯.......................

  ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Laravel
    FAIL   ................................................................................................................................ 244 files, 4 style issues
  ⨯ tests/Feature/Auth/AuthenticationTest.php                                           statement_indentation, no_extra_blank_lines, blank_line_between_import_groups
  ⨯ tests/Feature/Auth/PasswordResetTest.php                                            statement_indentation, no_extra_blank_lines, blank_line_between_import_groups
  ⨯ tests/Feature/Auth/RegistrationTest.php                                             statement_indentation, no_extra_blank_lines, blank_line_between_import_groups
  ⨯ tests/Feature/Auth/VerifiedLoginControllerTest.php                                  statement_indentation, no_extra_blank_lines, blank_line_between_import_groups

The difference in files is the same as @toddy15 described:

Image

@toddy15
Copy link
Author

toddy15 commented Mar 4, 2025

A workaround for this is to use $this->get() instead of the function Pest\Laravel\get(). Pint then formats the source code as expected on PHP 8.4.

@stephanbouman
Copy link

@toddy15 we figured that out as well. It seems that it only happens with Pest\Laravel\get() . Tests where we use the Pest\Laravel\post() method are not affected.

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

No branches or pull requests

2 participants