-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTransaction.php
More file actions
118 lines (100 loc) · 3.25 KB
/
Transaction.php
File metadata and controls
118 lines (100 loc) · 3.25 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
namespace Dredd\DataObjects;
use stdClass;
/**
* Transaction object is passed as a first argument to
* {@link https://dredd.org/en/latest/hooks/index.html#hooks hook functions}
* and is one of the main public interfaces in Dredd.
*
* @link https://dredd.org/en/latest/data-structures.html#transaction-object
*/
class Transaction
{
/** @var string $id */
public $id;
/**
* Reference to the transaction definition in the original API description document
* (See also {@link https://github.com/apiaryio/dredd-transactions#user-content-data-structures Dredd Transactions})
*
* @var string $name
*/
public $name;
/** @var string $host */
public $host;
/** @var int $port */
public $port;
/** @var string $protocol */
public $protocol;
/**
* Expanded URI Template with parameters (if any) used for the HTTP request Dredd performs to the tested server
*
* @link https://tools.ietf.org/html/rfc6570.html
* @var string $fullPath
*/
public $fullPath;
/**
* Can be set to `true` and the transaction will be skipped
*
* @var bool $skip
*/
public $skip;
/**
* Can be set to `true` or string and the transaction will fail
* - (string) - failure message with details why the transaction failed
* - (boolean)
* @var bool|string $fail
*/
public $fail;
/** @var Origin $origin */
public $origin;
/**
* Test data passed to Dredd’s reporters
*
* @link https://dredd.org/en/latest/data-structures.html#transaction-test
* @var object
*/
public $test;
/**
* Transaction runtime errors
*
* Whenever an exception occurs during a test run it’s being recorded under the errors property of the test.
*
* @link https://dredd.org/en/latest/data-structures.html#test-runtime-error
* @var object
*/
public $errors;
/**
* Transaction result equals to the result of the
* {@link https://github.com/apiaryio/gavel.js Gavel} validation library.
*
* @link https://dredd.org/en/latest/data-structures.html#transaction-results
* @var object
*/
public $results;
/**
* The HTTP request Dredd performs to the tested server, taken from the API description
* @var Request $request
*/
public $request;
/** @var ExpectedResponse $expected */
public $expected;
/** @var RealResponse $real */
public $real;
public function __construct($transaction)
{
$this->id = $transaction->id;
$this->name = $transaction->name;
$this->host = $transaction->host;
$this->port = $transaction->port;
$this->protocol = $transaction->protocol;
$this->fullPath = $transaction->fullPath;
$this->skip = $transaction->skip ?? false;
$this->fail = $transaction->fail ?? false;
$this->errors = $transaction->errors ?? new stdClass();
$this->results = $transaction->results ?? new stdClass();
$this->origin = new Origin($transaction->origin);
$this->request = new Request($transaction->request);
$this->expected = new ExpectedResponse($transaction->expected);
$this->real = new RealResponse($transaction->real);
}
}