Skip to content

Commit

Permalink
Improve code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lkrms committed Jan 7, 2025
1 parent d22210e commit a68e157
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/Rule/HangingIndentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function getPriority(string $method): ?int
}

/**
* @inheritDoc
* @codeCoverageIgnore
*/
public static function needsSortedTokens(): bool
{
Expand Down Expand Up @@ -358,7 +358,6 @@ public function processTokens(array $tokens): void
// context, followed by the precedence value added previously
// - the token added to the last context, followed by the
// precedence value added previously (if present)
// - `$lastToken` if no token was added to the last context
if (
TokenUtil::OPERATOR_PRECEDENCE_INDEX[$trigger->id]
&& ($precedence = TokenUtil::getOperatorPrecedence($trigger)) < 99
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/StandardIndentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function getPriority(string $method): ?int
}

/**
* @inheritDoc
* @codeCoverageIgnore
*/
public static function needsSortedTokens(): bool
{
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/Rule/HangingIndentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Lkrms\PrettyPHP\Tests\Rule;

use Lkrms\PrettyPHP\Catalog\FormatterFlag;
use Lkrms\PrettyPHP\Rule\AlignChains;
use Lkrms\PrettyPHP\Tests\TestCase;
use Lkrms\PrettyPHP\Formatter;
Expand All @@ -25,7 +26,8 @@ public function testOutput(string $expected, string $code, $formatter): void
*/
public static function outputProvider(): array
{
$formatterB = Formatter::build();
$formatterB = Formatter::build()
->flags(FormatterFlag::DETECT_PROBLEMS);
$formatter = $formatterB->build();
$withAlignChains = $formatterB
->enable([AlignChains::class])
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Lkrms\PrettyPHP\Tests;

use Lkrms\PrettyPHP\Catalog\FormatterFlag;
use Lkrms\PrettyPHP\Contract\Extension;
use Lkrms\PrettyPHP\Contract\HasTokenNames;
use Lkrms\PrettyPHP\Formatter;
Expand Down Expand Up @@ -43,14 +44,16 @@ public static function assertFormatterOutputIs(string $expected, string $code, $
* @param array<class-string<Extension>> $enable
* @param array<class-string<Extension>> $disable
* @param 2|4|8 $tabSize
* @param int-mask-of<FormatterFlag::*> $flags
*/
public static function assertCodeFormatIs(
string $expected,
string $code,
array $enable = [],
array $disable = [],
bool $insertSpaces = true,
int $tabSize = 4
int $tabSize = 4,
int $flags = FormatterFlag::DETECT_PROBLEMS
): void {
self::assertFormatterOutputIs(
$expected,
Expand All @@ -60,6 +63,7 @@ public static function assertCodeFormatIs(
->tabSize($tabSize)
->enable($enable)
->disable($disable)
->flags($flags)
);
}

Expand Down

0 comments on commit a68e157

Please sign in to comment.