-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathRecordGetOrganizationFixtureTest.php
More file actions
39 lines (30 loc) · 1.58 KB
/
RecordGetOrganizationFixtureTest.php
File metadata and controls
39 lines (30 loc) · 1.58 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
<?php
/**
* Record or refresh tests/Fixtures/saloon/get-organization.json from a real DocuWare tenant.
*
* 1. Set DOCUWARE_URL, DOCUWARE_USERNAME, DOCUWARE_PASSWORD in the environment.
* 2. Set DOCUWARE_RECORD_FIXTURES=true (e.g. in phpunit.xml or .env).
* 3. Run: vendor/bin/pest tests/Manual/RecordGetOrganizationFixtureTest.php
* 4. Review the JSON for secrets, then unset DOCUWARE_RECORD_FIXTURES.
*/
use CodebarAg\DocuWare\Requests\General\Organization\GetOrganization;
use Saloon\Data\RecordedResponse;
use Saloon\MockConfig;
it('records get-organization Saloon fixture', function () {
MockConfig::setFixturePath(dirname(__DIR__).'/Fixtures/saloon');
$response = getConnector()->send(new GetOrganization);
expect($response->successful())
->toBeTrue('Expected successful GetOrganization response before writing fixture; HTTP '.$response->status().'.');
$contentType = (string) $response->header('Content-Type');
expect($contentType === '' || str_contains(strtolower($contentType), 'json'))
->toBeTrue('Expected JSON Content-Type from GetOrganization; got: '.($contentType !== '' ? $contentType : '(empty)'));
$fixturePath = dirname(__DIR__).'/Fixtures/saloon/get-organization.json';
file_put_contents(
$fixturePath,
RecordedResponse::fromResponse($response)->toFile()
);
expect(file_exists($fixturePath))->toBeTrue();
})->group('manual')->skip(
fn () => ! filter_var(env('DOCUWARE_RECORD_FIXTURES', false), FILTER_VALIDATE_BOOLEAN),
'Set DOCUWARE_RECORD_FIXTURES=true to record get-organization.json against your tenant.',
);