You are here

function RealisticDummyContentTest::testIsDummy in Realistic Dummy Content 8

File

api/tests/src/Unit/facade/RealisticDummyContentTest.php, line 20
Define autoload class.

Class

RealisticDummyContentTest
Test Realistic dummy content.

Namespace

Drupal\Tests\realistic_dummy_content_api\Unit\facade

Code

function testIsDummy() {

  // only pure functions should be tested here. The database is not available.
  $user = (object) array();
  $user->mail = 'whatever@example.com.invalid';
  $this
    ->assertTrue(RealisticDummyContent::realistic_dummy_content_api_dummy($user, 'user'), 'User with an email ending in .invalid is considered dummy content');
  $user->mail = 'whatever@example.com';
  $user->devel_generate = TRUE;
  $this
    ->assertTrue(RealisticDummyContent::realistic_dummy_content_api_dummy($user, 'user'), 'User with the devel_generate property set is considered dummy content');
  unset($user->devel_generate);
  $this
    ->assertFalse(RealisticDummyContent::realistic_dummy_content_api_dummy($user, 'user'), 'User with neither an address ending in .invalid nor the devel_generate property set is considered non-dummy');
  $node = (object) array();
  $node->devel_generate = array();
  $this
    ->assertTrue(RealisticDummyContent::realistic_dummy_content_api_dummy($node, 'node'), 'Node with the devel_generate property set to an empty array is considered dummy');
  unset($node->devel_generate);
  $this
    ->assertFALSE(RealisticDummyContent::realistic_dummy_content_api_dummy($node, 'node'), 'Node with the devel_generate not set is considered non-dummy');
}