Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
feat : Configure php_unit_test_case_static_method_calls fixer to use …
Browse files Browse the repository at this point in the history
…this call type
  • Loading branch information
prisis committed Jan 7, 2019
1 parent 4d2da42 commit e53d8b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
3 changes: 3 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public function getRules(): array
'noise_remaining_usages' => false,
],
'no_superfluous_phpdoc_tags' => false,
'php_unit_test_case_static_method_calls' => [
'call_type' => 'this',
],
'fopen_flags' => false,
'fopen_flag_order' => false,
];
Expand Down
34 changes: 17 additions & 17 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ final class ConfigTest extends TestCase
{
public function testImplementsInterface(): void
{
self::assertInstanceOf(ConfigInterface::class, new Config());
$this->assertInstanceOf(ConfigInterface::class, new Config());
}

public function testValues(): void
{
$config = new Config();

self::assertSame('narrowspark', $config->getName());
$this->assertSame('narrowspark', $config->getName());
}

public function testHasPsr2Rules(): void
Expand Down Expand Up @@ -68,20 +68,20 @@ public function testIfAllRulesAreTested(): void
$rules = (new Config())->getRules();

foreach ($rules as $key => $value) {
self::assertTrue(isset($testRules[$key]), '[' . $key . '] Rule is missing.');
$this->assertTrue(isset($testRules[$key]), '[' . $key . '] Rule is missing.');
}

self::assertCount(\count($testRules), $rules);
$this->assertCount(\count($testRules), $rules);
}

public function testDoesNotHaveHeaderCommentFixerByDefault(): void
{
$rules = (new Config())->getRules();

self::assertArrayHasKey('header_comment', $rules);
self::assertFalse($rules['header_comment']);
self::assertTrue($rules['no_blank_lines_before_namespace']);
self::assertFalse($rules['single_blank_line_before_namespace']);
$this->assertArrayHasKey('header_comment', $rules);
$this->assertFalse($rules['header_comment']);
$this->assertTrue($rules['no_blank_lines_before_namespace']);
$this->assertFalse($rules['single_blank_line_before_namespace']);
}

public function testHasHeaderCommentFixerIfProvided(): void
Expand All @@ -90,17 +90,17 @@ public function testHasHeaderCommentFixerIfProvided(): void
$config = new Config($header);
$rules = $config->getRules();

self::assertArrayHasKey('header_comment', $rules);
$this->assertArrayHasKey('header_comment', $rules);

$expected = [
'comment_type' => 'PHPDoc',
'header' => $header,
'location' => 'after_declare_strict',
'separate' => 'both',
];
self::assertSame($expected, $rules['header_comment']);
self::assertTrue($rules['no_blank_lines_before_namespace']);
self::assertFalse($rules['single_blank_line_before_namespace']);
$this->assertSame($expected, $rules['header_comment']);
$this->assertTrue($rules['no_blank_lines_before_namespace']);
$this->assertFalse($rules['single_blank_line_before_namespace']);
}

public function testAllConfiguredRulesAreBuiltIn(): void
Expand All @@ -120,7 +120,7 @@ public function testAllConfiguredRulesAreBuiltIn(): void
\array_merge($this->builtInFixers(), $pedroTrollerRules)
);

self::assertEmpty($fixersNotBuiltIn, \sprintf(
$this->assertEmpty($fixersNotBuiltIn, \sprintf(
'Failed to assert that fixers for the rules "%s" are built in',
\implode('", "', $fixersNotBuiltIn)
));
Expand All @@ -140,13 +140,13 @@ public function testDoesNotHaveRulesEnabled(string $fixer, $reason): void
];

if ($fixer === 'array_syntax') {
self::assertNotSame(['syntax' => 'long'], $config->getRules()['array_syntax'], \sprintf(
$this->assertNotSame(['syntax' => 'long'], $config->getRules()['array_syntax'], \sprintf(
'Fixer "%s" should not be enabled, because "%s"',
$fixer,
$reason['long']
));
} else {
self::assertArraySubset($rule, $config->getRules(), true, \sprintf(
$this->assertArraySubset($rule, $config->getRules(), true, \sprintf(
'Fixer "%s" should not be enabled, because "%s"',
$fixer,
$reason
Expand Down Expand Up @@ -562,12 +562,12 @@ private function getSymfonyRules(): array
private function assertHasRules(array $expected, array $actual, string $set): void
{
foreach ($expected as $fixer => $isEnabled) {
self::assertArrayHasKey($fixer, $actual, \sprintf(
$this->assertArrayHasKey($fixer, $actual, \sprintf(
'Failed to assert that a rule for fixer "%s" (in set "%s") exists.,',
$fixer,
$set
));
self::assertSame($isEnabled, $actual[$fixer], \sprintf(
$this->assertSame($isEnabled, $actual[$fixer], \sprintf(
'Failed to assert that fixer "%s" (in set "%s") is %s.',
$fixer,
$set,
Expand Down

0 comments on commit e53d8b0

Please sign in to comment.