EntityConditionGroupTest.php

Same filename in other branches
  1. 9 core/modules/jsonapi/tests/src/Unit/Query/EntityConditionGroupTest.php
  2. 10 core/modules/jsonapi/tests/src/Unit/Query/EntityConditionGroupTest.php
  3. 11.x core/modules/jsonapi/tests/src/Unit/Query/EntityConditionGroupTest.php

Namespace

Drupal\Tests\jsonapi\Unit\Query

File

core/modules/jsonapi/tests/src/Unit/Query/EntityConditionGroupTest.php

View source
<?php

namespace Drupal\Tests\jsonapi\Unit\Query;

use Drupal\jsonapi\Query\EntityConditionGroup;
use Drupal\Tests\UnitTestCase;

/**
 * @coversDefaultClass \Drupal\jsonapi\Query\EntityConditionGroup
 * @group jsonapi
 *
 * @internal
 */
class EntityConditionGroupTest extends UnitTestCase {
    
    /**
     * @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', []);
    }
    
    /**
     * Data provider for testConstruct.
     */
    public function constructProvider() {
        return [
            [
                [
                    'conjunction' => 'AND',
                    'members' => [],
                ],
            ],
            [
                [
                    'conjunction' => 'OR',
                    'members' => [],
                ],
            ],
        ];
    }

}

Classes

Title Deprecated Summary
EntityConditionGroupTest @coversDefaultClass \Drupal\jsonapi\Query\EntityConditionGroup @group jsonapi

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.