From ab4787c66749ed935eca0baedd6aa34b163fd21c Mon Sep 17 00:00:00 2001 From: Vincenzo Petrucci Date: Fri, 17 Nov 2023 15:03:28 +0100 Subject: [PATCH 1/3] feat: added onlyOn* methods to run the test only on a specific OS --- src/PendingCalls/TestCall.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 60b6fcf8..102a4f17 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -223,6 +223,30 @@ final class TestCall return $this->skipOn('Linux', 'This test is skipped on [Linux].'); } + /** + * Runs the current test only if the given test is running on Windows. + */ + public function onlyOnWindows(): self + { + return $this->skipOnLinux()->skipOnMac(); + } + + /** + * Runs the current test only if the given test is running on Mac. + */ + public function onlyOnMac(): self + { + return $this->skipOnWindows()->skipOnLinux(); + } + + /** + * Run the current test only if the given test is running on Linux. + */ + public function onlyOnLinux(): self + { + return $this->skipOnWindows()->skipOnMac(); + } + /** * Skips the current test if the given test is running on the given operating systems. */ From cf23dfa477e5e445020cc833ad022212e06c74a6 Mon Sep 17 00:00:00 2001 From: Vincenzo Petrucci Date: Fri, 17 Nov 2023 16:16:48 +0100 Subject: [PATCH 2/3] feat: onlyOn* methods now use the private onlyOn method --- src/PendingCalls/TestCall.php | 58 ++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 102a4f17..48d98cb4 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -223,30 +223,6 @@ final class TestCall return $this->skipOn('Linux', 'This test is skipped on [Linux].'); } - /** - * Runs the current test only if the given test is running on Windows. - */ - public function onlyOnWindows(): self - { - return $this->skipOnLinux()->skipOnMac(); - } - - /** - * Runs the current test only if the given test is running on Mac. - */ - public function onlyOnMac(): self - { - return $this->skipOnWindows()->skipOnLinux(); - } - - /** - * Run the current test only if the given test is running on Linux. - */ - public function onlyOnLinux(): self - { - return $this->skipOnWindows()->skipOnMac(); - } - /** * Skips the current test if the given test is running on the given operating systems. */ @@ -257,6 +233,40 @@ final class TestCall : $this; } + /** + * Skips the current test unless the given test is running on Windows. + */ + public function onlyOnWindows(): self + { + return $this->onlyOn('Windows', 'This test is skipped unless on [Windows].'); + } + + /** + * Skips the current test unless the given test is running on Mac. + */ + public function onlyOnMac(): self + { + return $this->onlyOn('Darwin', 'This test is skipped unless on [Mac].'); + } + + /** + * Skips the current test unless the given test is running on Linux. + */ + public function onlyOnLinux(): self + { + return $this->onlyOn('Linux', 'This test is skipped unless on [Linux].'); + } + + /** + * Skips the current test unless the given test is running on the given operating system. + */ + private function onlyOn(string $osFamily, string $message): self + { + return $osFamily !== PHP_OS_FAMILY + ? $this->skip($message) + : $this; + } + /** * Repeats the current test the given number of times. */ From f7705fe1c1c007aa91aac9333f5039f2ae6c4908 Mon Sep 17 00:00:00 2001 From: Vincenzo Petrucci Date: Mon, 20 Nov 2023 14:51:38 +0100 Subject: [PATCH 3/3] feat: onlyOn* methods, removed private onlyOn, rely instead on skipOn* methods --- src/PendingCalls/TestCall.php | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 48d98cb4..45669e9d 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -238,7 +238,7 @@ final class TestCall */ public function onlyOnWindows(): self { - return $this->onlyOn('Windows', 'This test is skipped unless on [Windows].'); + return $this->skipOnMac()->skipOnLinux(); } /** @@ -246,7 +246,7 @@ final class TestCall */ public function onlyOnMac(): self { - return $this->onlyOn('Darwin', 'This test is skipped unless on [Mac].'); + return $this->skipOnWindows()->skipOnLinux(); } /** @@ -254,17 +254,7 @@ final class TestCall */ public function onlyOnLinux(): self { - return $this->onlyOn('Linux', 'This test is skipped unless on [Linux].'); - } - - /** - * Skips the current test unless the given test is running on the given operating system. - */ - private function onlyOn(string $osFamily, string $message): self - { - return $osFamily !== PHP_OS_FAMILY - ? $this->skip($message) - : $this; + return $this->skipOnWindows()->skipOnMac(); } /**