Skip to content

Commit

Permalink
Updated docs for 1.4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
TavoNiievez committed Aug 27, 2020
1 parent 6258e89 commit ce6140c
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 71 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor
.idea
.phpunit.result.cache
composer.phar
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`.
96 changes: 25 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -52,52 +63,21 @@ 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
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.

Expand All @@ -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:
Expand All @@ -165,12 +117,14 @@ 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/
[3]: https://en.wikipedia.org/wiki/Behavior-driven_development
[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
108 changes: 108 additions & 0 deletions docs/supported_verifiers.md
Original file line number Diff line number Diff line change
@@ -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
```

0 comments on commit ce6140c

Please sign in to comment.