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

Use destruction events at a later runtime #606

Merged

Conversation

mglaman
Copy link
Contributor

@mglaman mglaman commented Nov 21, 2023

This pull request is for: (mark with an "x")

  • examples/*
  • modules/next
  • packages/next-drupal
  • starters/basic-starter
  • starters/graphql-starter
  • Other

GitHub Issue: fixes #444

  • I need help adding tests. (mark with an "x")
    Code changes need test coverage. If you don't know
    how to make tests, check this box to ask for help.

Describe your changes

See issue – converts from inappropriate drupal_register_shutdown_functioncalls to destruction service so that the container is available, appropriately.

Copy link

vercel bot commented Nov 21, 2023

@mglaman is attempting to deploy a commit to the Chapter Three Team on Vercel.

A member of the Team first needs to authorize it.

@mglaman
Copy link
Contributor Author

mglaman commented Nov 21, 2023

Looks blocked on #605

@JohnAlbin
Copy link
Collaborator

@mglaman #605 has been merged.

It looks like the PHP tests are failing on coding standards issue. You can run yarn phpcs to test PHP coding standards on your local git clone.

@mglaman
Copy link
Contributor Author

mglaman commented Nov 22, 2023

Thanks! I'll tidy that up after holiday break

@JohnAlbin
Copy link
Collaborator

JohnAlbin commented Dec 4, 2023

There's still some phpcs errors.

FILE: ...modules/next/src/EventSubscriber/EntityActionEventDispatcher.php
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
 15 | ERROR | Missing short description in doc comment
    |       | (Drupal.Commenting.DocComment.MissingShort)
 20 | ERROR | Parameter $eventDispatcher is not described in
    |       | comment
    |       | (Drupal.Commenting.FunctionComment.ParamMissingDefinition)
 23 | ERROR | Doc comment for parameter $next_entity_type_manager
    |       | does not match actual variable name
    |       | $eventDispatcher
    |       | (Drupal.Commenting.FunctionComment.ParamNameNoMatch)
----------------------------------------------------------------------

From #444:

This is preventing the ability to write tests. I notice that https://github.com/chapter-three/next-drupal/blob/main/modules/next/tests/src/Kernel/Event/EntityActionEventTest.php is explicitly invoking _drupal_shutdown_function but tests which do not fail

What changes should we make to our tests related to this comment?

@mglaman
Copy link
Contributor Author

mglaman commented Dec 7, 2023

What changes should we make to our tests related to this comment?

Your tests are explicitly invoking the shutdown function, that's there weren't any errors here before. But for our tests, the shutdown was being invoked after the test had finished and Drupal's container destroyed. Which I also forgot to update the tests, here!

fixes phpcs and tests for changes
@mglaman
Copy link
Contributor Author

mglaman commented Dec 7, 2023

I think phpcs and tests can be fixed. I can rebase this onto one commit with proper commit messaging

Copy link
Collaborator

@JohnAlbin JohnAlbin left a comment

Choose a reason for hiding this comment

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

This is looking good.

There's just one test failure now.

There was 1 failure:

1) Drupal\Tests\next\Kernel\Plugin\PathRevalidatorTest::testRevalidate
Some predictions failed:
Double\ClientInterface\P1:
  No calls have been made that match:
      Double\ClientInterface\P1->request(exact("GET"), exact("http://blog.com/api/revalidate?slug=/node/2"))
    but expected at least one.
  No calls have been made that match:
      Double\ClientInterface\P1->request(exact("GET"), exact("http://marketing.com/api/revalidate?slug=/node/3&secret=12345"))
    but expected at least one.
  No calls have been made that match:
      Double\ClientInterface\P1->request(exact("GET"), exact("http://blog.com/api/revalidate?slug=/node/3"))
    but expected at least one.
  No calls have been made that match:
      Double\ClientInterface\P1->request(exact("GET"), exact("http://marketing.com/api/revalidate?slug=/&secret=12345"))
    but expected at least one.
  No calls have been made that match:
      Double\ClientInterface\P1->request(exact("GET"), exact("http://marketing.com/api/revalidate?slug=/blog&secret=12345"))
    but expected at least one.
  No calls have been made that match:
      Double\ClientInterface\P1->request(exact("GET"), exact("http://blog.com/api/revalidate?slug=/"))
    but expected at least one.
  No calls have been made that match:
      Double\ClientInterface\P1->request(exact("GET"), exact("http://blog.com/api/revalidate?slug=/blog"))
    but expected at least one.

replace calls to drupal shutdown for kernel terminate in tests
Copy link
Collaborator

@JohnAlbin JohnAlbin left a comment

Choose a reason for hiding this comment

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

All the tests pass!

@JohnAlbin JohnAlbin merged commit ec2cee0 into chapter-three:main Dec 12, 2023
7 of 8 checks passed
@mglaman mglaman deleted the entity-action-event-terminate-dispatcher branch April 4, 2024 15:16
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.

Kernel::TERMINATE over drupal_register_shutdown_function
3 participants