Skip to content

Commit 3c39c20

Browse files
committed
add mask unused
1 parent 38f1b79 commit 3c39c20

File tree

5 files changed

+48
-7
lines changed

5 files changed

+48
-7
lines changed

src/Analyzer/UnusedDefinitionsAnalyzer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function analyse(array $contextFiles, array $featureFiles): array
4343
$this->maskCollectionStatsPrinter->printStats($maskCollection);
4444

4545
$featureInstructions = $this->usedInstructionResolver->resolveInstructionsFromFeatureFiles($featureFiles);
46-
4746
$maskProgressBar = $this->symfonyStyle->createProgressBar($maskCollection->count());
4847

4948
$unusedMasks = [];
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

tests/Analyzer/UnusedDefinitionsAnalyzer/UnusedDefinitionsAnalyzerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ protected function setUp(): void
2121

2222
public function test(): void
2323
{
24-
$featureFiles = BehatMetafilesFinder::findFeatureFiles([__DIR__ . '/Fixture']);
25-
$contextFiles = BehatMetafilesFinder::findContextFiles([__DIR__ . '/Fixture']);
24+
$featureFiles = BehatMetafilesFinder::findFeatureFiles([__DIR__ . '/Fixture/Features']);
25+
$this->assertCount(1, $featureFiles);
2626

27-
$unusedDefinitions = $this->unusedDefinitionsAnalyzer->analyse(
28-
$featureFiles,
29-
$contextFiles
30-
);
27+
$contextFiles = BehatMetafilesFinder::findContextFiles([__DIR__ . '/Fixture/Contexts']);
28+
$this->assertCount(1, $contextFiles);
29+
30+
$unusedDefinitions = $this->unusedDefinitionsAnalyzer->analyse($contextFiles, $featureFiles);
3131

3232
$this->assertCount(0, $unusedDefinitions);
3333
}

0 commit comments

Comments
 (0)