Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
run: composer validate --strict --no-check-lock
- name: Install Composer dependencies (with dev)
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: PHP CodeSniffer
run: composer phpcs
- name: PHPUnit
run: composer test
- name: Install Composer dependencies (without dev)
Expand Down
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,24 @@
"Imponeer\\Decorators\\LogDataOutput\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Imponeer\\Decorators\\LogDataOutput\\Tests\\": "tests/"
}
},
"keywords": [
"symfony",
"console",
"output",
"decorator"
],
"require-dev": {
"phpunit/phpunit": "^12"
"phpunit/phpunit": "^12",
"squizlabs/php_codesniffer": "^3.10"
},
"scripts": {
"test": "phpunit --testdox"
"test": "phpunit --testdox",
"phpcs": "phpcs --standard=PSR12 src/ tests/",
"phpcbf": "phpcbf --standard=PSR12 src/ tests/"
}
}
5 changes: 3 additions & 2 deletions src/OutputDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public function fatal(string $message, ...$params): void
*
* @return string
*/
public function renderIndentString(): string {
public function renderIndentString(): string
{
return str_repeat(' ', $this->indent * 2);
}

Expand Down Expand Up @@ -224,4 +225,4 @@ public function getFormatter(): OutputFormatterInterface
{
return $this->output->getFormatter();
}
}
}
17 changes: 11 additions & 6 deletions tests/OutputDecoratorTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Imponeer\Decorators\LogDataOutput\Tests;

use Imponeer\Decorators\LogDataOutput\OutputDecorator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
Expand All @@ -18,7 +20,8 @@ protected function setUp(): void
parent::setUp();
}

public static function getTestData(): array {
public static function getTestData(): array
{
return [
'writeln (simple)' => [
'writeln',
Expand Down Expand Up @@ -87,7 +90,8 @@ public static function getTestData(): array {
];
}

private function useDecoratorMethod(string $method, string $text, array $params): string {
private function useDecoratorMethod(string $method, string $text, array $params): string
{
if (empty($params)) {
$this->decorator->$method($text);
} else {
Expand All @@ -99,7 +103,8 @@ private function useDecoratorMethod(string $method, string $text, array $params)
}

#[DataProvider('getTestData')]
public function testIncrIndent(string $method, string $text, array $args = [], ?string $shouldReturn = null): void {
public function testIncrIndent(string $method, string $text, array $args = [], ?string $shouldReturn = null): void
{
if ($shouldReturn === null) {
$shouldReturn = $text;
}
Expand Down Expand Up @@ -136,7 +141,8 @@ public function testDecrIndent(string $method, string $text, array $args = [], ?
}

#[DataProvider('getTestData')]
public function testResetIncr(string $method, string $text, array $args = [], ?string $shouldReturn = null): void {
public function testResetIncr(string $method, string $text, array $args = [], ?string $shouldReturn = null): void
{
if ($shouldReturn === null) {
$shouldReturn = $text;
}
Expand All @@ -152,5 +158,4 @@ public function testResetIncr(string $method, string $text, array $args = [], ?s
$buffer = $this->useDecoratorMethod($method, $text, $args);
$this->assertSame($shouldReturn . PHP_EOL, $buffer);
}

}
}