Skip to content

Commit

Permalink
Merge pull request #650 from rodrigoprimo/test-coverage-interface-nam…
Browse files Browse the repository at this point in the history
…e-suffix

Generic/InterfaceNameSuffix: improve code coverage
  • Loading branch information
jrfnl authored Oct 30, 2024
2 parents 960262c + 2b7a230 commit d02c686
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function process(File $phpcsFile, $stackPtr)
{
$interfaceName = $phpcsFile->getDeclarationName($stackPtr);
if ($interfaceName === null) {
// Live coding or parse error. Bow out.
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

interface SomeNameInterface {}

interface MissingInterfaceSuffix {} // Error.

interface CaseOfSuffixIsNotEnforced_interFACE {}

interface
/*comment*/
InterfaceAnotherInvalidName
extends
AnotherInterface, \Countable {} // Error.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// Intentional parse error (no interface name).
// This should be the only test in this file.
// Testing that the sniff is *not* triggered.

interface

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,21 @@ final class InterfaceNameSuffixUnitTest extends AbstractSniffUnitTest
* The key of the array should represent the line number and the value
* should represent the number of errors that should occur on that line.
*
* @param string $testFile The name of the test file.
*
* @return array<int, int>
*/
public function getErrorList()
public function getErrorList($testFile='')
{
return [8 => 1];
switch ($testFile) {
case 'InterfaceNameSuffixUnitTest.1.inc':
return [
5 => 1,
9 => 1,
];
default:
return [];
}

}//end getErrorList()

Expand Down

0 comments on commit d02c686

Please sign in to comment.