8
0

add get endpoint for fields, add field entity, use constants

Dieser Commit ist enthalten in:
2025-01-03 10:02:54 +01:00
Ursprung 63530475cf
Commit 2a0ad3d74c
3 geänderte Dateien mit 117 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -15,6 +15,7 @@
namespace D3\KlicktippPhpClient\tests\integration\Resources;
use D3\KlicktippPhpClient\Entities\Field as FieldEntity;
use D3\KlicktippPhpClient\Entities\FieldList;
use D3\KlicktippPhpClient\Exceptions\BaseException;
use D3\KlicktippPhpClient\Resources\Field;
@ -94,6 +95,43 @@ class FieldTest extends IntegrationTestCase
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
}
/**
* @test
* @throws ReflectionException
* @covers \D3\KlicktippPhpClient\Resources\Field::get
* @dataProvider getDataProvider
*/
public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false)
{
$sut = new Field($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
}
$return = $this->callMethod(
$sut,
'get',
['12514414']
);
$this->assertInstanceOf(FieldEntity::class, $return);
$this->assertSame($expected, $return->toArray());
}
public static function getDataProvider(): Generator
{
yield 'success' => [new Response(200, [], '{
"'.Field::ID.'": "12514414",
"'.Field::NAME.'": "fieldName2"
}'), [
Field::ID => "12514414",
Field::NAME => "fieldName2",
]];
yield 'unknown id' => [new Response(404, [], '["Kein Field mit dieser ID."]'), null, true];
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
}
/**
* @test
* @throws ReflectionException