Skip to content

Commit 29fc0ef

Browse files
committed
test: presets
1 parent 10be755 commit 29fc0ef

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

tests/Feature/PresetsTest.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace Feature;
4+
5+
use Tests\TestCase;
6+
7+
class PresetsTest extends TestCase
8+
{
9+
private $presetUpsertRes = null;
10+
private $presetName = 'test-preset';
11+
12+
13+
protected function setUp(): void
14+
{
15+
parent::setUp();
16+
17+
$returnData = $this->client()->presets->put([
18+
'preset_name' => $this->presetName,
19+
'preset_data' => [
20+
'value' => [
21+
'query_by' => "*",
22+
],
23+
]
24+
]);
25+
$this->presetUpsertRes = $returnData;
26+
}
27+
28+
protected function tearDown(): void
29+
{
30+
$presets = $this->client()->presets->get();
31+
foreach ($presets['presets'] as $preset) {
32+
$this->client()->presets->delete($preset['name']);
33+
}
34+
}
35+
36+
public function testCanUpsertAPreset(): void
37+
{
38+
$this->assertEquals($this->presetName, $this->presetUpsertRes['name']);
39+
}
40+
41+
//* Currently there isn't a method for retrieving a preset by name
42+
// public function testCanRetrieveAPreset(): void
43+
// {
44+
// $returnData = $this->client()->presets->get($this->presetName);
45+
// $this->assertEquals($this->presetName, $returnData['name']);
46+
// }
47+
48+
public function testCanDeleteAPreset(): void
49+
{
50+
$returnData = $this->client()->presets->delete($this->presetName);
51+
$this->assertEquals($this->presetName, $returnData['name']);
52+
53+
$returnPresets = $this->client()->presets->get();
54+
$this->assertEquals(0, count($returnPresets['presets']));
55+
}
56+
57+
public function testCanRetrieveAllPresets(): void
58+
{
59+
$returnData = $this->client()->presets->get();
60+
$this->assertEquals(1, count($returnData['presets']));
61+
}
62+
}

0 commit comments

Comments
 (0)