Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegrunwell committed Jan 14, 2018
2 parents 3835ca9 + f40ed15 commit 004b169
Show file tree
Hide file tree
Showing 8 changed files with 336 additions and 1,520 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
composer.lock
tests/coverage
vendor
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ php:

sudo: false

env:
matrix:
- PREFER_LOWEST="--prefer-lowest --prefer-stable"
- PREFER_LOWEST=""

install:
- wget https://github.com/php-coveralls/php-coveralls/releases/download/v1.0.0/coveralls.phar
- chmod +x coveralls.phar
- composer install --no-interaction --prefer-dist
- composer update --no-interaction --prefer-dist $PREFER_LOWEST

script:
- mkdir -p build/logs
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.1.0] - 2018-01-14

* Added the `assertElementContains()`, `assertElementNotContains()`, `assertElementRegExp()`, and `assertElementNotRegExp()` assertions, for verifying the contents of elements that match the given DOM query ([#6]).
* Moved the `Tests` namespace into a development-only autoloader, to prevent them from potentially being included in projects using this library ([#7]).
* [Based on this article by Martin Hujer](https://blog.martinhujer.cz/17-tips-for-using-composer-efficiently/#tip-%236%3A-put-%60composer.lock%60-into-%60.gitignore%60-in-libraries), remove the `composer.lock` file from the library ([#8]).
* _Lower_ the minimum version of [zendframework/zend-dom](https://packagist.org/packages/zendframework/zend-dom) to 2.2.5 for maximum portability ([#9]).

## [1.0.0] - 2017-10-24

* Initial release of the PHPUnit Markup Assertions Composer package.


[Unreleased]: https://github.com/stevegrunwell/phpunit-markup-assertions/compare/master...develop
[1.1.0]: https://github.com/stevegrunwell/phpunit-markup-assertions/releases/tag/v1.1.0
[1.0.0]: https://github.com/stevegrunwell/phpunit-markup-assertions/releases/tag/v1.0.0
[#6]: https://github.com/stevegrunwell/phpunit-markup-assertions/issues/6
[#7]: https://github.com/stevegrunwell/phpunit-markup-assertions/issues/7
[#8]: https://github.com/stevegrunwell/phpunit-markup-assertions/issues/8
[#9]: https://github.com/stevegrunwell/phpunit-markup-assertions/issues/9
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ These are the assertions made available to PHPUnit via the `MarkupAssertionsTrai
* [`assertSelectorCount()`](#assertselectorcount)
* [`assertHasElementWithAttributes()`](#asserthaselementwithattributes)
* [`assertNotHasElementWithAttributes()`](#assertnothaselementwithattributes)
* [`assertElementContains()`](#assertelementcontains)
* [`assertElementNotContains()`](#assertelementnotcontains)
* [`assertElementRegExp()`](#assertelementregexp)
* [`assertElementNotRegExp()`](#assertelementnotregexp)

### assertContainsSelector()

Expand Down Expand Up @@ -205,3 +209,86 @@ Assert that an element with the given attributes does not exist in the given mar
<dt>(string) $message</dt>
<dd>A message to display if the assertion fails.</dd>
</dl>

### assertElementContains()

Assert that the element with the given selector contains a string.

<dl>
<dt>(string) $contents</dt>
<dd>The string to look for within the DOM node's contents.</dd>
<dt>(string) $selector</dt>
<dd>A query selector for the element to find.</dd>
<dt>(string) $output</dt>
<dd>The output that should contain the <code>$selector</code>.</dd>
<dt>(string) $message</dt>
<dd>A message to display if the assertion fails.</dd>
</dl>

#### Example

```php
public function testColumnShowsUserEmail()
{
$user = getUser();
$table = getTableMarkup();

$this->assertElementContains(
$user->email,
'td.email',
$table,
'The <td class="email"> should contain the user\'s email address.'
);
}
```

### assertElementNotContains()

Assert that the element with the given selector does not contain a string.

This method is the inverse of [`assertElementContains()`](#assertelementcontains).

<dl>
<dt>(string) $contents</dt>
<dd>The string to look for within the DOM node's contents.</dd>
<dt>(string) $selector</dt>
<dd>A query selector for the element to find.</dd>
<dt>(string) $output</dt>
<dd>The output that should contain the <code>$selector</code>.</dd>
<dt>(string) $message</dt>
<dd>A message to display if the assertion fails.</dd>
</dl>

### assertElementRegExp()

Assert that the element with the given selector contains a string.

This method works just like [`assertElementContains()`](#assertelementcontains), but uses regular expressions instead of simple string matching.

<dl>
<dt>(string) $regexp</dt>
<dd>The regular expression pattern to look for within the DOM node.</dd>
<dt>(string) $selector</dt>
<dd>A query selector for the element to find.</dd>
<dt>(string) $output</dt>
<dd>The output that should contain the <code>$selector</code>.</dd>
<dt>(string) $message</dt>
<dd>A message to display if the assertion fails.</dd>
</dl>

### assertElementNotRegExp()

Assert that the element with the given selector does not contain a string.

This method is the inverse of [`assertElementRegExp()`](#assertelementregexp) and behaves like [`assertElementNotContains()`](#assertelementnotcontains) except with regular expressions instead of simple string matching.

<dl>
<dt>(string) $regexp</dt>
<dd>The regular expression pattern to look for within the DOM node.</dd>
<dt>(string) $selector</dt>
<dd>A query selector for the element to find.</dd>
<dt>(string) $output</dt>
<dd>The output that should contain the <code>$selector</code>.</dd>
<dt>(string) $message</dt>
<dd>A message to display if the assertion fails.</dd>
</dl>
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"source": "https://github.com/stevegrunwell/phpunit-markup-assertions/"
},
"require": {
"zendframework/zend-dom": "^2.6"
"zendframework/zend-dom": "^2.2.5"
},
"require-dev": {
"phpunit/phpunit": "^6.4"
"phpunit/phpunit": ">=6.0"
},
"scripts": {
"test-coverage": [
Expand All @@ -27,7 +27,11 @@
},
"autoload": {
"psr-4": {
"SteveGrunwell\\PHPUnit_Markup_Assertions\\": "src/",
"SteveGrunwell\\PHPUnit_Markup_Assertions\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
}
Expand Down
Loading

0 comments on commit 004b169

Please sign in to comment.