Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct Functions::isEmpty() #275 #281

Merged
merged 3 commits into from Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
.idea/
vendor/
2 changes: 1 addition & 1 deletion src/Ouzo/Goodies/Utilities/Functions.php
Expand Up @@ -123,7 +123,7 @@ public static function notEmpty()
public static function isEmpty()
{
return function ($object) {
return !empty($object);
return empty($object);
};
}

Expand Down
44 changes: 44 additions & 0 deletions test/src/Ouzo/Goodies/Utilities/FunctionsTest.php
Expand Up @@ -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(), ''));
}
}