You are here

function FieldKernelTest::testIsValueEmpty in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Handler/FieldKernelTest.php \Drupal\views\Tests\Handler\FieldKernelTest::testIsValueEmpty()

Tests views_handler_field::isValueEmpty().

File

core/modules/views/src/Tests/Handler/FieldKernelTest.php, line 701
Contains \Drupal\views\Tests\Handler\FieldKernelTest.

Class

FieldKernelTest
Tests the generic field handler.

Namespace

Drupal\views\Tests\Handler

Code

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.');
}