|
@@ -0,0 +1,121 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+namespace Opentalent\OtCore\Tests\Unit\Fixtures;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+use TYPO3\CMS\Core\Http\HtmlResponse;
|
|
|
|
|
+use TYPO3\CMS\Core\Http\JsonResponse;
|
|
|
|
|
+use TYPO3\CMS\Core\Http\Response;
|
|
|
|
|
+
|
|
|
|
|
+class ApiResponseFixtures
|
|
|
|
|
+{
|
|
|
|
|
+ private $responses = [
|
|
|
|
|
+ 'stub' => '{"@context": "/api/contexts/PortailOrganization"}',
|
|
|
|
|
+ 'org-1' => '
|
|
|
|
|
+ {
|
|
|
|
|
+ "@context": "/api/contexts/PortailOrganization",
|
|
|
|
|
+ "@id": "/api/public/organizations?_format=json&filter[where][id]=1",
|
|
|
|
|
+ "@type": "hydra:PagedCollection",
|
|
|
|
|
+ "hydra:totalItems": 1,
|
|
|
|
|
+ "hydra:itemsPerPage": 30,
|
|
|
|
|
+ "hydra:firstPage": "/api/public/organizations?_format=json&filter%5Bwhere%5D%5Bid%5D=1",
|
|
|
|
|
+ "hydra:lastPage": "/api/public/organizations?_format=json&filter%5Bwhere%5D%5Bid%5D=1",
|
|
|
|
|
+ "hydra:member": [
|
|
|
|
|
+ {
|
|
|
|
|
+ "@id": "/api/public/organizations/1",
|
|
|
|
|
+ "@type": "PortailOrganization",
|
|
|
|
|
+ "subDomain": "org",
|
|
|
|
|
+ "name": "Name",
|
|
|
|
|
+ "slug": "org-1",
|
|
|
|
|
+ "principalType": "ARTISTIC_PRACTICE_ONLY",
|
|
|
|
|
+ "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi faucibus nulla et nulla maximus tempor. Nullam eros nunc, sodales nec turpis vel, semper consectetur eros. Vivamus id porttitor turpis. Cras at urna faucibus, cursus eros ac, eleifend enim. Maecenas id leo id ante lacinia tempor. Cras est eros, pellentesque et luctus non, tempor in turpis. Maecenas interdum, nisi eu posuere vestibulum, ex erat accumsan sem, in tempor sem mi scelerisque sapien. ",
|
|
|
|
|
+ "categories": [
|
|
|
|
|
+ "1MC"
|
|
|
|
|
+ ],
|
|
|
|
|
+ "addressCity": "CITY",
|
|
|
|
|
+ "postalCode": "00000",
|
|
|
|
|
+ "streetAddress": "street",
|
|
|
|
|
+ "latitude": 1.2345,
|
|
|
|
|
+ "longitude": 1.2345,
|
|
|
|
|
+ "country": "France",
|
|
|
|
|
+ "logo": "https://api.opentalent.fr/_internal/secure/files/1",
|
|
|
|
|
+ "parentName": "Network",
|
|
|
|
|
+ "parentSubDomain": "network"
|
|
|
|
|
+ }],
|
|
|
|
|
+ "hydra:search": {}
|
|
|
|
|
+ }',
|
|
|
|
|
+ 'event-2' => '
|
|
|
|
|
+ {
|
|
|
|
|
+ "@context": "/api/contexts/PortailEvent",
|
|
|
|
|
+ "@id": "/api/public/events?_format=json&filter[where][id]=2",
|
|
|
|
|
+ "@type": "hydra:PagedCollection",
|
|
|
|
|
+ "hydra:totalItems": 1,
|
|
|
|
|
+ "hydra:itemsPerPage": 30,
|
|
|
|
|
+ "hydra:firstPage": "/api/public/events?_format=json&filter%5Bwhere%5D%5Bid%5D=2",
|
|
|
|
|
+ "hydra:lastPage": "/api/public/events?_format=json&filter%5Bwhere%5D%5Bid%5D=2",
|
|
|
|
|
+ "hydra:member": [
|
|
|
|
|
+ {
|
|
|
|
|
+ "@id": "/api/public/events/2",
|
|
|
|
|
+ "@type": "PortailEvent",
|
|
|
|
|
+ "organizationId": 1,
|
|
|
|
|
+ "subDomain": "org",
|
|
|
|
|
+ "name": "The Event",
|
|
|
|
|
+ "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi faucibus nulla et nulla maximus tempor. Nullam eros nunc, sodales nec turpis vel, semper consectetur eros. Vivamus id porttitor turpis. Cras at urna faucibus, cursus eros ac, eleifend enim. Maecenas id leo id ante lacinia tempor. Cras est eros, pellentesque et luctus non, tempor in turpis. Maecenas interdum, nisi eu posuere vestibulum, ex erat accumsan sem, in tempor sem mi scelerisque sapien. ",
|
|
|
|
|
+ "categories": [],
|
|
|
|
|
+ "url": "http://www.org.fr/",
|
|
|
|
|
+ "rule": null,
|
|
|
|
|
+ "datetimeStart": "2021-01-01T17:00:00+00:00",
|
|
|
|
|
+ "datetimeEnd": "2021-01-01T18:00:00+00:00",
|
|
|
|
|
+ "dates": null,
|
|
|
|
|
+ "placeName": "Place",
|
|
|
|
|
+ "placeDescription": null,
|
|
|
|
|
+ "placeFloorSize": null,
|
|
|
|
|
+ "placeCapacity": null,
|
|
|
|
|
+ "city": "City",
|
|
|
|
|
+ "postalCode": "00000",
|
|
|
|
|
+ "streetAddress": "street",
|
|
|
|
|
+ "longitude": 1.2345,
|
|
|
|
|
+ "latitude": 1.2345,
|
|
|
|
|
+ "roomName": null,
|
|
|
|
|
+ "roomDescription": null,
|
|
|
|
|
+ "roomLocalisation": null,
|
|
|
|
|
+ "roomCapacity": null,
|
|
|
|
|
+ "roomFloorSize": null,
|
|
|
|
|
+ "zupId": null,
|
|
|
|
|
+ "deepLink": null,
|
|
|
|
|
+ "image": "https://api.opentalent.fr/_internal/secure/files/2",
|
|
|
|
|
+ "priceMini": null,
|
|
|
|
|
+ "meetingSchedule": [],
|
|
|
|
|
+ "api": true,
|
|
|
|
|
+ "parentName": "Network",
|
|
|
|
|
+ "parentSubDomain": "network"
|
|
|
|
|
+ }
|
|
|
|
|
+ ],
|
|
|
|
|
+ "hydra:search":{}
|
|
|
|
|
+ }'
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ private $map = [
|
|
|
|
|
+ 'https://api.opentalent.fr/api/public/organizations?_format=json&itemsPerPage=10&foo=1' => 'stub',
|
|
|
|
|
+ 'https://api.opentalent.fr/api/public/organizations?_format=json&itemsPerPage=8' => 'stub',
|
|
|
|
|
+ 'https://api.opentalent.fr/api/public/organizations?_format=json&filter%5Bwhere%5D%5Bid%5D=1&page=1&totalItems=1&itemsPerPage=8' => 'org-1',
|
|
|
|
|
+ 'https://api.opentalent.fr/api/public/organizations?_format=json&filter%5Bwhere%5D%5Bid%5D=1&itemsPerPage=8' => 'org-1',
|
|
|
|
|
+ 'https://api.opentalent.fr/api/public/events?_format=json&itemsPerPage=8&filter[where][id]=2' => 'event-2'
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ public function get($url) {
|
|
|
|
|
+ if (array_key_exists($url, $this->map)) {
|
|
|
|
|
+ $query = $this->map[$url];
|
|
|
|
|
+ $response = new HtmlResponse(
|
|
|
|
|
+ $this->responses[$query],
|
|
|
|
|
+ 200,
|
|
|
|
|
+ []
|
|
|
|
|
+ );
|
|
|
|
|
+ return $response;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|