44
55use Drupal \dblog \Controller \DbLogController ;
66use Drupal \KernelTests \KernelTestBase ;
7+ use Drupal \language \Entity \ConfigurableLanguage ;
78use Drupal \next \Entity \NextEntityTypeConfig ;
89use Drupal \node \Entity \NodeType ;
910use Drupal \Tests \node \Traits \NodeCreationTrait ;
@@ -30,6 +31,8 @@ class EntityRevalidatedEventTest extends KernelTestBase {
3031 'system ' ,
3132 'user ' ,
3233 'dblog ' ,
34+ 'content_translation ' ,
35+ 'language ' ,
3336 ];
3437
3538 /**
@@ -46,6 +49,9 @@ protected function setUp(): void {
4649 $ this ->installSchema ('node ' , ['node_access ' ]);
4750 $ this ->installSchema ('user ' , ['users_data ' ]);
4851
52+ // Set up multilingual.
53+ ConfigurableLanguage::createFromLangcode ('nl ' )->save ();
54+
4955 NodeType::create (['type ' => 'page ' , 'name ' => 'Page ' ])->save ();
5056
5157 // Create entity type config.
@@ -71,24 +77,31 @@ protected function setUp(): void {
7177 */
7278 public function testEntityRevalidatedEvents () {
7379 $ page = $ this ->createNode (['type ' => 'page ' , 'title ' => 'A page ' ]);
80+ $ page ->addTranslation ('nl ' , ['title ' => 'Translation ' ]);
7481
7582 // Insert.
7683 $ page ->save ();
7784 $ this ->container ->get ('kernel ' )->terminate (Request::create ('/ ' ), new Response ());
78- $ this ->assertLogsContains (" Entity A page, action insert, revalidated 0. " );
85+ $ this ->assertLogsContains (' Entity A page, action insert, revalidated 0. ' );
7986
8087 // Update.
8188 $ page ->set ('title ' , 'A page updated ' )->save ();
8289 $ this ->container ->get ('kernel ' )->terminate (Request::create ('/ ' ), new Response ());
83- $ this ->assertLogsContains ("Entity A page updated, action update, revalidated 0. " );
90+ $ this ->assertLogsContains ('Entity A page updated, action update, revalidated 0. ' );
91+
92+ // Delete translation.
93+ $ page ->removeTranslation ('nl ' );
94+ $ page ->save ();
95+ $ this ->container ->get ('kernel ' )->terminate (Request::create ('/ ' ), new Response ());
96+ $ this ->assertLogsContains ('Entity Translation, action delete, revalidated 0. ' );
8497
8598 // Delete.
8699 $ page ->delete ();
87100 $ this ->container ->get ('kernel ' )->terminate (Request::create ('/ ' ), new Response ());
88- $ this ->assertLogsContains (" Entity A page updated, action delete, revalidated 0. " );
101+ $ this ->assertLogsContains (' Entity A page updated, action delete, revalidated 0. ' );
89102 // As hook_entity_predelete is used to perform revalidate
90103 // before delete action then it's ideal to check log after revalidate.
91- $ this ->assertLogsContains (" Event next.entity.action dispatched for entity A page updated and action delete. " );
104+ $ this ->assertLogsContains (' Event next.entity.action dispatched for entity A page updated and action delete. ' );
92105 }
93106
94107 /**
@@ -97,7 +110,7 @@ public function testEntityRevalidatedEvents() {
97110 * @param string $message
98111 * The message to assert in the logs.
99112 */
100- protected function assertLogsContains (string $ message ) {
113+ protected function assertLogsContains (string $ message ): void {
101114 $ logs = $ this ->container ->get ('database ' )
102115 ->select ('watchdog ' , 'wd ' )
103116 ->fields ('wd ' , ['message ' , 'variables ' ])
0 commit comments