@@ -6,37 +6,37 @@ |
||
| 6 | 6 | |
| 7 | 7 | class StringContainsIgnoringWhiteSpace extends SubstringMatcher { |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * Matches if value is a string that contains $substring consider all whitespace as single space |
|
| 11 | - * |
|
| 12 | - * @param string $substring |
|
| 13 | - * |
|
| 14 | - * @return self |
|
| 15 | - */ |
|
| 16 | - public static function containsStringIgnoringWhiteSpace( $substring ) { |
|
| 17 | - return new self( $substring ); |
|
| 18 | - } |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * @param string $item |
|
| 22 | - * |
|
| 23 | - * @return bool |
|
| 24 | - */ |
|
| 25 | - protected function evalSubstringOf( $item ) { |
|
| 26 | - return strpos( $this->stripSpace( $item ), $this->stripSpace( $this->_substring ) ) !== false; |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - protected function relationship() { |
|
| 30 | - return 'containing ignoring whitespace'; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @param string $string |
|
| 35 | - * |
|
| 36 | - * @return string |
|
| 37 | - */ |
|
| 38 | - private function stripSpace( $string ) { |
|
| 39 | - return trim( preg_replace( '/\s+/', ' ', $string ) ); |
|
| 40 | - } |
|
| 9 | + /** |
|
| 10 | + * Matches if value is a string that contains $substring consider all whitespace as single space |
|
| 11 | + * |
|
| 12 | + * @param string $substring |
|
| 13 | + * |
|
| 14 | + * @return self |
|
| 15 | + */ |
|
| 16 | + public static function containsStringIgnoringWhiteSpace( $substring ) { |
|
| 17 | + return new self( $substring ); |
|
| 18 | + } |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * @param string $item |
|
| 22 | + * |
|
| 23 | + * @return bool |
|
| 24 | + */ |
|
| 25 | + protected function evalSubstringOf( $item ) { |
|
| 26 | + return strpos( $this->stripSpace( $item ), $this->stripSpace( $this->_substring ) ) !== false; |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + protected function relationship() { |
|
| 30 | + return 'containing ignoring whitespace'; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @param string $string |
|
| 35 | + * |
|
| 36 | + * @return string |
|
| 37 | + */ |
|
| 38 | + private function stripSpace( $string ) { |
|
| 39 | + return trim( preg_replace( '/\s+/', ' ', $string ) ); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | } |
@@ -3,100 +3,100 @@ |
||
| 3 | 3 | use Hamcrest\Matcher; |
| 4 | 4 | |
| 5 | 5 | if ( !function_exists( 'htmlPiece' ) ) { |
| 6 | - /** |
|
| 7 | - * @param Matcher|null $elementMatcher |
|
| 8 | - * |
|
| 9 | - * @return \WMDE\HamcrestHtml\HtmlMatcher |
|
| 10 | - */ |
|
| 11 | - function htmlPiece( Matcher $elementMatcher = null ) { |
|
| 12 | - return \WMDE\HamcrestHtml\HtmlMatcher::htmlPiece( $elementMatcher ); |
|
| 13 | - } |
|
| 6 | + /** |
|
| 7 | + * @param Matcher|null $elementMatcher |
|
| 8 | + * |
|
| 9 | + * @return \WMDE\HamcrestHtml\HtmlMatcher |
|
| 10 | + */ |
|
| 11 | + function htmlPiece( Matcher $elementMatcher = null ) { |
|
| 12 | + return \WMDE\HamcrestHtml\HtmlMatcher::htmlPiece( $elementMatcher ); |
|
| 13 | + } |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | if ( !function_exists( 'havingRootElement' ) ) { |
| 17 | - function havingRootElement( Matcher $matcher = null ) { |
|
| 18 | - return \WMDE\HamcrestHtml\RootElementMatcher::havingRootElement( $matcher ); |
|
| 19 | - } |
|
| 17 | + function havingRootElement( Matcher $matcher = null ) { |
|
| 18 | + return \WMDE\HamcrestHtml\RootElementMatcher::havingRootElement( $matcher ); |
|
| 19 | + } |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | if ( !function_exists( 'havingDirectChild' ) ) { |
| 23 | - function havingDirectChild( Matcher $elementMatcher = null ) { |
|
| 24 | - return \WMDE\HamcrestHtml\DirectChildElementMatcher::havingDirectChild( $elementMatcher ); |
|
| 25 | - } |
|
| 23 | + function havingDirectChild( Matcher $elementMatcher = null ) { |
|
| 24 | + return \WMDE\HamcrestHtml\DirectChildElementMatcher::havingDirectChild( $elementMatcher ); |
|
| 25 | + } |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | if ( !function_exists( 'havingChild' ) ) { |
| 29 | - function havingChild( Matcher $elementMatcher = null ) { |
|
| 30 | - return \WMDE\HamcrestHtml\ChildElementMatcher::havingChild( $elementMatcher ); |
|
| 31 | - } |
|
| 29 | + function havingChild( Matcher $elementMatcher = null ) { |
|
| 30 | + return \WMDE\HamcrestHtml\ChildElementMatcher::havingChild( $elementMatcher ); |
|
| 31 | + } |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | if ( !function_exists( 'withTagName' ) ) { |
| 35 | - /** |
|
| 36 | - * @param Matcher|string $tagName |
|
| 37 | - * |
|
| 38 | - * @return \WMDE\HamcrestHtml\TagNameMatcher |
|
| 39 | - */ |
|
| 40 | - function withTagName( $tagName ) { |
|
| 41 | - return \WMDE\HamcrestHtml\TagNameMatcher::withTagName( $tagName ); |
|
| 42 | - } |
|
| 35 | + /** |
|
| 36 | + * @param Matcher|string $tagName |
|
| 37 | + * |
|
| 38 | + * @return \WMDE\HamcrestHtml\TagNameMatcher |
|
| 39 | + */ |
|
| 40 | + function withTagName( $tagName ) { |
|
| 41 | + return \WMDE\HamcrestHtml\TagNameMatcher::withTagName( $tagName ); |
|
| 42 | + } |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | if ( !function_exists( 'withAttribute' ) ) { |
| 46 | - /** |
|
| 47 | - * @param Matcher|string $attributeName |
|
| 48 | - * |
|
| 49 | - * @return \WMDE\HamcrestHtml\AttributeMatcher |
|
| 50 | - */ |
|
| 51 | - function withAttribute( $attributeName ) { |
|
| 52 | - return \WMDE\HamcrestHtml\AttributeMatcher::withAttribute( $attributeName ); |
|
| 53 | - } |
|
| 46 | + /** |
|
| 47 | + * @param Matcher|string $attributeName |
|
| 48 | + * |
|
| 49 | + * @return \WMDE\HamcrestHtml\AttributeMatcher |
|
| 50 | + */ |
|
| 51 | + function withAttribute( $attributeName ) { |
|
| 52 | + return \WMDE\HamcrestHtml\AttributeMatcher::withAttribute( $attributeName ); |
|
| 53 | + } |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if ( !function_exists( 'withClass' ) ) { |
| 57 | - /** |
|
| 58 | - * @param Matcher|string $class |
|
| 59 | - * |
|
| 60 | - * @return \WMDE\HamcrestHtml\ClassMatcher |
|
| 61 | - */ |
|
| 62 | - function withClass( $class ) { |
|
| 63 | - // TODO don't allow to call with empty string |
|
| 57 | + /** |
|
| 58 | + * @param Matcher|string $class |
|
| 59 | + * |
|
| 60 | + * @return \WMDE\HamcrestHtml\ClassMatcher |
|
| 61 | + */ |
|
| 62 | + function withClass( $class ) { |
|
| 63 | + // TODO don't allow to call with empty string |
|
| 64 | 64 | |
| 65 | - return \WMDE\HamcrestHtml\ClassMatcher::withClass( $class ); |
|
| 66 | - } |
|
| 65 | + return \WMDE\HamcrestHtml\ClassMatcher::withClass( $class ); |
|
| 66 | + } |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | if ( !function_exists( 'havingTextContents' ) ) { |
| 70 | - /** |
|
| 71 | - * @param Matcher|string $text |
|
| 72 | - * |
|
| 73 | - * @return \WMDE\HamcrestHtml\TextContentsMatcher |
|
| 74 | - */ |
|
| 75 | - function havingTextContents( $text ) { |
|
| 76 | - return \WMDE\HamcrestHtml\TextContentsMatcher::havingTextContents( $text ); |
|
| 77 | - } |
|
| 70 | + /** |
|
| 71 | + * @param Matcher|string $text |
|
| 72 | + * |
|
| 73 | + * @return \WMDE\HamcrestHtml\TextContentsMatcher |
|
| 74 | + */ |
|
| 75 | + function havingTextContents( $text ) { |
|
| 76 | + return \WMDE\HamcrestHtml\TextContentsMatcher::havingTextContents( $text ); |
|
| 77 | + } |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | if ( !function_exists( 'tagMatchingOutline' ) ) { |
| 81 | - /** |
|
| 82 | - * @param string $htmlOutline |
|
| 83 | - * |
|
| 84 | - * @return \WMDE\HamcrestHtml\ComplexTagMatcher |
|
| 85 | - */ |
|
| 86 | - function tagMatchingOutline( $htmlOutline ) { |
|
| 87 | - return \WMDE\HamcrestHtml\ComplexTagMatcher::tagMatchingOutline( $htmlOutline ); |
|
| 88 | - } |
|
| 81 | + /** |
|
| 82 | + * @param string $htmlOutline |
|
| 83 | + * |
|
| 84 | + * @return \WMDE\HamcrestHtml\ComplexTagMatcher |
|
| 85 | + */ |
|
| 86 | + function tagMatchingOutline( $htmlOutline ) { |
|
| 87 | + return \WMDE\HamcrestHtml\ComplexTagMatcher::tagMatchingOutline( $htmlOutline ); |
|
| 88 | + } |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | if ( !function_exists( 'containsStringIgnoringWhiteSpace' ) ) { |
| 92 | - /** |
|
| 93 | - * @param string $substring |
|
| 94 | - * |
|
| 95 | - * @return \WMDE\HamcrestHtml\StringContainsIgnoringWhiteSpace |
|
| 96 | - */ |
|
| 97 | - function containsStringIgnoringWhiteSpace( $substring ) { |
|
| 98 | - return \WMDE\HamcrestHtml\StringContainsIgnoringWhiteSpace::containsStringIgnoringWhiteSpace( |
|
| 99 | - $substring |
|
| 100 | - ); |
|
| 101 | - } |
|
| 92 | + /** |
|
| 93 | + * @param string $substring |
|
| 94 | + * |
|
| 95 | + * @return \WMDE\HamcrestHtml\StringContainsIgnoringWhiteSpace |
|
| 96 | + */ |
|
| 97 | + function containsStringIgnoringWhiteSpace( $substring ) { |
|
| 98 | + return \WMDE\HamcrestHtml\StringContainsIgnoringWhiteSpace::containsStringIgnoringWhiteSpace( |
|
| 99 | + $substring |
|
| 100 | + ); |
|
| 101 | + } |
|
| 102 | 102 | } |