From 8ae7ca93d465d8fdd8a537f6fe612bb969878891 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 23 Apr 2021 13:41:52 +0100 Subject: [PATCH] Adds tests to "whenNotEmpty" (#37091) --- tests/Support/SupportStringableTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Support/SupportStringableTest.php b/tests/Support/SupportStringableTest.php index e40003f04a5f..9f8dbaf64944 100644 --- a/tests/Support/SupportStringableTest.php +++ b/tests/Support/SupportStringableTest.php @@ -109,6 +109,23 @@ public function testWhenEmpty() })); } + public function testWhenNotEmpty() + { + tap($this->stringable(), function ($stringable) { + $this->assertSame($stringable, $stringable->whenNotEmpty(function ($stringable) { + return $stringable.'.'; + })); + }); + + $this->assertSame('', (string) $this->stringable()->whenNotEmpty(function ($stringable) { + return $stringable.'.'; + })); + + $this->assertSame('Not empty.', (string) $this->stringable('Not empty')->whenNotEmpty(function ($stringable) { + return $stringable.'.'; + })); + } + public function testWhenFalse() { $this->assertSame('when', (string) $this->stringable('when')->when(false, function ($stringable, $value) {