-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from Zegnat/plain-text-parsing
New algorithm for plain text values. Merging to release as an `-alpha` release.
- Loading branch information
Showing
4 changed files
with
121 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace Mf2\Parser\Test; | ||
|
||
class PlainTextTest extends \PHPUnit_Framework_TestCase { | ||
/** | ||
* @dataProvider aaronpkExpectations | ||
*/ | ||
public function testAaronpkExpectations($input, $pName, $eValue, $eHtml) { | ||
$parser = new \Mf2\Parser($input); | ||
$output = $parser->parse(); | ||
$entryProperties = $output['items'][0]['properties']; | ||
$this->assertEquals($pName, $entryProperties['name'][0]); | ||
$this->assertEquals($eValue, $entryProperties['content'][0]['value']); | ||
$this->assertEquals($eHtml, $entryProperties['content'][0]['html']); | ||
} | ||
|
||
public function aaronpkExpectations() { | ||
return array( | ||
1 => array( | ||
"<div class=\"h-entry\">\n <div class=\"e-content p-name\"><p>Hello World</p></div>\n</div>", | ||
"Hello World", | ||
"Hello World", | ||
"<p>Hello World</p>" | ||
), | ||
2 => array( | ||
"<div class=\"h-entry\">\n <div class=\"e-content p-name\"><p>Hello<br>World</p></div>\n</div>", | ||
"Hello\nWorld", | ||
"Hello\nWorld", | ||
"<p>Hello<br>World</p>" | ||
), | ||
3 => array( | ||
"<div class=\"h-entry\">\n <div class=\"e-content p-name\"><p>Hello<br>\nWorld</p></div>\n</div>", | ||
"Hello\nWorld", | ||
"Hello\nWorld", | ||
"<p>Hello<br>\nWorld</p>" | ||
), | ||
4 => array( | ||
"<div class=\"h-entry\">\n <div class=\"e-content p-name\">\n <p>Hello World</p>\n </div>\n</div>", | ||
"Hello World", | ||
"Hello World", | ||
"<p>Hello World</p>" | ||
), | ||
5 => array( | ||
"<div class=\"h-entry\">\n <div class=\"e-content p-name\">Hello\nWorld</div>\n</div>", | ||
"Hello World", | ||
"Hello World", | ||
"Hello\nWorld" | ||
), | ||
6 => array( | ||
"<div class=\"h-entry\">\n <div class=\"e-content p-name\"><p>Hello</p><p>World</p></div>\n</div>", | ||
"Hello\nWorld", | ||
"Hello\nWorld", | ||
"<p>Hello</p><p>World</p>" | ||
), | ||
7 => array( | ||
"<div class=\"h-entry\">\n <div class=\"e-content p-name\">Hello<br>\n World</div>\n</div>", | ||
"Hello\nWorld", | ||
"Hello\nWorld", | ||
"Hello<br>\n World", | ||
), | ||
8 => array( | ||
"<div class=\"h-entry\">\n <div class=\"e-content p-name\"><br>Hello<br>World<br></div>\n</div>", | ||
"Hello\nWorld", | ||
"Hello\nWorld", | ||
"<br>Hello<br>World<br>" | ||
), | ||
9 => array( | ||
"<div class=\"h-entry\">\n <div class=\"e-content p-name\">\n <p>One</p>\n <p>Two</p>\n <p>Three</p>\n </div>\n</div>", | ||
"One\nTwo\nThree", | ||
"One\nTwo\nThree", | ||
"<p>One</p>\n <p>Two</p>\n <p>Three</p>" | ||
) | ||
); | ||
} | ||
} |