{"id":19647259,"url":"https://github.com/ibexa/test-rest","last_synced_at":"2026-03-06T19:07:39.818Z","repository":{"id":154479193,"uuid":"631992663","full_name":"ibexa/test-rest","owner":"ibexa","description":null,"archived":false,"fork":false,"pushed_at":"2025-12-09T23:01:06.000Z","size":76,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-03-02T16:42:24.489Z","etag":null,"topics":["ibexa-bundle","ibexa-product"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ibexa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":"COPYRIGHT","agents":null,"dco":null,"cla":null}},"created_at":"2023-04-24T13:42:07.000Z","updated_at":"2025-12-09T23:01:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"04275560-86f9-4236-ae4b-c08b6d78a2e9","html_url":"https://github.com/ibexa/test-rest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ibexa/test-rest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibexa%2Ftest-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibexa%2Ftest-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibexa%2Ftest-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibexa%2Ftest-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ibexa","download_url":"https://codeload.github.com/ibexa/test-rest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibexa%2Ftest-rest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30192445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T18:54:55.862Z","status":"ssl_error","status_checked_at":"2026-03-06T18:53:04.013Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ibexa-bundle","ibexa-product"],"created_at":"2024-11-11T14:43:06.116Z","updated_at":"2026-03-06T19:07:39.803Z","avatar_url":"https://github.com/ibexa.png","language":"PHP","readme":"# Warning\n\n**This package is considered both internal and experimental, and may change without notice.**\n\n# Ibexa REST Test package\n\nThis package is part of [Ibexa DXP](https://ibexa.co).\n\nTo use this package, [install Ibexa DXP](https://doc.ibexa.co/en/latest/install/).\n\n## Getting started\n\nThe purpose of the package is to provide Ibexa REST testing framework, reducing boilerplate code.\n\n## Installation\n\nTo start using it, install it together with [ibexa/test-core](https://github.com/ibexa/test-core):\n\n```\ncomposer req --dev ibexa/test-rest:^0.1.x-dev ibexa/test-core:^0.1.x-dev\n```\n\n## Prerequisites\n\nIt is assumed that you already have created an instance of `\\Ibexa\\Contracts\\Core\\Test\\IbexaTestKernel` and configured it\nvia `phpunit.integration.xml.dist` or similar PHPUnit configuration file, together with your `./tests/integration/bootstrap.php`.\n\n## Configuration\n\n### Register Bundles\n\nYour custom `IbexaTestKernel::registerBundles` method needs to yield your bundle instance, and at least:\n\n```php\nyield from parent::registerBundles();\nyield new \\Hautelook\\TemplatedUriBundle\\HautelookTemplatedUriBundle();\nyield new \\Ibexa\\Bundle\\Rest\\IbexaRestBundle();\nyield new \\Ibexa\\Bundle\\Test\\Rest\\IbexaTestRestBundle();\n```\n\n### Configure Container\n\nNext, create REST routing configuration file, in a similar way project configuration file is prepared via recipes, e.g.:\n`./tests/integration/Resources/REST/routing/rest.yaml`:\n\n```yaml\nibexa.acme.rest:\n  resource: '@IbexaAcmeBundle/Resources/routing/rest.yaml'\n  prefix: '%ibexa.rest.path_prefix%'\n```\n\nThen, in your custom `IbexaTestKernel::registerContainerConfiguration` method configure the following:\n\n```php\n$loader-\u003eload(static function (ContainerBuilder $container): void {\n    $container-\u003eloadFromExtension('framework', [\n        'router' =\u003e [\n            'resource' =\u003e __DIR__ . '/Resources/routing.yaml', // path to the file you've just created\n        ],\n    ]);\n  \n    $container-\u003esetParameter('form.type_extension.csrf.enabled', false);\n\n    self::addSyntheticService($container, \\Lexik\\Bundle\\JWTAuthenticationBundle\\Services\\JWTTokenManagerInterface::class);\n});\n```\n\n## Write your first test\n\nAt this point you should be able to write your first test:\n\n```php\nuse Ibexa\\Contracts\\Test\\Rest\\BaseRestWebTestCase;\nuse Ibexa\\Contracts\\Test\\Rest\\Request\\Value\\EndpointRequestDefinition;\n\nfinal class GetAcmeTest extends BaseRestWebTestCase\n{\n    protected static function getEndpointsToTest(): iterable\n    {\n        $endpointRequestDefinition = new EndpointRequestDefinition(\n            'GET',\n            '/api/ibexa/v2/acme',\n            'AcmeValue', // expected resource type\n            self::generateMediaTypeString('AcmeValue', 'xml'), // accept header\n            [], // custom HTTP headers to include in the request\n            null, // InputPayload instance for POST/PATCH requests\n            null, // custom request name for the data provider\n            'acme/acme01' // snapshot name\n        );\n\n        yield $endpointRequestDefinition;\n\n        yield $endpointRequestDefinition\n            -\u003ewithAcceptHeader(self::generateMediaTypeString('AcmeValue', 'json'));\n    }\n\n    protected function getSchemaFileBasePath(string $resourceType, string $format): string\n    {\n        return dirname(__DIR__) . '/Resources/REST/Schemas/' . $resourceType;\n    }\n\n    protected static function getSnapshotDirectory(): ?string\n    {\n        return dirname(__DIR__) . '/Resources/REST/Snapshots';\n    }\n}\n```\n\n### Base class\n\nYou need to override `\\Ibexa\\Contracts\\Test\\Rest\\BaseRestWebTestCase` class.\n\n### Define what to test\n\nThe Test case class needs to override `getEndpointsToTest` static method which should yield `EndpointRequestDefinition`\ndescribing what endpoints and how you want to test.\n\nEach `EndpointRequestDefinition` tests one endpoint, expecting one specific response format (XML or JSON).\n\n`EndpointRequestDefinition` takes the following constructor arguments, in that order:\n\n* HTTP method type (`'GET'`, `'POST'`, etc.)\n* Endpoint URI, including REST prefix.\n* Expected Resource Type the endpoint should return (e.g: `'Content'`, `'Product'`, or `null` for `NoContent`).\n* Accept HTTP header, e.g. `application/vnd.ibexa.api.Content+xml` (use\n  `self::generateMediaTypeString(resourceType, format)` syntax sugar for that).\n* Extra HTTP headers if needed.\n* Input Payload (`null` for `GET` requests). See\n  [Testing endpoints requiring input payload](#testing-endpoints-requiring-input-payload) for more details.\n* Endpoint request name used to generate PHPUnit data set name (`null` to use default name)\n* Snapshot name, see [Testing snapshots](#testing-snapshots) for more details.\n\nTo test an endpoint in another format, you can use `withAcceptHeader` method which will clone the definition changing\nAccept header.\n\n### Response contents validation against schema files\n\nREST Integration Test Framework, for each resource response, validates it against its schema (XSD or JSON).\n\nDecide where you want to keep schema files and create a directory for them, e.g.:\n`./tests/integration/Resources/REST/Schemas`. To configure it, your Test case class needs to define\n`getSchemaFileBasePath` method which returns schema file base path (including file name without an extension), e.g.:\n`./tests/integration/Resources/REST/Schemas/AcmeValue`, where in `Schemas` directory, there are two schema files:\n`AcmeValue.xsd` and `AcmeValue.json`. You can generate these schema files using IDE and/or some online tools.\n\nTypically, you'd want to create your own abstract base class defining this and make each Test case class extend it\ninstead, e.g.:\n\n```php\nabstract class BaseAcmeRestWebTestCase extends BaseRestWebTestCase\n{\n    protected function getSchemaFileBasePath(string $resourceType, string $format): string\n    {\n        return dirname(__DIR__) . '/Resources/REST/Schemas/' . $resourceType;\n    }\n}\n```\n\nFile extension is not included because it depends on a validator (e.g. XSD for XML files).\n\n### Testing snapshots\n\nIf you have a response snapshot to test against, your Test case class needs  to override `getSnapshotDirectory` method\nand define snapshot base file path (without extension) when instantiating `EndpointRequestDefinition`.\n\nREST Test Framework looks for a snapshot file concatenating:\n\n```\n\u003csnapshot_directory\u003e/\u003csnapshot_name\u003e.\u003cresponse_format:json|xml\u003e\n```\n\nIf you want to generate a snapshot at runtime, set the following environment variable:\n\n```bash\nTEST_REST_GENERATE_SNAPSHOTS=1\n```\n\n### Testing endpoints requiring input payload\n\nTo test mutation endpoints (`POST`, `PATCH`, `PUT`, etc.) you need to create input payload files and load them using\n`\\Ibexa\\Contracts\\Test\\Rest\\Input\\PayloadLoader` while creating `EndpointRequestDefinition`.\n\nExample:\n```php\n    public static function getEndpointsToTest(): iterable\n    {\n        $payloadLoader = new PayloadLoader(dirname(__DIR__) . '/Resources/REST/InputPayloads');\n\n        yield new EndpointRequestDefinition(\n            'POST',\n            '/api/ibexa/v2/acme',\n            'AcmeValue',\n            self::generateMediaTypeString('AcmeValue', 'xml'),\n            [],\n            $payloadLoader-\u003eloadPayload('AcmeValueCreate', 'xml', 'Acme/CustomPayloadFileName')\n        );\n\n        yield new EndpointRequestDefinition(\n            'POST',\n            '/api/ibexa/v2/acme',\n            'AcmeValue',\n            self::generateMediaTypeString('AcmeValue', 'json'),\n            [],\n            $payloadLoader-\u003eloadPayload('AcmeValueCreate', 'json', 'Acme/CustomPayloadFileName')\n        );\n    }\n```\n\n`PayloadLoader::loadPayload` expects 2 arguments: input Media Type, format. Optionally you can pass custom file\nbase path (without extension) as the 3rd argument. If not given, the file base path will default to the given Media Type.\n\n## COPYRIGHT\n\nCopyright (C) 1999-2025 Ibexa AS (formerly eZ Systems AS). All rights reserved.\n\n## LICENSE\n\nThis source code is available separately under the following licenses:\n\nA - Ibexa Business Use License Agreement (Ibexa BUL),\nversion 2.4 or later versions (as license terms may be updated from time to time)\nIbexa BUL is granted by having a valid Ibexa DXP (formerly eZ Platform Enterprise) subscription,\nas described at: https://www.ibexa.co/product\nFor the full Ibexa BUL license text, please see:\n- LICENSE-bul file placed in the root of this source code, or\n- https://www.ibexa.co/software-information/licenses-and-agreements (latest version applies)\n\nAND\n\nB - Ibexa Trial and Test License Agreement (Ibexa TTL),\nversion 2.2 or later versions (as license terms may be updated from time to time)\nTrial can be granted by Ibexa, reach out to Ibexa AS for evaluation access: https://www.ibexa.co/about-ibexa/contact-us\nFor the full Ibexa TTL license text, please see:\n- LICENSE file placed in the root of this source code, or\n- https://www.ibexa.co/software-information/licenses-and-agreements (latest version applies)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibexa%2Ftest-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibexa%2Ftest-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibexa%2Ftest-rest/lists"}