Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Commit

Permalink
Enhancement: Synchronize with ergebnis/php-library-template
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Jan 6, 2020
1 parent f0f4944 commit 723e7fa
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 101 deletions.
2 changes: 2 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ update_configs:
include_scope: true
prefix: "Build"
default_assignees:
- "ergebnis-bot"
- "localheinz"
default_labels:
- "dependency"
default_reviewers:
- "ergebnis-bot"
- "localheinz"
directory: "/"
package_manager: "php:composer"
Expand Down
14 changes: 6 additions & 8 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ branches:
required_approving_review_count: 1
required_status_checks:
contexts:
- "Coding Standards (7.1, locked)"
- "Coding Standards (7.2, locked)"
- "Dependency Analysis (7.4, locked)"
- "Static Code Analysis (7.4, locked)"
- "Tests (7.1, lowest)"
- "Tests (7.1, locked)"
- "Tests (7.1, highest)"
- "Tests (7.2, lowest)"
- "Tests (7.2, locked)"
- "Tests (7.2, highest)"
Expand All @@ -38,7 +35,8 @@ branches:
apps:
- "dependabot-preview"
teams: []
users: []
users:
- "ergebnis-bot"

# https://developer.github.com/v3/issues/labels/#create-a-label
# https://developer.github.com/v3/issues/labels/#update-a-label
Expand Down Expand Up @@ -75,15 +73,15 @@ repository:
allow_rebase_merge: false
allow_squash_merge: false
default_branch: "master"
description: ":eyeglasses: Provides utilities for tests."
description: ":octocat: + :ledger: Provides a GitHub repository template for a PHP library, using GitHub actions."
has_downloads: true
has_issues: true
has_pages: false
has_projects: false
has_wiki: false
name: "test-util"
name: "php-library-template"
private: false

# https://developer.github.com/v3/repos/branches/#remove-branch-protection

topics: "phpunit, phpunit-util, phpunit-assertions, faker"
topics: "php, library, template"
2 changes: 1 addition & 1 deletion .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: "Create release"
uses: "actions/create-release@v1.0.0"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
with:
draft: false
prerelease: false
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ jobs:
run: "mkdir -p .build/psalm"

- name: "Run vimeo/psalm"
run: "vendor/bin/psalm --config=psalm.xml --show-info=false"
run: "vendor/bin/psalm --config=psalm.xml --shepherd --show-info=false --stats"

tests:
name: "Tests"
Expand Down Expand Up @@ -353,8 +353,8 @@ jobs:
- "tests"

steps:
- name: "Approve"
- name: "Approve pull requests created by dependabot that update development dependencies"
uses: "hmarr/auto-approve-action@v2.0.0"
if: "(github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]') && github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, 'Build(deps-dev)')"
with:
github-token: "${{ secrets.AUTO_APPROVE_TOKEN }}"
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
days-before-close: 5
days-before-stale: 60
repo-token: "${{ secrets.GITHUB_TOKEN }}"
repo-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
stale-issue-label: 'stale'
stale-issue-message: >
This issue has been automatically marked as stale because it has not had
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan
mkdir -p .build/phpstan
vendor/bin/phpstan analyse --configuration=phpstan.neon
mkdir -p .build/psalm
vendor/bin/psalm --config=psalm.xml --show-info=false
vendor/bin/psalm --config=psalm.xml --show-info=false --stats

.PHONY: static-code-analysis-baseline
static-code-analysis-baseline: vendor ## Generates a baseline for static code analysis with phpstan/phpstan and vimeo/psalm
Expand Down
99 changes: 12 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,94 +1,25 @@
# test-util
# php-library-template

