Skip to content

Commit c61be69

Browse files
nikophilclaude
andcommitted
fix: allow quoted object names starting with digits in regex patterns
Move the (?!\d) negative lookahead inside the branch reset group, just before the unquoted \S+ alternative. This allows quoted names like "007" to start with a digit while still preventing ambiguity with count patterns for unquoted names. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9a0d889 commit c61be69

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Feature: Test object names starting with digits
2+
3+
Scenario: Quoted object names can start with digits
4+
Given there is a "generic entity" "123" with
5+
| prop1 |
6+
| foo |
7+
Then "generic entity" "123" should exist
8+
And "generic entity" "123" should have properties
9+
| prop1 |
10+
| foo |
11+
12+
Scenario: Quoted object names can be pure numbers
13+
Given there is a contact "007"
14+
Then contact "007" should exist
15+
16+
Scenario: Count assertions still work correctly alongside digit names
17+
Given there is a contact "1"
18+
And there is a contact "2"
19+
Then 2 contacts should exist
20+
And contact "1" should exist
21+
And contact "2" should exist

src/Test/Behat/src/FoundryContext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,21 @@ public function assertNbObjectsExist(int $nb, string $factoryShortName): void
7272
* optional "exist and", and optional trailing "properties".
7373
*/
7474
#[\Override]
75-
#[Then('/^(?:the |an? )?(?!\d)(?|"(?P<factoryShortName>[^"]+)"|(?P<factoryShortName>\S+)) (?:(?:called |named ))?(?|"(?P<objectName>[^"]+)"|(?P<objectName>\S+)) should (?:exist and )?have(?: properties)?$/')]
75+
#[Then('/^(?:the |an? )?(?|"(?P<factoryShortName>[^"]+)"|(?!\d)(?P<factoryShortName>\S+)) (?:(?:called |named ))?(?|"(?P<objectName>[^"]+)"|(?P<objectName>\S+)) should (?:exist and )?have(?: properties)?$/')]
7676
public function assertObjectHasProperties(FoundryTableNode $table, string $factoryShortName, string $objectName): void
7777
{
7878
parent::assertObjectHasProperties($table, $factoryShortName, $objectName);
7979
}
8080

8181
#[\Override]
82-
#[Then('/^(?:the |an? )?(?!\d)(?|"(?P<factoryShortName>[^"]+)"|(?P<factoryShortName>\S+)) (?:(?:called |named ))?(?|"(?P<objectName>[^"]+)"|(?P<objectName>\S+)) should exist$/')]
82+
#[Then('/^(?:the |an? )?(?|"(?P<factoryShortName>[^"]+)"|(?!\d)(?P<factoryShortName>\S+)) (?:(?:called |named ))?(?|"(?P<objectName>[^"]+)"|(?P<objectName>\S+)) should exist$/')]
8383
public function assertObjectExists(string $factoryShortName, string $objectName): void
8484
{
8585
parent::assertObjectExists($factoryShortName, $objectName);
8686
}
8787

8888
#[\Override]
89-
#[Then('/^(?:the |an? )?(?!\d)(?|"(?P<factoryShortName>[^"]+)"|(?P<factoryShortName>\S+)) (?:(?:called |named ))?(?|"(?P<objectName>[^"]+)"|(?P<objectName>\S+)) should not exist$/')]
89+
#[Then('/^(?:the |an? )?(?|"(?P<factoryShortName>[^"]+)"|(?!\d)(?P<factoryShortName>\S+)) (?:(?:called |named ))?(?|"(?P<objectName>[^"]+)"|(?P<objectName>\S+)) should not exist$/')]
9090
public function assertObjectDoesNotExist(string $factoryShortName, string $objectName): void
9191
{
9292
parent::assertObjectDoesNotExist($factoryShortName, $objectName);

0 commit comments

Comments
 (0)