From 4d84229a6d90e369af5507e40976cbd241ea5153 Mon Sep 17 00:00:00 2001 From: Jorrit Schippers Date: Fri, 24 Jul 2020 10:08:38 +0200 Subject: [PATCH] Set subject on admin instance when extracting translatable strings --- src/Translator/Extractor/AdminExtractor.php | 1 + tests/Translator/Extractor/AdminExtractorTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Translator/Extractor/AdminExtractor.php b/src/Translator/Extractor/AdminExtractor.php index 25f00c762d..5cfc245797 100644 --- a/src/Translator/Extractor/AdminExtractor.php +++ b/src/Translator/Extractor/AdminExtractor.php @@ -96,6 +96,7 @@ public function extract($resource, MessageCatalogue $catalogue) } $admin->setLabelTranslatorStrategy($this); + $admin->setSubject($admin->getNewInstance()); foreach (self::PUBLIC_ADMIN_METHODS as $method) { $admin->$method(); diff --git a/tests/Translator/Extractor/AdminExtractorTest.php b/tests/Translator/Extractor/AdminExtractorTest.php index fba8b4a314..5ca0de0a23 100644 --- a/tests/Translator/Extractor/AdminExtractorTest.php +++ b/tests/Translator/Extractor/AdminExtractorTest.php @@ -121,4 +121,18 @@ public function testExtractCallsBreadcrumbs(): void $this->adminExtractor->extract([], $catalogue); } + + public function testExtractSetsSubject(): void + { + $this->fooAdmin + ->expects($this->exactly(1)) + ->method('setSubject'); + $this->fooAdmin + ->expects($this->exactly(1)) + ->method('getNewInstance'); + + $catalogue = new MessageCatalogue('en'); + + $this->adminExtractor->extract([], $catalogue); + } }