[![Continuous Integration](https://github.com/ergebnis/test-util/workflows/Continuous%20Integration/badge.svg)](https://github.com/ergebnis/test-util/actions)
[![Code Coverage](https://codecov.io/gh/ergebnis/test-util/branch/master/graph/badge.svg)](https://codecov.io/gh/ergebnis/test-util)
[![Latest Stable Version](https://poser.pugx.org/ergebnis/test-util/v/stable)](https://packagist.org/packages/ergebnis/test-util)
[![Total Downloads](https://poser.pugx.org/ergebnis/test-util/downloads)](https://packagist.org/packages/ergebnis/test-util)

Provides utilities for tests.
[![Continuous Deployment](https://github.com/ergebnis/php-library-template/workflows/Continuous%20Deployment/badge.svg)](https://github.com/ergebnis/php-library-template/actions)
[![Continuous Integration](https://github.com/ergebnis/php-library-template/workflows/Continuous%20Integration/badge.svg)](https://github.com/ergebnis/php-library-template/actions)
[![Code Coverage](https://codecov.io/gh/ergebnis/php-library-template/branch/master/graph/badge.svg)](https://codecov.io/gh/ergebnis/php-library-template)
[![Type Coverage](https://shepherd.dev/github/ergebnis/php-library-template/coverage.svg)](https://shepherd.dev/github/ergebnis/php-library-template)
[![Latest Stable Version](https://poser.pugx.org/ergebnis/php-library-template/v/stable)](https://packagist.org/packages/ergebnis/php-library-template)
[![Total Downloads](https://poser.pugx.org/ergebnis/php-library-template/downloads)](https://packagist.org/packages/ergebnis/php-library-template)

## Installation

:bulb: This is a great place for showing how to install the package, see below:

Run

```
$ composer require --dev ergebnis/test-util
$ composer require ergebnis/php-library-template
```

## Usage

Import the `Ergebnis\Test\Util\Helper` trait into your test class:

```php
<?php

declare(strict_types=1);

namespace Foo\Bar\Test\Unit;

use Ergebnis\Test\Util\Helper;
use PHPUnit\Framework;

final class BazTest extends Framework\TestCase
{
use Helper;
}
```

### Easy access to localized instances of `Faker\Generator`

The `Helper` trait provides a method to fetch a localized instance of `Faker\Generator`:

* `faker(string $locale = 'en_US') : \Faker\Generator`

```php
<?php

declare(strict_types=1);

namespace Example\Test\Unit;

use Ergebnis\Test\Util\Helper;
use Example\Player;
use PHPUnit\Framework;

final class PlayerTest extends Framework\TestCase
{
use Helper;

public function testConstructorSetsValues(): void
{
$name = self::faker()->firstName;

$player = new Player($name);

$this->assertSame($name, $player->firstName());
}
}
```

For reference, see [`fzaninotto/faker`](https://github.com/fzaninotto/Faker).

### Additional Assertions

In addition to the assertions made available by extending from `PHPUnit\Framework\TestCase`,
the `Helper` trait provides the following assertions:

* `assertClassesAreAbstractOrFinal(string $directory, array $excludeClassNames = [])`
* `assertClassesHaveTests(string $directory, string $namespace, string $testNamespace, array $excludeClassyNames = [])`
* `assertClassExists(string $className)`
* `assertClassExtends(string $parentClassName, string $className)`
* `assertClassImplementsInterface(string $interfaceName, string $className)`
* `assertClassIsAbstract(string $className)`
* `assertClassIsFinal(string $className)`
* `assertClassSatisfiesSpecification(callable $specification, string $className, string $message = '')`
* `assertClassUsesTrait(string $traitName, string $className)`
* `assertClassyConstructsSatisfySpecification(callable $specification, string $directory, array $excludeClassNames = [], $message = '')`
* `assertInterfaceExists(string $interfaceName)`
* `assertInterfaceExtends(string $parentInterfaceName, string $interfaceName)`
* `assertInterfaceSatisfiesSpecification(callable $specification, string $interfaceName, string $message = '')`
* `assertTraitExists(string $traitName)`
* `assertTraitSatisfiesSpecification(callable $specification, string $traitName, string $message = '')`
:bulb: This is a great place for showing a few usage examples!

## Changelog

Expand All @@ -100,14 +31,8 @@ Please have a look at [`CONTRIBUTING.md`](.github/CONTRIBUTING.md).

## Code of Conduct

Please have a look at [`CODE_OF_CONDUCT.md`](https://github.com/ergebnis/.github/blob/master/CODE_OF_CONDUCT.md).
Please have a look at [`CODE_OF_CONDUCT.md`](.github/CODE_OF_CONDUCT.md).

## License

This package is licensed using the MIT License.

## Credits

The [`SrcCodeTest`](test/AutoReview/SrcCodeTest.php) in this and other
projects I maintain or contribute to is inspired by [`ProjectCodeTest`](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.0.0/tests/ProjectCodeTest.php)
in [`friends-of-php/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer), and was initially created by [Dariusz Rumiński](https://github.com/keradus).

0 comments on commit 723e7fa

Please sign in to comment.