You are here

public function FilterTest::testCreateFromQueryParameter in JSON:API 8.2

@covers ::createFromQueryParameter @dataProvider parameterProvider

File

tests/src/Kernel/Query/FilterTest.php, line 300

Class

FilterTest
@coversDefaultClass \Drupal\jsonapi\Query\Filter @group jsonapi @group jsonapi_query @group legacy

Namespace

Drupal\Tests\jsonapi\Kernel\Query

Code

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());
  }
}