Skip to content

Commit 584335e

Browse files
🚨 Improve tests
1 parent b747e36 commit 584335e

7 files changed

+11
-10
lines changed

TwigCS/Tests/AbstractSniffTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace TwigCS\Tests;
44

55
use \Exception;
6+
use \ReflectionClass;
67
use PHPUnit\Framework\MockObject\MockObject;
78
use PHPUnit\Framework\TestCase;
89
use Twig\Loader\LoaderInterface;
@@ -43,16 +44,16 @@ public function setUp()
4344
}
4445

4546
/**
46-
* @param string $filename
4747
* @param SniffInterface $sniff
4848
* @param array $expects
4949
*/
50-
protected function checkGenericSniff($filename, SniffInterface $sniff, array $expects)
50+
protected function checkGenericSniff(SniffInterface $sniff, array $expects)
5151
{
52-
$file = __DIR__.'/Fixtures/'.$filename;
53-
5452
$ruleset = new Ruleset();
5553
try {
54+
$class = new ReflectionClass(get_called_class());
55+
$file = __DIR__.'/Fixtures/'.$class->getShortName().'.twig';
56+
5657
$ruleset->addSniff($sniff);
5758
$report = $this->lint->run($file, $ruleset);
5859
} catch (Exception $e) {

TwigCS/Tests/Sniff/BlankEOFTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
*/
1111
class BlankEOFTest extends AbstractSniffTest
1212
{
13-
public function testSniff1()
13+
public function testSniff()
1414
{
15-
$this->checkGenericSniff('blankEOF.twig', new BlankEOFSniff(), [
15+
$this->checkGenericSniff(new BlankEOFSniff(), [
1616
[4, 1],
1717
]);
1818
}

TwigCS/Tests/Sniff/DelimiterSpacingTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
*/
1111
class DelimiterSpacingTest extends AbstractSniffTest
1212
{
13-
public function testSniff1()
13+
public function testSniff()
1414
{
15-
$this->checkGenericSniff('delimiterSpacing.twig', new DelimiterSpacingSniff(), [
15+
$this->checkGenericSniff(new DelimiterSpacingSniff(), [
1616
[12, 1],
1717
[12, 12],
1818
[12, 15],

TwigCS/Tests/Sniff/ForbidCommentedCodeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
*/
1111
class ForbidCommentedCodeTest extends AbstractSniffTest
1212
{
13-
public function testSniff1()
13+
public function testSniff()
1414
{
15-
$this->checkGenericSniff('forbidCommentedCode.twig', new ForbidCommentedCodeSniff(), [
15+
$this->checkGenericSniff(new ForbidCommentedCodeSniff(), [
1616
[2, 5],
1717
]);
1818
}

0 commit comments

Comments
 (0)