Skip to content

Commit

Permalink
Adds tests to "whenNotEmpty" (laravel#37091)
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro authored and bert-w committed Apr 29, 2021
1 parent b6dd33b commit 8ae7ca9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/Support/SupportStringableTest.php
Expand Up @@ -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) {
Expand Down

0 comments on commit 8ae7ca9

Please sign in to comment.