Skip to content
Permalink
Browse files

Merge pull request #281 from Danon/master

Correct Functions::isEmpty() #275
  • Loading branch information
bbankowski committed Mar 21, 2020
2 parents 219f783 + 6b823f7 commit dedd64ea5a7b31eadf05ba71ab93454a246ca263
Showing with 47 additions and 1 deletion.
  1. +2 −0 .gitignore
  2. +1 −1 src/Ouzo/Goodies/Utilities/Functions.php
  3. +44 −0 test/src/Ouzo/Goodies/Utilities/FunctionsTest.php
@@ -0,0 +1,2 @@
.idea/
vendor/
@@ -123,7 +123,7 @@ public static function notEmpty()
public static function isEmpty()
{
return function ($object) {
return !empty($object);
return empty($object);
};
}

@@ -285,4 +285,48 @@ public function shouldCheckIfStringIsEqualIgnoringCaseToValue()
$this->assertTrue(Functions::call(Functions::equalsIgnoreCase('value'), 'VaLuE'));
$this->assertTrue(Functions::call(Functions::equalsIgnoreCase('VaLuE'), 'value'));
}

/**
* @test
*/
public function shouldBeEmpty()
{
// then
$this->assertFalse(Functions::call(Functions::isEmpty(), ['The Lannisters send their regards']));
$this->assertTrue(Functions::call(Functions::isEmpty(), []));
$this->assertTrue(Functions::call(Functions::isEmpty(), null));
}

/**
* @test
*/
public function shouldNotBeEmpty()
{
// then
$this->assertTrue(Functions::call(Functions::notEmpty(), ['The Lannisters send their regards']));
$this->assertFalse(Functions::call(Functions::notEmpty(), []));
$this->assertFalse(Functions::call(Functions::notEmpty(), null));
}

/**
* @test
*/
public function shouldBeBlank()
{
// then
$this->assertFalse(Functions::call(Functions::isBlank(), 'Not blank'));
$this->assertTrue(Functions::call(Functions::isBlank(), ' '));
$this->assertTrue(Functions::call(Functions::isBlank(), ''));
}

/**
* @test
*/
public function shouldNotBeBlank()
{
// then
$this->assertTrue(Functions::call(Functions::notBlank(), 'Not blank'));
$this->assertFalse(Functions::call(Functions::notBlank(), ' '));
$this->assertFalse(Functions::call(Functions::notBlank(), ''));
}
}

0 comments on commit dedd64e

Please sign in to comment.
You can’t perform that action at this time.