![]() And that got me wondering: how are people installing and using this tool? Overall, I am not sure if drupal-check actually needed a release since I have removed the Phar installation option (which provides all dependencies bundled into a single executable.) Technically, users just needed to run composer update to receive the updated phpstan-drupal dependency. It felt good to triage the project and its issues. I also made the 1.1.8 release for drupal-check. It creates a mutated test class into its own codebase. In the end, I had to create a file that replicated the code in ClassWriter that would be autoloaded before Drupal was analyzed or any PHPUnit classes loaded during tests. The result was a drupal-phpunit-hack.php file added to phpstan-drupal's autoload definition. If you want to watch my visual despair, here is a link to that part of the stream. I needed to find a fix that worked when running phpstan-drupal's own PHPUnit test suite and analyzing a Drupal codebase. That meant Drupal could not be statically analyzed if PHPUnit 8 is installed without running the mutation. Drupal modifies a class at runtime, moves it into a new location, and autoloads it to replace the default code. It finds the PHPUnit\Framework\TestCase class before it has been loaded and on-demand mutates the base test class and copies it into the sites/simpletest folder. While reading through Drupal's PHPUnit bootstrap file, I found this ClassWriter class. In fact, a bug in PHP-Parser was crashing on a class alias within a trait for PHPUnit compatibility not too long ago. How doe Drupal work around this? Shouldn't everything be breaking?! Drupal provides various PHPUnit compatibility tools. What does that mean? When you try to analyze or execute the file, you get the following error: PHP Fatal error: Declaration of Drupal\Tests\UnitTestCase::setUp() must be compatible with PHPUnit\Framework\TestCase::setUp(): void ![]() Drupal tests are littered with overrides of this method and do not specify the return type, and therefore are not compatible overrides. PHPUnit 8 added a void return type to the setUp method. If you missed the live stream, I hit a fun error due to Drupal's workaround PHPUnit 8. My work was getting the testing pipelines to verify everything was working with PHP 8 and Drupal 9. I want to give thanks to andypost and liber_t for pull requests to fix errors when running on PHP 8. The 0.12.9 version was released on March 10th. This release allowed Upgrade Status to create an alpha release with PHP 8 support. Maybe a little more since I haven't included time spent in Drupal Slack very well. I'll explain how I'll use the remaining hours at the end of this update. Of the sponsored 20 hours thus far, I have used 7 hours total. ![]() let me know if you have any questions and I’ll be happy to answer them.I am happy to announce that phpstan-drupal and drupal-check are Drupal 9 and PHP 8 ready! Both projects have CI pipelines running tests and analysis to make sure they're compatible as we start the journey for Drupal 10 (□ already? I know!)įlorida DrupalCamp sponsored 20 hours of development. Since my funding is from the community, I have been working on these projects via a live stream on Twitch every Wednesday. To do this I use this Drush command: drush cr if you don’t currently use Drush, I highly recommend using it, or the Drupal Console. Now, go back to your site, and you should be able to see the Action you have just created. follow these screenshots to know how to use it. Now, this is what the class file should contain in the end: addMessage(t($message), $type) The annotation allows us to identify the action, also this class will contain doExecute() method.ĭoExecute() method will contain the logic of our action. The class file should contain annotation as well. we’ll place our ShowMessage.php class under the modules/custom/codimth_custom_rules_action/src/Plugin/RulesAction directory. Now, we’ll create a class that will contain the logic of our action. Once the folder and file has been created, you can go to your Drupal dashboard and enable the custom module we have just created. Inside this file enter following: name: Codimth Custom Rules Actionĭescription: Create a custom rules Action you will need to create the codimth_custom_rules_ file under the modules/custom/codimth_custom_rules_action folder. In Drupal 8, it is necessary to create an info.yml file that contains the metadata for every custom module. in this tutorial I’ll show you how to create custom rules action in Drupal 8. Rules is a tool that enables you to define automatic, conditionally executed actions, triggered by various types of events.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |