field example



    /** * @return iterable<int|string, mixed> */
    public static function configurationLoadingProvider(): iterable
    {
        yield 'Test simple inheritance' => [
            'child',
            [
                'base' => [
                    'base-field-1' => self::field('#000'),
                    'base-field-2' => self::fieldUntyped(7),
                ],
                'parent' => [
                    'parent-field-1' => self::field('#000'),
                ],
                'child' => [
                    'child-field-1' => self::field('#000'),
                ],
            ],
            [
                'base-field-1' => '#000',
                
->willReturn(TRUE);
    $container->set('cache_contexts_manager', $cache_context_manager->reveal());
    \Drupal::setContainer($container);
  }

  /** * @covers ::createFromQueryParameter * @dataProvider queryParameterProvider */
  public function testCreateFromQueryParameter($case) {
    $condition = EntityCondition::createFromQueryParameter($case);
    $this->assertEquals($case['path']$condition->field());
    $this->assertEquals($case['value']$condition->value());
    if (isset($case['operator'])) {
      $this->assertEquals($case['operator']$condition->operator());
    }
  }

  /** * Data provider for testDenormalize. */
  public function queryParameterProvider() {
    return [
      [[
return $this;
    }

    /** * @param array<string, mixed> $config */
    public function entitySelectField(string $name, string $entity, bool $multi = false, array $config = []): self
    {
        $type = $multi ? 'multi-entity-id-select' : 'single-entity-id-select';

        return $this->field($name$typearray_merge([
            'entity' => $entity,
        ]$config));
    }

    /** * @param array<string|int> $options * @param array<string, mixed> $config */
    public function selectField(string $name, array $options, bool $multi = false, array $config = []): self
    {
        $type = $multi ? 'multi-select' : 'single-select';

        
$group = $query->orConditionGroup();
        break;
    }

    // Get all children of the group.     $members = $condition_group->members();

    foreach ($members as $member) {
      // If the child is simply a condition, add it to the new group.       if ($member instanceof EntityCondition) {
        if ($member->operator() == 'IS NULL') {
          $group->notExists($member->field());
        }
        elseif ($member->operator() == 'IS NOT NULL') {
          $group->exists($member->field());
        }
        else {
          $group->condition($member->field()$member->value()$member->operator());
        }
      }
      // If the child is a group, then recursively construct a sub group.       elseif ($member instanceof EntityConditionGroup) {
        // Add the subgroup to this new group.
/** * Prefixes all fields in an EntityConditionGroup. */
  protected static function addConditionFieldPrefix(EntityConditionGroup $group$field_prefix) {
    $prefixed = [];
    foreach ($group->members() as $member) {
      if ($member instanceof EntityConditionGroup) {
        $prefixed[] = static::addConditionFieldPrefix($member$field_prefix);
      }
      else {
        $field = !empty($field_prefix) ? "{$field_prefix}." . $member->field() : $member->field();
        $prefixed[] = new EntityCondition($field$member->value()$member->operator());
      }
    }
    return new EntityConditionGroup($group->conjunction()$prefixed);
  }

  /** * Gets an EntityConditionGroup that filters out inaccessible entities. * * @param string $entity_type_id * The entity type ID for which to get an EntityConditionGroup. * @param \Drupal\Core\Cache\CacheableMetadata $cacheability * Collects cacheability for the query. * * @return \Drupal\jsonapi\Query\EntityConditionGroup|null * An EntityConditionGroup or NULL if no conditions need to be applied to * secure an entity query. */


  /** * @covers ::createFromQueryParameter * @dataProvider parameterProvider */
  public function testCreateFromQueryParameter($case$expected) {
    $resource_type = new ResourceType('foo', 'bar', NULL);
    $actual = Filter::createFromQueryParameter($case$resource_type$this->getFieldResolverMock($resource_type));
    $conditions = $actual->root()->members();
    for ($i = 0; $i < count($case)$i++) {
      $this->assertEquals($expected[$i]['path']$conditions[$i]->field());
      $this->assertEquals($expected[$i]['value']$conditions[$i]->value());
      $this->assertEquals($expected[$i]['operator']$conditions[$i]->operator());
    }
  }

  /** * Data provider for testCreateFromQueryParameter. */
  public function parameterProvider() {
    return [
      'shorthand' => [
        [
/** * @covers ::__construct * @dataProvider constructProvider */
  public function testConstruct($case) {
    $group = new EntityConditionGroup($case['conjunction']$case['members']);

    $this->assertEquals($case['conjunction']$group->conjunction());

    foreach ($group->members() as $key => $condition) {
      $this->assertEquals($case['members'][$key]['path']$condition->field());
      $this->assertEquals($case['members'][$key]['value']$condition->value());
    }
  }

  /** * @covers ::__construct */
  public function testConstructException() {
    $this->expectException(\InvalidArgumentException::class);
    new EntityConditionGroup('NOT_ALLOWED', []);
  }

  
use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackImageBlockElement;
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackSectionBlock;

final class SlackSectionBlockTest extends TestCase
{
    public function testCanBeInstantiated()
    {
        $section = new SlackSectionBlock();
        $section->text('section text');
        $section->field('section field');
        $section->accessory(new SlackImageBlockElement('https://example.com/image.jpg', 'an image'));

        $this->assertSame([
            'type' => 'section',
            'text' => [
                'type' => 'mrkdwn',
                'text' => 'section text',
            ],
            'fields' => [
                [
                    'type' => 'mrkdwn',
                    
Home | Imprint | This part of the site doesn't use cookies.