Browse Source

add simple case of Known markup

for #57
pull/60/head
Aaron Parecki 6 years ago
parent
commit
3ac38f9dbf
No known key found for this signature in database GPG Key ID: 276C2817346D6056
2 changed files with 31 additions and 2 deletions
  1. +16
    -2
      tests/SanitizeTest.php
  2. +15
    -0
      tests/data/sanitize.example/photo-with-dupe-name-alt

+ 16
- 2
tests/SanitizeTest.php View File

@ -177,8 +177,6 @@ class SanitizeTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$data = json_decode($body); $data = json_decode($body);
echo json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
$this->assertObjectNotHasAttribute('name', $data->data); $this->assertObjectNotHasAttribute('name', $data->data);
$this->assertEquals('http://target.example.com/photo.jpg', $data->data->photo[0]); $this->assertEquals('http://target.example.com/photo.jpg', $data->data->photo[0]);
$this->assertEquals('This is a photo post with an img tag inside the content.', $data->data->content->text); $this->assertEquals('This is a photo post with an img tag inside the content.', $data->data->content->text);
@ -224,6 +222,22 @@ class SanitizeTest extends PHPUnit_Framework_TestCase {
$body = $response->getContent(); $body = $response->getContent();
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$data = json_decode($body); $data = json_decode($body);
print_r($data);
$this->assertObjectHasAttribute('name', $data->data);
$this->assertEquals('Oh, how well they know me! 🥃', $data->data->name);
$this->assertObjectNotHasAttribute('content', $data->data);
$this->assertEquals('https://cleverdevil.io/file/5bf2fa91c3d4c592f9978200923cb56e/thumb.jpg', $data->data->photo[0]);
}
public function testPhotoWithDupeNameAndAlt() {
$url = 'http://sanitize.example/photo-with-dupe-name-alt';
$response = $this->parse(['url' => $url]);
$body = $response->getContent();
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($body);
echo json_encode($data->data, JSON_PRETTY_PRINT+JSON_UNESCAPED_SLASHES);
$this->assertObjectHasAttribute('name', $data->data); $this->assertObjectHasAttribute('name', $data->data);
$this->assertEquals('Oh, how well they know me! 🥃', $data->data->name); $this->assertEquals('Oh, how well they know me! 🥃', $data->data->name);

+ 15
- 0
tests/data/sanitize.example/photo-with-dupe-name-alt View File

@ -0,0 +1,15 @@
HTTP/1.1 200 OK
Server: Apache
Date: Wed, 09 Dec 2015 03:29:14 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
<html>
<head>
<title>Test</title>
</head>
<body class="h-entry">
<h2 class="p-name">Photo caption</h2>
<p class="e-content"><img class="u-photo" src="/photo.jpg" alt="Photo caption"></p>
</body>
</html>

Loading…
Cancel
Save