Skip to content

Commit

Permalink
Refactor and improve unit test examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrommen committed Jan 22, 2017
1 parent ef89139 commit 6abd5dc
Show file tree
Hide file tree
Showing 32 changed files with 1,973 additions and 567 deletions.
15 changes: 9 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
# General backup/log/swap files
# Backups
*~
*.DS_Store
*.log
*.out
*.so
*.swp

# Custom files
*.map
*.sass-cache*
# Logs
logs
*.log

# Composer
vendor
composer.lock

# Node
.npm
node_modules
npm-debug.log*

# PhpStorm
.idea

# PHPUnit
phpunit.xml

# This should stay at the bottom

# Git
!.gitkeep
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog

## 0.0.9

* Refactor and improve unit test examples.

## 0.0.1-alpha

* Initial commit.
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,33 @@ This repository contains example code for the according talk at WordCamp Nurembe

The first part of the talk is about unit testing. After a short summary, you can see several unit test examples. This repository includes the complete and fully documented versions of the presented [PHP unit tests](php/0-unit-test-examples) as well as the respective [JavaScript unit tests](js/0-unit-test-examples).

### Requirements
### Running the Tests

The PHP unit tests require PHP 5.4+, and [PHPUnit](https://phpunit.de/), [Mockery](https://github.com/padraic/mockery), [Brain Monkey](https://github.com/Brain-WP/BrainMonkey) and [WP_Mock](https://github.com/10up/wp_mock). If you have [Composer](https://getcomposer.org/) installed, just execute `$ composer install`, and you're good to go.
You want to run the tests yourself? Here's how:

The JavaScript unit tests require [tape](https://github.com/substack/tape) and [Sinon.JS](http://sinonjs.org/). With [npm](https://www.npmjs.com/) installed, `$ npm install` gets you started already.
#### JavaScript

In order to run the JavaScript tests, you have to install the required [npm](https://www.npmjs.com/) packages first.

Using [Yarn](https://www.npmjs.com/package/yarn):

```shell
$ yarn && yarn run test
```

Using [npm](https://www.npmjs.com/package/npm):

```shell
$ npm i && npm run test
```

#### PHP

In order to run the PHP tests, you have to install the required [Composer](https://getcomposer.org/) packages first.

```shell
$ composer install && vendor/bin/phpunit
```

## Bad Practices

Expand All @@ -23,3 +45,9 @@ Feel free to [fork this repository](https://github.com/tfrommen/testable-code/fo
## Changelog

[Changelog](CHANGELOG.md).

## License

Copyright (c) 2016 Thorsten Frommen

This code is licensed under the [MIT License](LICENSE).
32 changes: 18 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
"description": "Example code for the talk \"How (Not) to Write Testable Code\" at WordCamp Nuremberg, 2016.",
"keywords": [
"code",
"es6",
"javascript",
"mockery",
"php",
"phpunit",
"sinon",
"tape",
"testable",
"testing"
"testing",
"unit"
],
"homepage": "https://github.com/tfrommen/testable-code",
"license": "MIT",
"authors": [
{
"name": "Thorsten Frommen",
"email": "info@tfrommen.de",
"homepage": "http://tfrommen.de",
"homepage": "https://tfrommen.de",
"role": "Developer"
}
],
Expand All @@ -30,20 +32,22 @@
"php": ">=5.4.0"
},
"require-dev": {
"php": ">=5.4.0",
"10up/wp_mock": "dev-master",
"brain/monkey": "~1.3",
"mockery/mockery": "~0.9",
"antecedent/patchwork": "1.3.*",
"brain/monkey": "^1.4.0",
"mockery/mockery": "^0.9.7",
"phpunit/phpunit": "~4.8|~5.1"
},
"config": {
"platform": {
"php": "5.4.0"
}
"autoload": {
"classmap": [
"php/0-unit-test-examples/src"
],
"file": [
"vendor/antecedent/patchwork/Patchwork.php"
]
},
"extra": {
"branch-alias": {
"dev-master": "0.0.x-dev"
}
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"optimize-autoloader": true
}
}
Loading

0 comments on commit 6abd5dc

Please sign in to comment.