-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize project with jeromegamez/cookiecutter-php
- Loading branch information
0 parents
commit 81f0c65
Showing
13 changed files
with
308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[**.{neon,neon.dist}] | ||
indent_style = tab | ||
|
||
[**.{yml,yaml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*.php diff=php | ||
|
||
/.build export-ignore | ||
/.github export-ignore | ||
/tests export-ignore | ||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.php-cs-fixer.dist.php export-ignore | ||
/phpstan.neon.dist export-ignore | ||
/phpunit.xml.dist export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
tests: | ||
name: PHP ${{ matrix.php }} | ||
runs-on: ubuntu-20.04 | ||
|
||
strategy: | ||
matrix: | ||
php: | ||
- "8.1" | ||
dependencies: | ||
- "lowest" | ||
- "highest" | ||
|
||
env: | ||
extensions: ctype, dom, intl, json, mbstring, openssl, xml, zip, zlib | ||
key: cache-v1 # can be any string, change to clear the extension cache. | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup cache environment | ||
id: extcache | ||
uses: shivammathur/cache-extensions@v1 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: ${{ env.extensions }} | ||
key: ${{ env.key }} | ||
|
||
- name: Cache extensions | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.extcache.outputs.dir }} | ||
key: ${{ steps.extcache.outputs.key }} | ||
restore-keys: ${{ steps.extcache.outputs.key }} | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: ${{ env.extensions }} | ||
tools: composer, pecl | ||
coverage: xdebug | ||
env: | ||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: "ramsey/composer-install@v1" | ||
with: | ||
dependency-versions: "${{ matrix.dependencies }}" | ||
composer-options: "${{ matrix.composer-options }}" | ||
|
||
- name: Setup problem matchers for PHP | ||
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" | ||
|
||
- name: Run PHPStan | ||
run: vendor/bin/phpstan analyse | ||
|
||
- name: Setup Problem Matchers for PHPUnit | ||
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | ||
|
||
- name: Run PHPUnit | ||
run: vendor/bin/phpunit --testdox --coverage-text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/.build | ||
/tools | ||
/vendor | ||
|
||
/.php-cs-fixer.php | ||
/.phpunit.result.cache | ||
/.phpunit.xml | ||
|
||
/composer.lock | ||
/phpstan.neon | ||
/phpunit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
/** @noinspection TransitiveDependenciesUsageInspection */ | ||
/** @noinspection DevelopmentDependenciesUsageInspection */ | ||
|
||
use Ergebnis\PhpCsFixer\Config\Factory; | ||
use Beste\PhpCsFixer\Config\RuleSet\Php81; | ||
|
||
$config = Factory::fromRuleSet(new Php81()); | ||
|
||
$config->getFinder()->in(__DIR__); | ||
|
||
$config->setCacheFile(__DIR__ . '/.build/.php-cs-fixer.cache'); | ||
|
||
return $config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# CHANGELOG | ||
|
||
## [Unreleased] | ||
|
||
<!-- | ||
[Unreleased]: https://github.com/beste/psr-testlogger/compare/1.0.0...main | ||
[1.0.0]: https://github.com/beste/psr-testlogger/tree/1.0.0 | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Jérôme Gamez, https://github.com/beste <jerome@gamez.name> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# PSR Test Logger | ||
|
||
PSR-3 compliant test logger for developers who like tests and want to check if their application logs messages as they expect. | ||
|
||
## Installation | ||
|
||
```shell | ||
composer require beste/psr-testlogger | ||
``` | ||
|
||
## Running tests | ||
|
||
```shell | ||
composer run tests | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"name": "beste/psr-testlogger", | ||
"description": "PSR-3 compliant test logger for developers who like tests and want to check if their application logs messages as they expect.", | ||
"keywords": ["psr", "psr-3", "log", "test", "tests", "phpunit"], | ||
"license": "MIT", | ||
"type": "library", | ||
"authors": [ | ||
{ | ||
"name": "Jérôme Gamez", | ||
"email": "jerome@gamez.name" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.1" | ||
}, | ||
"require-dev": { | ||
"phpstan/extension-installer": "^1.1", | ||
"phpstan/phpstan": "^1.8.2", | ||
"phpstan/phpstan-deprecation-rules": "^1.0", | ||
"phpstan/phpstan-phpunit": "^1.1.1", | ||
"phpstan/phpstan-strict-rules": "^1.4", | ||
"phpunit/phpunit": "^9.5.23" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Beste\\Psr\\Log\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Beste\\Psr\\Log\\Tests\\": "tests" | ||
} | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"phpstan/extension-installer": true | ||
}, | ||
"sort-packages": true | ||
}, | ||
"scripts": { | ||
"cs": "tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --diff --verbose", | ||
"install-dev-tools": [ | ||
"mkdir --parents .build", | ||
"@install-php-cs-fixer" | ||
], | ||
"install-php-cs-fixer": [ | ||
"mkdir --parents tools/php-cs-fixer", | ||
"composer require --working-dir=tools/php-cs-fixer beste/php-cs-fixer-config" | ||
], | ||
"phpstan": "vendor/bin/phpstan analyse", | ||
"phpunit": "vendor/bin/phpunit", | ||
"test": [ | ||
"@phpstan", | ||
"@phpunit" | ||
] | ||
}, | ||
"scripts-descriptions": { | ||
"cs": "Applies coding standards", | ||
"phpstan": "Runs static analysis with PHPStan", | ||
"phpunit": "Runs tests with PHPUnit", | ||
"test": "Runs static analysis and test suites" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
parameters: | ||
level: max | ||
|
||
paths: | ||
- src/ | ||
- tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
cacheResultFile=".build/.phpunit.result.cache" | ||
colors="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Tests"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
</include> | ||
</coverage> | ||
|
||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Beste\Psr\Log; | ||
|
||
final class Placeholder | ||
{ | ||
private string $prefix; | ||
|
||
public function __construct(string $prefix) | ||
{ | ||
$this->prefix = $prefix; | ||
} | ||
|
||
public function echo(string $value): string | ||
{ | ||
return $this->prefix . $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Beste\Psr\Log\Tests; | ||
|
||
use Beste\Psr\Log\Placeholder; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @internal | ||
* @covers \Beste\Psr\Log\Placeholder | ||
*/ | ||
final class PlaceholderTest extends TestCase | ||
{ | ||
private Placeholder $placeholder; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->placeholder = new Placeholder('Jérôme Gamez says: '); | ||
} | ||
|
||
public function testItEchoesAValue(): void | ||
{ | ||
self::assertSame('Jérôme Gamez says: Hello', $this->placeholder->echo('Hello')); | ||
} | ||
} |