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

Set subject on admin instance when extracting translatable strings #6224

Merged
merged 1 commit into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Translator/Extractor/AdminExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 14 additions & 0 deletions tests/Translator/Extractor/AdminExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,18 @@ public function testExtractCallsBreadcrumbs(): void

$this->adminExtractor->extract([], $catalogue);
}

public function testExtractSetsSubject(): void
Copy link
Member

Choose a reason for hiding this comment

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

I saw this test and I thought that was the requested one @jorrit . Should we revert?

Copy link
Member

Choose a reason for hiding this comment

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

No, don't worry, I added one in #6237

{
$this->fooAdmin
->expects($this->exactly(1))
->method('setSubject');
$this->fooAdmin
->expects($this->exactly(1))
->method('getNewInstance');

$catalogue = new MessageCatalogue('en');

$this->adminExtractor->extract([], $catalogue);
}
}