-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTests.php
More file actions
87 lines (74 loc) · 2.48 KB
/
Copy pathTests.php
File metadata and controls
87 lines (74 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
declare(strict_types=1);
namespace TestingBot\Resource;
use TestingBot\Http\Request;
/**
* Test (job) records. A test is identified by its numeric id or its WebDriver
* session id.
*/
final class Tests extends AbstractResource
{
/**
* List tests, most recent first.
*
* @param array<string, mixed> $filters Extra query filters: `since`,
* `browser_id`, `group`, `build`, `skip_fields`, `omit`.
* @return array<mixed>
*/
public function list(int $offset = 0, int $count = 10, array $filters = []): array
{
return $this->request(new Request('GET', 'tests', query: $this->paginationQuery($offset, $count, $filters)));
}
/**
* Get a single test by id or session id.
*
* @param array<string, mixed> $options Query options: `skip_fields`, `omit`.
* @return array<mixed>
*/
public function get(string $id, array $options = []): array
{
$id = $this->requireNonEmpty($id, 'Please use a valid test id or WebDriver session id');
return $this->request(new Request('GET', 'tests/' . $id, query: $options));
}
/**
* Update a test's metadata (name, success, status_message, extra, build…).
*
* @param array<string, mixed> $details
* @return array<mixed>
*/
public function update(string $id, array $details): array
{
$id = $this->requireNonEmpty($id, 'Please use a valid test id or WebDriver session id');
return $this->request(new Request('PUT', 'tests/' . $id, body: $this->wrap('test', $details)));
}
/**
* Create a test record (for reporting an externally run result).
*
* @param array<string, mixed> $details
* @return array<mixed>
*/
public function create(array $details): array
{
return $this->request(new Request('POST', 'tests', body: $this->wrap('test', $details)));
}
/**
* Delete a test and its assets.
*
* @return array<mixed>
*/
public function delete(string $id): array
{
$id = $this->requireNonEmpty($id, 'Please use a valid test id or WebDriver session id');
return $this->request(new Request('DELETE', 'tests/' . $id));
}
/**
* Stop a running test.
*
* @return array<mixed>
*/
public function stop(string $id): array
{
$id = $this->requireNonEmpty($id, 'Please use a valid test id or WebDriver session id');
return $this->request(new Request('PUT', 'tests/' . $id . '/stop'));
}
}