Skip to content

Commit

Permalink
Initialize project with jeromegamez/cookiecutter-php
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Sep 23, 2022
0 parents commit 81f0c65
Show file tree
Hide file tree
Showing 13 changed files with 308 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
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
11 changes: 11 additions & 0 deletions .gitattributes
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
70 changes: 70 additions & 0 deletions .github/workflows/tests.yml
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
11 changes: 11 additions & 0 deletions .gitignore
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
15 changes: 15 additions & 0 deletions .php-cs-fixer.dist.php
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;
8 changes: 8 additions & 0 deletions CHANGELOG.md
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
-->
21 changes: 21 additions & 0 deletions LICENSE
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.
15 changes: 15 additions & 0 deletions README.md
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
```
63 changes: 63 additions & 0 deletions composer.json
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"
}
}
6 changes: 6 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
level: max

paths:
- src/
- tests/
20 changes: 20 additions & 0 deletions phpunit.xml.dist
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>
20 changes: 20 additions & 0 deletions src/Placeholder.php
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;
}
}
27 changes: 27 additions & 0 deletions tests/PlaceholderTest.php
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'));
}
}

0 comments on commit 81f0c65

Please sign in to comment.