You are here

FieldOptionsTest.php in Webform CiviCRM Integration 8.5

File

tests/src/Kernel/FieldOptionsTest.php
View source
<?php

namespace Drupal\Tests\webform_civicrm\Kernel;

use Drupal\Core\Database\Database;
use Drupal\KernelTests\KernelTestBase;

/**
 * @group webform_civicrm
 *
 * @todo CiviCRM does not support SQLite.
 */
class FieldOptionsTest extends KernelTestBase {
  protected static $modules = [
    'user',
    'civicrm',
    'webform',
    'webform_civicrm',
  ];
  protected function bootEnvironment() {
    parent::bootEnvironment();
    Database::addConnectionInfo('civicrm_test', 'default', $this
      ->getDatabaseConnectionInfo()['default']);
  }
  protected function setUp() {
    $this
      ->markTestSkipped('Requires MySQL');
    parent::setUp();
    module_load_install('civicrm');
    civicrm_install();
    $this->container
      ->get('civicrm')
      ->initialize();
  }

  /**
   * {@inheritdoc}
   */
  protected function tearDown() {
    $conn = Database::getConnection('default', 'civicrm_test');
    $database = $conn
      ->getConnectionOptions()['database'];

    // Todo: get this working when db name passed in as an argument.
    $conn
      ->query("DROP DATABASE {$database}");
    $conn
      ->destroy();
  }

  /**
   * @dataProvider testGetDataprovider
   */
  public function testGet(array $field, string $context, array $data) {
    $field_options = $this->container
      ->get('webform_civicrm.field_options');
    $options = $field_options
      ->get($field, $context, $data);
  }
  public function testGetDataprovider() {
    (yield [
      [
        'form_key' => 'civicrm_1_contact_1_email_email',
      ],
      'live_options',
      [],
    ]);
  }

}

Classes

Namesort descending Description
FieldOptionsTest @group webform_civicrm