|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Dredd\DataObjects; |
| 4 | + |
| 5 | +/** |
| 6 | + * Transaction object is passed as a first argument to |
| 7 | + * {@link https://dredd.org/en/latest/hooks/index.html#hooks hook functions} |
| 8 | + * and is one of the main public interfaces in Dredd. |
| 9 | + * |
| 10 | + * @link https://dredd.org/en/latest/data-structures.html#transaction-object |
| 11 | + */ |
| 12 | +class Transaction |
| 13 | +{ |
| 14 | + /** @var string $id */ |
| 15 | + public $id; |
| 16 | + |
| 17 | + /** |
| 18 | + * Reference to the transaction definition in the original API description document |
| 19 | + * (See also {@link https://github.com/apiaryio/dredd-transactions#user-content-data-structures Dredd Transactions}) |
| 20 | + * |
| 21 | + * @var string $name |
| 22 | + */ |
| 23 | + public $name; |
| 24 | + |
| 25 | + /** @var string $host */ |
| 26 | + public $host; |
| 27 | + |
| 28 | + /** @var int $port */ |
| 29 | + public $port; |
| 30 | + |
| 31 | + /** @var string $protocol */ |
| 32 | + public $protocol; |
| 33 | + |
| 34 | + /** |
| 35 | + * Expanded URI Template with parameters (if any) used for the HTTP request Dredd performs to the tested server |
| 36 | + * |
| 37 | + * @link https://tools.ietf.org/html/rfc6570.html |
| 38 | + * @var string $fullPath |
| 39 | + */ |
| 40 | + public $fullPath; |
| 41 | + |
| 42 | + /** |
| 43 | + * Can be set to `true` and the transaction will be skipped |
| 44 | + * |
| 45 | + * @var bool $skip |
| 46 | + */ |
| 47 | + public $skip; |
| 48 | + |
| 49 | + /** |
| 50 | + * Can be set to `true` or string and the transaction will fail |
| 51 | + * - (string) - failure message with details why the transaction failed |
| 52 | + * - (boolean) |
| 53 | + * @var bool|string $fail |
| 54 | + */ |
| 55 | + public $fail; |
| 56 | + |
| 57 | + /** @var Origin $origin */ |
| 58 | + public $origin; |
| 59 | + |
| 60 | + /** |
| 61 | + * Test data passed to Dredd’s reporters |
| 62 | + * |
| 63 | + * @link https://dredd.org/en/latest/data-structures.html#transaction-test |
| 64 | + * @var object |
| 65 | + */ |
| 66 | + public $test; |
| 67 | + |
| 68 | + /** |
| 69 | + * Transaction runtime errors |
| 70 | + * |
| 71 | + * Whenever an exception occurs during a test run it’s being recorded under the errors property of the test. |
| 72 | + * |
| 73 | + * @link https://dredd.org/en/latest/data-structures.html#test-runtime-error |
| 74 | + * @var object |
| 75 | + */ |
| 76 | + public $errors; |
| 77 | + |
| 78 | + /** |
| 79 | + * Transaction result equals to the result of the |
| 80 | + * {@link https://github.com/apiaryio/gavel.js Gavel} validation library. |
| 81 | + * |
| 82 | + * @link https://dredd.org/en/latest/data-structures.html#transaction-results |
| 83 | + * @var object |
| 84 | + */ |
| 85 | + public $results; |
| 86 | + |
| 87 | + /** |
| 88 | + * The HTTP request Dredd performs to the tested server, taken from the API description |
| 89 | + * @var Request $request |
| 90 | + */ |
| 91 | + public $request; |
| 92 | + |
| 93 | + /** @var ExpectedResponse $expected */ |
| 94 | + public $expected; |
| 95 | + |
| 96 | + /** @var RealResponse $real */ |
| 97 | + public $real; |
| 98 | + |
| 99 | + public function __construct($transaction) |
| 100 | + { |
| 101 | + $this->id = $transaction->id; |
| 102 | + $this->name = $transaction->name; |
| 103 | + $this->host = $transaction->host; |
| 104 | + $this->port = $transaction->port; |
| 105 | + $this->protocol = $transaction->protocol; |
| 106 | + $this->fullPath = $transaction->fullPath; |
| 107 | + $this->skip = $transaction->skip; |
| 108 | + $this->fail = $transaction->fail; |
| 109 | + $this->origin = new Origin($transaction->origin); |
| 110 | + $this->request = new Request($transaction->request); |
| 111 | + $this->expected = new ExpectedResponse($transaction->expected); |
| 112 | + $this->real = new RealResponse($transaction->real); |
| 113 | + } |
| 114 | +} |
0 commit comments