add subscription process create endpoint
This commit is contained in:
parent
549078f1b7
commit
abcfea9480
@ -48,6 +48,24 @@ class SubscriptionProcess extends Model
|
||||
return new SubscriptionEntity($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BaseException
|
||||
*/
|
||||
public function create(?string $name): SubscriptionEntity
|
||||
{
|
||||
$data = $this->connection->requestAndParse(
|
||||
'POST',
|
||||
'list.json',
|
||||
[
|
||||
RequestOptions::FORM_PARAMS => array_filter([
|
||||
'name' => trim($name ?? ''),
|
||||
]),
|
||||
]
|
||||
);
|
||||
|
||||
return new SubscriptionEntity($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BaseException
|
||||
*/
|
||||
|
@ -113,6 +113,31 @@ class SubscriptionProcessTest extends IntegrationTestCase
|
||||
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\KlicktippPhpClient\Resources\SubscriptionProcess::create
|
||||
* @dataProvider getDataProvider
|
||||
*/
|
||||
public function testCreate(ResponseInterface $response, ?Subscription $expected, bool $expectException = false)
|
||||
{
|
||||
$sut = new SubscriptionProcess($this->getConnectionMock($response));
|
||||
|
||||
if ($expectException) {
|
||||
$this->expectException(BaseException::class);
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'create',
|
||||
['newName']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
|
Loading…
x
Reference in New Issue
Block a user