Skip to content

Generic/InterfaceNameSuffix: improve code coverage #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
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