Skip to content

Commit 76fc30f

Browse files
authored
tv skip mask (#6)
* skip unsued mask * add mask unused * link
1 parent cbeb675 commit 76fc30f

File tree

7 files changed

+86
-6
lines changed

7 files changed

+86
-6
lines changed

.github/workflows/code_analysis.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ jobs:
1919
name: 'Composer Validate'
2020
run: composer validate --ansi
2121

22-
-
23-
name: 'Rector'
24-
run: composer rector --ansi
25-
2622
-
2723
name: 'Coding Standard'
2824
run: composer fix-cs --ansi

src/Analyzer/UnusedDefinitionsAnalyzer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
use Symfony\Component\Console\Style\SymfonyStyle;
1717
use Symfony\Component\Finder\SplFileInfo;
1818

19+
/**
20+
* @see \Rector\Behastan\Tests\Analyzer\UnusedDefinitionsAnalyzer\UnusedDefinitionsAnalyzerTest
21+
*/
1922
final readonly class UnusedDefinitionsAnalyzer
2023
{
2124
/**
@@ -43,7 +46,6 @@ public function analyse(array $contextFiles, array $featureFiles): array
4346
$this->maskCollectionStatsPrinter->printStats($maskCollection);
4447

4548
$featureInstructions = $this->usedInstructionResolver->resolveInstructionsFromFeatureFiles($featureFiles);
46-
4749
$maskProgressBar = $this->symfonyStyle->createProgressBar($maskCollection->count());
4850

4951
$unusedMasks = [];

src/DependencyInjection/ContainerFactory.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ public function create(): Container
5050
return $phpParserFactory->createForHostVersion();
5151
});
5252

53+
// silence in PHPUnit tests to keep output clear
54+
$consoleOutput = new ConsoleOutput();
55+
$consoleOutput->setVerbosity(
56+
defined('PHPUNIT_COMPOSER_INSTALL') ? ConsoleOutput::VERBOSITY_QUIET : ConsoleOutput::VERBOSITY_NORMAL
57+
);
58+
5359
$container->singleton(
5460
SymfonyStyle::class,
55-
static fn (): SymfonyStyle => new SymfonyStyle(new ArrayInput([]), new ConsoleOutput())
61+
static fn (): SymfonyStyle => new SymfonyStyle(new ArrayInput([]), $consoleOutput)
5662
);
5763

5864
return $container;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Behat\Behat\Context;
6+
7+
interface Context
8+
{
9+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Analyzer\UnusedDefinitionsAnalyzer\Fixture\Contexts;
4+
5+
use Behat\Behat\Context\Context;
6+
use Behat\Step\Given;
7+
use Behat\Step\When;
8+
9+
final class LoginContext implements Context
10+
{
11+
#[Given('I am on the login page')]
12+
public function iAmOnTheLoginPage(): void
13+
{
14+
// open login page
15+
}
16+
17+
#[When('I login as :username')]
18+
public function iLoginAs(string $username): void
19+
{
20+
// fill credentials and submit form
21+
}
22+
23+
#[When('The :username is logged in')]
24+
public function isLoggedIn(string $username): void
25+
{
26+
// fill credentials and submit form
27+
}
28+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Feature: User login
2+
Scenario: Successful login
3+
Given I am on the login page
4+
When I login as "Tomas"
5+
Then The "Tomas" is logged in
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Behastan\Tests\Analyzer\UnusedDefinitionsAnalyzer;
6+
7+
use Rector\Behastan\Analyzer\UnusedDefinitionsAnalyzer;
8+
use Rector\Behastan\Finder\BehatMetafilesFinder;
9+
use Rector\Behastan\Tests\AbstractTestCase;
10+
11+
final class UnusedDefinitionsAnalyzerTest extends AbstractTestCase
12+
{
13+
private UnusedDefinitionsAnalyzer $unusedDefinitionsAnalyzer;
14+
15+
protected function setUp(): void
16+
{
17+
parent::setUp();
18+
19+
$this->unusedDefinitionsAnalyzer = $this->make(UnusedDefinitionsAnalyzer::class);
20+
}
21+
22+
public function test(): void
23+
{
24+
$featureFiles = BehatMetafilesFinder::findFeatureFiles([__DIR__ . '/Fixture/Features']);
25+
$this->assertCount(1, $featureFiles);
26+
27+
$contextFiles = BehatMetafilesFinder::findContextFiles([__DIR__ . '/Fixture/Contexts']);
28+
$this->assertCount(1, $contextFiles);
29+
30+
$unusedDefinitions = $this->unusedDefinitionsAnalyzer->analyse($contextFiles, $featureFiles);
31+
32+
$this->assertCount(0, $unusedDefinitions);
33+
}
34+
}

0 commit comments

Comments
 (0)