public function testFetch()
{
$data = ['a' => 'ssh-rsa AAAAB3xxx0uj+Q== [email protected]', 'b' => 'ssh-rsa AAAAB3xxx000+Q== [email protected]'];
$this->request->expects($this->once())->method('request')->with($this->url, ['options' => ['method' => 'get']])->willReturn(['data' => $data]);
$i = 0;
$models = [];
$options = ['collection' => $this->collection];
foreach ($data as $id => $key) {
$options['id'] = $id;
$model_data = (object) ['id' => $id, 'key' => $key];
$model = $models[$i] = new SSHKey($model_data, $options);
$this->container->expects($this->at($i++))->method('get')->with(SSHKey::class, [$model_data, $options])->willReturn($model);
}
$this->collection->fetch();
$this->assertEquals($models, $this->collection->all());
}