From f720be862ea4aa9b77ae18ed17f3bf8be1589dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20As=CC=A7an?= Date: Thu, 12 Sep 2024 02:45:37 +0300 Subject: [PATCH 1/7] Add reference method --- src/PendingCalls/TestCall.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 1b02ed1e..6f1732b7 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -48,6 +48,13 @@ final class TestCall */ private readonly bool $descriptionLess; + /** + * This property is not actually used in the codebase, it's only here to make Rector happy. + * + * @var string|array + */ + public array|string $references; + /** * Creates a new Pending Call. */ @@ -615,6 +622,21 @@ public function coversNothing(): self return $this; } + /** + * Adds a reference to the tested method or class. + * This helps to link test cases to the source code + * for easier navigation during development. + * + * @param string|array $classes + */ + public function reference(string|array ...$classes): self + { + // For rector + $this->references = $classes; // @phpstan-ignore-line + + return $this; + } + /** * Informs the test runner that no expectations happen in this test, * and its purpose is simply to check whether the given code can From bab193e7e130fd0a631ef77b90ee8c0ab23a8aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20As=CC=A7an?= Date: Thu, 12 Sep 2024 03:24:36 +0300 Subject: [PATCH 2/7] Fix property type --- src/PendingCalls/TestCall.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 6f1732b7..aa32827e 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -51,9 +51,9 @@ final class TestCall /** * This property is not actually used in the codebase, it's only here to make Rector happy. * - * @var string|array + * @var array */ - public array|string $references; + public array $references; /** * Creates a new Pending Call. @@ -632,7 +632,7 @@ public function coversNothing(): self public function reference(string|array ...$classes): self { // For rector - $this->references = $classes; // @phpstan-ignore-line + $this->references = $classes; return $this; } From 668685498fa4caca192655c1f8ef1c473ab9f5b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20As=CC=A7an?= Date: Thu, 12 Sep 2024 03:51:20 +0300 Subject: [PATCH 3/7] Fix phpdoc type-hints --- src/PendingCalls/TestCall.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index aa32827e..23c2931f 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -51,7 +51,7 @@ final class TestCall /** * This property is not actually used in the codebase, it's only here to make Rector happy. * - * @var array + * @var array> */ public array $references; @@ -623,11 +623,10 @@ public function coversNothing(): self } /** - * Adds a reference to the tested method or class. - * This helps to link test cases to the source code - * for easier navigation during development. + * Adds a reference to the tested method or class. This helps to link test + * cases to the source code for easier navigation. * - * @param string|array $classes + * @param array|class-string ...$classes */ public function reference(string|array ...$classes): self { From 169b76458ecbc076eabc8be526c557dc224b58d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20As=CC=A7an?= Date: Thu, 12 Sep 2024 11:15:30 +0300 Subject: [PATCH 4/7] make the name of the method plural --- src/PendingCalls/TestCall.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 23c2931f..ad7a8a91 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -628,7 +628,7 @@ public function coversNothing(): self * * @param array|class-string ...$classes */ - public function reference(string|array ...$classes): self + public function references(string|array ...$classes): self { // For rector $this->references = $classes; From ab0b4a1b4e62eb81f3e3c86a4b0b93a67ebdfacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20A=C5=9Fan?= Date: Thu, 12 Sep 2024 13:09:45 +0300 Subject: [PATCH 5/7] Update src/PendingCalls/TestCall.php Co-authored-by: Owen Voke --- src/PendingCalls/TestCall.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index ad7a8a91..50ddddc3 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -623,8 +623,8 @@ public function coversNothing(): self } /** - * Adds a reference to the tested method or class. This helps to link test - * cases to the source code for easier navigation. + * Adds one or more references to the tested method or class. This helps + * to link test cases to the source code for easier navigation. * * @param array|class-string ...$classes */ From 74ff3b8cd94e975ffccd26895a2a58361b35117e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20A=C5=9Fan?= Date: Thu, 12 Sep 2024 13:09:57 +0300 Subject: [PATCH 6/7] Update src/PendingCalls/TestCall.php Co-authored-by: Owen Voke --- src/PendingCalls/TestCall.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 50ddddc3..46e1acb9 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -630,8 +630,7 @@ public function coversNothing(): self */ public function references(string|array ...$classes): self { - // For rector - $this->references = $classes; + assert($classes !== []); return $this; } From ba7eb70a5d91f9a5e60750fb393a316efcf4fc9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20As=CC=A7an?= Date: Thu, 12 Sep 2024 13:11:12 +0300 Subject: [PATCH 7/7] Remove unnecessary property --- src/PendingCalls/TestCall.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 46e1acb9..1208b809 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -48,13 +48,6 @@ final class TestCall */ private readonly bool $descriptionLess; - /** - * This property is not actually used in the codebase, it's only here to make Rector happy. - * - * @var array> - */ - public array $references; - /** * Creates a new Pending Call. */