You are here

public function RealisticDummyContentTermReferenceFieldTest::providerGetTid in Realistic Dummy Content 8.2

Same name and namespace in other branches
  1. 7.2 api/src/test/includes/RealisticDummyContentTermReferenceFieldTest.php \Drupal\realistic_dummy_content_api\Test\RealisticDummyContentTermReferenceFieldTest::providerGetTid()

Provider for testGetTid().

File

api/src/test/includes/RealisticDummyContentTermReferenceFieldTest.php, line 102

Class

RealisticDummyContentTermReferenceFieldTest
Tests for ...\includes\RealisticDummyContentTermReferenceField.

Namespace

Drupal\realistic_dummy_content_api\Test

Code

public function providerGetTid() {
  return [
    [
      'message' => 'Exception if no vocabulary.',
      'vocabularies' => [],
      'field_info' => [],
      'expect_exception' => TRUE,
      'name' => '',
      'expected' => 0,
    ],
    [
      'message' => 'new term is created if none exists.',
      'vocabularies' => [
        [
          'vid' => 'first',
          'terms' => [],
        ],
      ],
      'field_info' => [
        [
          'vocabulary' => 'not-first',
        ],
      ],
      'expect_exception' => FALSE,
      'name' => 'whatever',
      'expected' => 'this-is-a-new-term',
    ],
    [
      'message' => 'new term is created if none exists in the vocabulary.',
      'vocabularies' => [
        [
          'vid' => 'first',
          'terms' => [
            [
              'id' => 'some-term',
            ],
          ],
        ],
      ],
      'field_info' => [
        [
          'vocabulary' => 'first',
        ],
      ],
      'expect_exception' => FALSE,
      'name' => 'whatever',
      'expected' => 'this-is-a-new-term',
    ],
    [
      'message' => 'new term is created if one exists in a different vocabulary.',
      'vocabularies' => [
        [
          'vid' => 'first',
          'terms' => [
            [
              'id' => 'some-term',
            ],
          ],
        ],
      ],
      'field_info' => [
        [
          'vocabulary' => 'not-first',
        ],
      ],
      'expect_exception' => FALSE,
      'name' => 'some-term',
      'expected' => 'this-is-a-new-term',
    ],
    [
      'message' => 'existing term is used if one exists in the target vocabulary.',
      'vocabularies' => [
        [
          'vid' => 'first',
          'terms' => [
            [
              'id' => 'some-term',
            ],
          ],
        ],
      ],
      'field_info' => [
        [
          'vocabulary' => 'first',
        ],
      ],
      'expect_exception' => FALSE,
      'name' => 'some-term',
      'expected' => 'some-term',
    ],
  ];
}