public function FieldKernelTest::testIsValueEmpty in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php \Drupal\Tests\views\Kernel\Handler\FieldKernelTest::testIsValueEmpty()
Tests views_handler_field::isValueEmpty().
File
- core/
modules/ views/ tests/ src/ Kernel/ Handler/ FieldKernelTest.php, line 758
Class
- FieldKernelTest
- Tests the generic field handler.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
public function testIsValueEmpty() {
$view = Views::getView('test_view');
$view
->initHandlers();
$field = $view->field['name'];
$this
->assertFalse($field
->isValueEmpty("not empty", TRUE), 'A normal string is not empty.');
$this
->assertTrue($field
->isValueEmpty("not empty", TRUE, FALSE), 'A normal string which skips empty() can be seen as empty.');
$this
->assertTrue($field
->isValueEmpty("", TRUE), '"" is considered as empty.');
$this
->assertTrue($field
->isValueEmpty('0', TRUE), '"0" is considered as empty if empty_zero is TRUE.');
$this
->assertTrue($field
->isValueEmpty(0, TRUE), '0 is considered as empty if empty_zero is TRUE.');
$this
->assertFalse($field
->isValueEmpty('0', FALSE), '"0" is considered not as empty if empty_zero is FALSE.');
$this
->assertFalse($field
->isValueEmpty(0, FALSE), '0 is considered not as empty if empty_zero is FALSE.');
$this
->assertTrue($field
->isValueEmpty(NULL, TRUE, TRUE), 'Null should be always seen as empty, regardless of no_skip_empty.');
$this
->assertTrue($field
->isValueEmpty(NULL, TRUE, FALSE), 'Null should be always seen as empty, regardless of no_skip_empty.');
}