-
Notifications
You must be signed in to change notification settings - Fork 49
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 #46 from ARCANEDEV/develop
Using the php-html package
- Loading branch information
Showing
15 changed files
with
184 additions
and
89 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
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
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,57 @@ | ||
<?php namespace Arcanedev\SeoHelper\Tests\Asserts; | ||
|
||
use DOMDocument; | ||
|
||
/** | ||
* Trait AssertsHtmlStrings | ||
* | ||
* @package Arcanedev\SeoHelper\Tests\Asserts | ||
* @author ARCANEDEV <[email protected]> | ||
*/ | ||
trait AssertsHtmlStrings | ||
{ | ||
/* ----------------------------------------------------------------- | ||
| Custom Assertions | ||
| ----------------------------------------------------------------- | ||
*/ | ||
|
||
/** | ||
* Assert two Html strings are equals. | ||
* | ||
* @param string $expected | ||
* @param string $actual | ||
* @param string $message | ||
*/ | ||
public static function assertHtmlStringEqualsHtmlString(string $expected, string $actual, string $message = '') | ||
{ | ||
static::assertEquals( | ||
static::convertToDomDocument($expected), | ||
static::convertToDomDocument($actual), | ||
$message, | ||
0.0, | ||
10, | ||
true | ||
); | ||
} | ||
|
||
/* ----------------------------------------------------------------- | ||
| Other Methods | ||
| ----------------------------------------------------------------- | ||
*/ | ||
|
||
/** | ||
* Convert string to DOMDocument. | ||
* | ||
* @param string $html | ||
* | ||
* @return \DOMDocument | ||
*/ | ||
protected static function convertToDomDocument($html) | ||
{ | ||
return tap(new DOMDocument, function (DOMDocument $dom) use ($html) { | ||
$dom->loadHTML(preg_replace('/>\s+</', '><', $html)); | ||
$dom->preserveWhiteSpace = false; | ||
}); | ||
} | ||
} | ||
|
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
Oops, something went wrong.