Moved decode and updated page plaintext decode test

This commit is contained in:
Dan Brown 2020-09-19 15:13:18 +01:00
parent 44f3508171
commit 31eec34b5d
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
2 changed files with 4 additions and 4 deletions

View File

@ -25,7 +25,7 @@ class PageContent
public function setNewHTML(string $html) public function setNewHTML(string $html)
{ {
$this->page->html = $this->formatHtml($html); $this->page->html = $this->formatHtml($html);
$this->page->text = html_entity_decode($this->toPlainText()); $this->page->text = $this->toPlainText();
} }
/** /**
@ -108,7 +108,7 @@ class PageContent
protected function toPlainText(): string protected function toPlainText(): string
{ {
$html = $this->render(true); $html = $this->render(true);
return strip_tags($html); return html_entity_decode(strip_tags($html));
} }
/** /**

View File

@ -312,10 +312,10 @@ class PageContentTest extends TestCase
$this->actingAs($this->getAdmin()) $this->actingAs($this->getAdmin())
->put($page->getUrl(''), [ ->put($page->getUrl(''), [
'name' => 'Testing', 'name' => 'Testing',
'html' => '<p>Hello &amp; welcome</p>', 'html' => '<p>&quot;Hello &amp; welcome&quot;</p>',
]); ]);
$page->refresh(); $page->refresh();
$this->assertEquals('Hello & welcome', $page->text); $this->assertEquals('"Hello & welcome"', $page->text);
} }
} }