|
2 | 2 |
|
3 | 3 | declare(strict_types=1);
|
4 | 4 |
|
| 5 | +use Storyblok\ManagementApi\Data\WorkflowStageData; |
| 6 | +use Storyblok\ManagementApi\Endpoints\WorkflowStageApi; |
5 | 7 | use Storyblok\ManagementApi\ManagementApiClient;
|
6 | 8 | use Symfony\Component\HttpClient\MockHttpClient;
|
7 | 9 |
|
|
29 | 31 | expect($string)->toMatch('/.*by_ids=12345%2C54321.*$/');
|
30 | 32 |
|
31 | 33 | });
|
| 34 | + |
| 35 | +test('Testing one workflow stage', function (): void { |
| 36 | + $responses = [ |
| 37 | + \mockResponse("one-workflow-stage", 200, []), |
| 38 | + \mockResponse("one-workflow-stage", 200, []), |
| 39 | + //\mockResponse("empty-asset", 404), |
| 40 | + ]; |
| 41 | + |
| 42 | + $client = new MockHttpClient($responses); |
| 43 | + $mapiClient = ManagementApiClient::initTest($client); |
| 44 | + $workflowStageApi = new WorkflowStageApi($mapiClient, "222"); |
| 45 | + |
| 46 | + $storyblokResponse = $workflowStageApi->get( |
| 47 | + "653554" |
| 48 | + ); |
| 49 | + $string = $storyblokResponse->getLastCalledUrl(); |
| 50 | + expect($string)->toMatch('/.*workflow_stages\/653554.*$/'); |
| 51 | + $data = $storyblokResponse->data(); |
| 52 | + expect($data->id())->toBe("653554"); |
| 53 | + |
| 54 | +}); |
| 55 | + |
| 56 | +test('Testing delete workflow stage', function (): void { |
| 57 | + $responses = [ |
| 58 | + \mockResponse("one-workflow-stage", 200, []), |
| 59 | + \mockResponse("one-workflow-stage", 200, []), |
| 60 | + //\mockResponse("empty-asset", 404), |
| 61 | + ]; |
| 62 | + |
| 63 | + $client = new MockHttpClient($responses); |
| 64 | + $mapiClient = ManagementApiClient::initTest($client); |
| 65 | + $workflowStageApi = new WorkflowStageApi($mapiClient, "222"); |
| 66 | + |
| 67 | + $storyblokResponse = $workflowStageApi->delete( |
| 68 | + "653554" |
| 69 | + ); |
| 70 | + $string = $storyblokResponse->getLastCalledUrl(); |
| 71 | + expect($string)->toMatch('/.*workflow_stages\/653554.*$/'); |
| 72 | + $data = $storyblokResponse->data(); |
| 73 | + expect($data->id())->toBe("653554"); |
| 74 | + |
| 75 | +}); |
| 76 | + |
| 77 | +test('Testing update workflow stage', function (): void { |
| 78 | + $responses = [ |
| 79 | + \mockResponse("one-workflow-stage", 200, []), |
| 80 | + \mockResponse("one-workflow-stage", 200, []), |
| 81 | + //\mockResponse("empty-asset", 404), |
| 82 | + ]; |
| 83 | + |
| 84 | + $client = new MockHttpClient($responses); |
| 85 | + $mapiClient = ManagementApiClient::initTest($client); |
| 86 | + $workflowStageApi = new WorkflowStageApi($mapiClient, "222"); |
| 87 | + |
| 88 | + $storyblokResponse = $workflowStageApi->get( |
| 89 | + "653554" |
| 90 | + ); |
| 91 | + $data = $storyblokResponse->data(); |
| 92 | + $data->setName("Test"); |
| 93 | + $data->setWorkflowid("12345"); |
| 94 | + |
| 95 | + expect($data->name())->toBe("Test"); |
| 96 | + $storyblokResponse = $workflowStageApi->update( |
| 97 | + "653554", |
| 98 | + $data |
| 99 | + ); |
| 100 | + $data = $storyblokResponse->data(); |
| 101 | + expect($data->id())->toBe("653554"); |
| 102 | + |
| 103 | +}); |
| 104 | + |
| 105 | +test('Testing create workflow stage', function (): void { |
| 106 | + $responses = [ |
| 107 | + \mockResponse("one-workflow-stage", 200, []), |
| 108 | + \mockResponse("one-workflow-stage", 200, []), |
| 109 | + //\mockResponse("empty-asset", 404), |
| 110 | + ]; |
| 111 | + |
| 112 | + $client = new MockHttpClient($responses); |
| 113 | + $mapiClient = ManagementApiClient::initTest($client); |
| 114 | + $workflowStageApi = new WorkflowStageApi($mapiClient, "222"); |
| 115 | + |
| 116 | + $data = WorkflowStageData::make([]); |
| 117 | + $data->setName("Test"); |
| 118 | + $data->setWorkflowid("12345"); |
| 119 | + |
| 120 | + expect($data->name())->toBe("Test"); |
| 121 | + $storyblokResponse = $workflowStageApi->create( |
| 122 | + $data |
| 123 | + ); |
| 124 | + $data = $storyblokResponse->data(); |
| 125 | + expect($data->id())->toBe("653554"); |
| 126 | + |
| 127 | +}); |
0 commit comments