* @link https://www.oxidmodule.com */ declare(strict_types=1); namespace D3\KlicktippPhpClient\tests\availability; use D3\KlicktippPhpClient\Exceptions\KlicktippExceptionInterface; use D3\KlicktippPhpClient\Resources\Tag; /** * @coversNothing */ class TagTest extends AvailabilityTestCase { /** * @return void * @throws KlicktippExceptionInterface */ public function testFields(): void { $klicktipp = $this->getKlicktipp(); $endpoint = $klicktipp->tag(); $tagId = null; try { $tagId = $endpoint->create('testTagName'); $this->assertNotEmpty($tagId); $properties = $endpoint->get($tagId); $this->assertArrayHasKey(Tag::NAME, $properties); $this->assertEquals('testTagName', $properties[Tag::NAME]); $fieldList = $endpoint->index(); $this->assertArrayHasKey($tagId, $fieldList->toArray()); $success = $endpoint->update($tagId, 'updatedTestFieldName'); $this->assertTrue($success); $success = $endpoint->delete($tagId); $this->assertTrue($success); } catch (KlicktippExceptionInterface $exception) { if ($tagId) { if (!$endpoint->delete($tagId)) { echo "can't delete tag with id $tagId\n"; } } throw $exception; } } }