You are here

public function ContentProcessorTest::testCreateNode in GatherContent 8.4

Data provider for createNodeTest.

Unfortunately real data providers get called before any other method.

I couldn't find a better way to generate test cases based on the bootstrapped Drupal installation (done in setUp) than creating my own "data provider" like test function.

File

tests/src/Kernel/ContentProcessorTest.php, line 39

Class

ContentProcessorTest
Class for testing core node import functionality.

Namespace

Drupal\Tests\gathercontent\Kernel

Code

public function testCreateNode() {
  $mapping = MockData::getMapping();
  $item = MockData::createItem($mapping, [
    TRUE,
    FALSE,
    TRUE,
  ], [
    TRUE,
    FALSE,
    FALSE,
  ]);
  $importOptions = new ImportOptions(NodeUpdateMethod::ALWAYS_CREATE);
  $cases = [
    'no checkboxes, no radioboxes' => [
      MockData::createItem($mapping, [
        FALSE,
        FALSE,
        FALSE,
      ], [
        FALSE,
        FALSE,
        FALSE,
      ]),
      $importOptions,
      [],
    ],
    'no checkboxes, 1 radiobox' => [
      MockData::createItem($mapping, [
        FALSE,
        FALSE,
        FALSE,
      ], [
        TRUE,
        FALSE,
        FALSE,
      ]),
      $importOptions,
      [],
    ],
    'no checkboxes, 3 radioboxes' => [
      MockData::createItem($mapping, [
        FALSE,
        FALSE,
        FALSE,
      ], [
        TRUE,
        TRUE,
        TRUE,
      ]),
      $importOptions,
      [],
    ],
    'all checkboxes, no radioboxes' => [
      MockData::createItem($mapping, [
        TRUE,
        TRUE,
        TRUE,
      ], [
        FALSE,
        FALSE,
        FALSE,
      ]),
      $importOptions,
      [],
    ],
    '1 file' => [
      $item,
      $importOptions,
      MockData::createFile($item),
    ],
    '3 files' => [
      $item,
      $importOptions,
      MockData::createFile($item) + MockData::createFile($item) + MockData::createFile($item),
    ],
  ];
  foreach ($cases as $caseName => $params) {
    print $caseName . PHP_EOL;
    call_user_func_array([
      static::class,
      'createNodeTest',
    ], $params);
  }
}