public function testLookupWithSortAndMissingKey()
{
$data = json_decode(file_get_contents(__DIR__ . '/../fixtures/datastore/entity-lookup-bigsort.json'), true);
// Move an entity to missing.
$missing = $data['entities'][5];
$data['missing'][] = $missing;
unset($data['entities'][5]);
$keys = [];
foreach ($data['keys'] as $key) {
$keys[] = new Key('test-project', ['path' => $key['path']]);
}
$this->connection->lookup(Argument::any())->willReturn(['found' => $data['entities']]);
$this->operation->setConnection($this->connection->reveal());
$res = $this->operation->lookup($keys, ['sort' => true]);
$found = $res['found'];
$this->assertEquals($keys[0]->path()[0]['id'], $found[0]->key()->path()[0]['id']);
$this->assertEquals($keys[1]->path()[0]['id'], $found[1]->key()->path()[0]['id']);
$this->assertEquals($keys[2]->path()[0]['id'], $found[2]->key()->path()[0]['id']);
$this->assertEquals($keys[3]->path()[0]['id'], $found[3]->key()->path()[0]['id']);
$this->assertEquals($keys[4]->path()[0]['id'], $found[4]->key()->path()[0]['id']);
$this->assertEquals($keys[6]->path()[0]['id'], $found[5]->key()->path()[0]['id']);
$this->assertEquals($keys[7]->path()[0]['id'], $found[6]->key()->path()[0]['id']);
$this->assertEquals($keys[8]->path()[0]['id'], $found[7]->key()->path()[0]['id']);
$this->assertEquals($keys[9]->path()[0]['id'], $found[8]->key()->path()[0]['id']);
$this->assertEquals($keys[10]->path()[0]['id'], $found[9]->key()->path()[0]['id']);
}