You are here

public function EntityCreateTest::testRequiredContexts in Rules 8.3

Tests context definitions for the bundle and required fields.

@covers \Drupal\rules\Plugin\RulesAction\EntityCreateDeriver::getDerivativeDefinitions

File

tests/src/Unit/Integration/RulesAction/EntityCreateTest.php, line 131

Class

EntityCreateTest
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\EntityCreate @group RulesAction

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

public function testRequiredContexts() {
  $context_definitions = $this->action
    ->getContextDefinitions();
  $this
    ->assertCount(2, $context_definitions);
  $this
    ->assertArrayHasKey('bundle', $context_definitions);
  $this
    ->assertEquals(ContextDefinition::ASSIGNMENT_RESTRICTION_INPUT, $context_definitions['bundle']
    ->getAssignmentRestriction());
  $this
    ->assertTrue($context_definitions['bundle']
    ->isRequired());
  $this
    ->assertArrayHasKey('field_required', $context_definitions);
  $this
    ->assertNull($context_definitions['field_required']
    ->getAssignmentRestriction());
  $this
    ->assertFalse($context_definitions['field_required']
    ->isRequired());
}