From ce6140c58269520b0401c53a739307f9c03598fb Mon Sep 17 00:00:00 2001 From: Tavo Nieves J Date: Thu, 27 Aug 2020 17:17:15 -0500 Subject: [PATCH] Updated docs for 1.4.x --- .gitignore | 1 + CHANGELOG.md | 14 +++++ README.md | 96 +++++++++----------------------- docs/supported_verifiers.md | 108 ++++++++++++++++++++++++++++++++++++ 4 files changed, 148 insertions(+), 71 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 docs/supported_verifiers.md diff --git a/.gitignore b/.gitignore index 285be54..87dc28f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ vendor .idea +.phpunit.result.cache composer.phar \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..cc310e8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog + +## 1.4 + +* Improved code quality and maintainability. +* Used strict types and namespaces. +Created exception `InvalidVerifyException.php` in case verify is used with some invalid data. +* Added documentation for all verifiers. +* Divided the verifiers into traits depending on the type of data they verify. +* Added data validations with php issers functions and instanceof. + +* **BC:** `equalXMLStructure` and its corresponding test were removed. +* **BC:** hasntKey verifier renamed to hasNotKey for clarity. +* **BC:** Removed support for PHP 7.0 and its corresponding versions of `PHPUnit` and `phpunit-wrapper`. \ No newline at end of file diff --git a/README.md b/README.md index 45fbb90..037bf2c 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,25 @@ Verify BDD Assertions for [PHPUnit][1] or [Codeception][2] +[![Latest Stable Version](https://poser.pugx.org/codeception/verify/v/stable)](https://packagist.org/packages/codeception/verify) +[![Total Downloads](https://poser.pugx.org/codeception/verify/downloads)](https://packagist.org/packages/codeception/verify) +[![Build Status](https://travis-ci.org/Codeception/Verify.png?branch=master)](https://travis-ci.org/Codeception/Verify) +[![License](https://poser.pugx.org/codeception/specify/license)](https://packagist.org/packages/codeception/verify) + This is very tiny wrapper for PHPUnit assertions, that are aimed to make tests a bit more readable. With [BDD][3] assertions influenced by [Chai][4], [Jasmine][5], and [RSpec][6] your assertions would be a bit closer to natural language. -[![Build Status](https://travis-ci.org/Codeception/Verify.png?branch=master)](https://travis-ci.org/Codeception/Verify) -[![Latest Stable Version](https://poser.pugx.org/codeception/verify/v/stable)](https://packagist.org/packages/codeception/verify) -[![Total Downloads](https://poser.pugx.org/codeception/verify/downloads)](https://packagist.org/packages/codeception/verify) +## Installation + +*Requires PHP 7.1 or higher* + +``` +composer require codeception/verify --dev +``` + +## Usage + +Use in any test `verify` function instead of `$this->assert*` methods: ```php $user = User::find(1); @@ -29,8 +42,6 @@ verify('first user rate is 7', $rate)->equals(7); verify($rate)->greaterThan(5); verify($rate)->lessThan(10); verify($rate)->lessOrEquals(7); -verify($rate)->lessOrEquals(8); -verify($rate)->greaterOrEquals(7); verify($rate)->greaterOrEquals(5); // true / false / null @@ -52,44 +63,14 @@ verify($callback)->throws(new Exception('message')); // does not throw verify($callback)->doesNotThrow(); -verify($callback)->doesNotThrow(Exception::class); -verify($callback)->doesNotThrow(Exception::class, 'exception message'); +verify($callback)->throws(Exception::class); verify($callback)->doesNotThrow(new Exception()); -verify($callback)->doesNotThrow(new Exception('exception message')); - -//Other methods: -* stringContainsString -* stringNotContainsString -* stringContainsStringIgnoringCase -* stringNotContainsStringIgnoringCase -* array -* bool -* float -* int -* numeric -* object -* resource -* string -* scalar -* callable -* notArray -* notBool -* notFloat -* notInt -* notNumeric -* notObject -* notResource -* notString -* notScalar -* notCallable -* equalsCanonicalizing -* notEqualsCanonicalizing -* equalsIgnoringCase -* notEqualsIgnoringCase -* equalsWithDelta -* notEqualsWithDelta + +// and many more ! ``` +> ##### :page_facing_up: See Verifiers full list [here.][7] + Shorthands for testing truth/fallacy: ```php @@ -97,7 +78,6 @@ verify_that($user->isActivated()); verify_not($user->isBanned()); ``` - These two functions don't check for strict true/false matching, rather `empty` function is used. `verify_that` checks that result is not empty value, `verify_not` does the opposite. @@ -111,34 +91,6 @@ expect_that($user->isActive()); expect_not($user->isBanned()); ``` -## Installation - -### Installing via Composer - -Install composer in a common location or in your project: - -```sh -curl -s http://getcomposer.org/installer | php -``` - -Create the `composer.json` file as follows: - -```json -"require-dev": { - "codeception/verify": "^1.0" -} -``` - -Run the composer installer: - -```sh -php composer.phar install -``` - -## Usage - -Use in any test `verify` function instead of `$this->assert*` methods. - ## Extending In order to add more assertions you can override `Codeception\Verify` class: @@ -165,7 +117,8 @@ verify('it works')->success(); ## License -Verify is open-sourced software licensed under the [MIT][7] License. © Codeception PHP Testing Framework +Verify is open-sourced software licensed under the [MIT][8] License. +© Codeception PHP Testing Framework [1]: https://phpunit.de/ [2]: http://codeception.com/ @@ -173,4 +126,5 @@ Verify is open-sourced software licensed under the [MIT][7] License. © Codecept [4]: http://chaijs.com/ [5]: http://jasmine.github.io/ [6]: http://rspec.info/ -[7]: https://github.com/Codeception/Verify/blob/master/LICENSE +[7]: /docs/supported_verifiers.md +[8]: /LICENSE diff --git a/docs/supported_verifiers.md b/docs/supported_verifiers.md new file mode 100644 index 0000000..7acb8fa --- /dev/null +++ b/docs/supported_verifiers.md @@ -0,0 +1,108 @@ +## Verifiers List + +### Array +``` +contains +containsOnly +containsOnlyInstancesOf +count +hasKey +hasNotKey +notContains +notContainsOnly +notCount +``` + +### File +``` +setIsFileExpectation +equals +notEquals +exists +notExists +equalsJsonFile +equalsXmlFile +``` + +### Mixed +``` +isEmpty +equalsCanonicalizing +equalsIgnoringCase +equalsWithDelta +false +greaterThan +greaterOrEquals +isInstanceOf +array +bool +callable +float +int +notArray +notBool +notCallable +notFloat +notInt +notNumeric +notObject +notResource +notScalar +notString +numeric +object +resource +scalar +string +lessThan +lessOrEquals +notEmpty +notEqualsCanonicalizing +notEqualsIgnoringCase +notEqualsWithDelta +isNotInstanceOf +notNull +notSame +null +same +true +``` + +### String +``` +hasStaticAttribute +notHasStaticAttribute +equalsJsonString +regExp +stringContainsString +stringContainsStringIgnoringCase +notEndsWith +endsWith +equalsFile +matchesFormat +matchesFormatFile +stringNotContainsString +stringNotContainsStringIgnoringCase +notMatchesFormat +notMatchesFormatFile +notStartsWith +startsWith +notEqualsFile +``` + +### Object/String +``` +hasAttribute +notHasAttribute +``` + +### Throwable +``` +throws +doesNotThrow +``` + +### Xml +``` +equalsXmlString +``` \ No newline at end of file