You are here

public function DatabaseStorageSortedTestBase::assertPairs in Key-value Extensions 8

2 calls to DatabaseStorageSortedTestBase::assertPairs()
DatabaseStorageListTest::testCalls in src/Tests/DatabaseStorageListTest.php
DatabaseStorageSortedSetTest::testCalls in src/Tests/DatabaseStorageSortedSetTest.php

File

src/Tests/DatabaseStorageSortedTestBase.php, line 40

Class

DatabaseStorageSortedTestBase

Namespace

Drupal\key_value\Tests

Code

public function assertPairs($expected_pairs) {
  $result = $this->connection
    ->select('key_value_sorted', 't')
    ->fields('t', [
    'name',
    'value',
  ])
    ->condition('collection', $this->collection)
    ->condition('name', array_keys($expected_pairs), 'IN')
    ->execute()
    ->fetchAllAssoc('name');
  $expected_count = count($expected_pairs);
  $this
    ->assertIdentical(count($result), $expected_count, "Query affected {$expected_count} records.");
  foreach ($expected_pairs as $key => $value) {
    $this
      ->assertIdentical($this->serializer
      ->decode($result[$key]->value), $value, "Key {$key} have value {$value}");
  }
}