author_url = 'https://joe.bloggs/'; $this->assertEquals('https://joe.bloggs', $like->author_url); } /** @test */ public function weDoNotModifyPlainTextContent(): void { $like = new Like(); $like->url = 'https://example.org/post/123'; $like->content = 'some plaintext content'; $like->save(); $this->assertEquals('some plaintext content', $like->content); } /** @test */ public function weCanHandleBlankContent(): void { $like = new Like(); $like->url = 'https://example.org/post/123'; $like->content = null; $like->save(); $this->assertNull($like->content); } /** @test */ public function htmlLikeContentIsFiltered(): void { $htmlEvil = <<

Hello

HTML; $htmlFiltered = <<Hello

HTML; $like = new Like(); $like->url = 'https://example.org/post/123'; $like->content = $htmlEvil; $like->save(); // HTMLPurifier will leave the whitespace before the tag // trim it, saving whitespace in $htmlFiltered can get removed by text editors $this->assertEquals($htmlFiltered, trim($like->content)); } }