File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 1212namespace CaptainHook \App \Runner ;
1313
1414use CaptainHook \App \Hook ;
15+ use PHPUnit \Framework \MockObject \MockObject ;
1516use RuntimeException ;
1617
1718/**
@@ -84,14 +85,14 @@ class Shorthand
8485 ];
8586
8687 /**
87- * Check if a configured action value is actually shorthand for an internal action
88+ * Check if a configured action or condition value is actually a shorthand for an internal action
8889 *
89- * @param string $action
90+ * @param string $shorthand
9091 * @return bool
9192 */
92- public static function isShorthand (string $ action ): bool
93+ public static function isShorthand (string $ shorthand ): bool
9394 {
94- return ( bool ) preg_match ('#^captainhook\.[a-z]+#i ' , $ action );
95+ return preg_match ('#^captainhook\.[a-z]+\.[a-z]+$ #i ' , $ shorthand );
9596 }
9697
9798 /**
Original file line number Diff line number Diff line change @@ -25,11 +25,12 @@ public function testCanIdentifyShorthand()
2525 $ this ->assertFalse (Shorthand::isShorthand ('foo ' ));
2626 $ this ->assertFalse (Shorthand::isShorthand ('\\CaptainHook \\App ' ));
2727 $ this ->assertFalse (Shorthand::isShorthand ('CaptainHook. ' ));
28+ $ this ->assertFalse (Shorthand::isShorthand ('captainhook.sh ' ));
2829
2930 // positive
30- $ this ->assertTrue (Shorthand::isShorthand ('CaptainHook.foo ' ));
31- $ this ->assertTrue (Shorthand::isShorthand ('captainhook.bar ' ));
32- $ this ->assertTrue (Shorthand::isShorthand ('CAPTAINHOOK.baz ' ));
31+ $ this ->assertTrue (Shorthand::isShorthand ('CaptainHook.foo.fiz ' ));
32+ $ this ->assertTrue (Shorthand::isShorthand ('captainhook.Bar.Baz ' ));
33+ $ this ->assertTrue (Shorthand::isShorthand ('CAPTAINHOOK.FOO.BAR ' ));
3334 }
3435
3536 /**
You can’t perform that action at this time.
0 commit comments