Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"api-platform/serializer": "self.version",
"api-platform/state": "self.version",
"api-platform/symfony": "self.version",
"api-platform/test": "self.version",
"api-platform/validator": "self.version"
},
"require": {
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/computed-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public function up(Schema $schema): void

namespace App\Tests {
use ApiPlatform\Playground\Test\TestGuideTrait;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;

final class ComputedFieldTest extends ApiTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/create-a-custom-doctrine-filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function up(Schema $schema): void

namespace App\Tests {
use ApiPlatform\Playground\Test\TestGuideTrait;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;
use App\Entity\Book;

final class BookTest extends ApiTestCase
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/custom-pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function load(ObjectManager $manager): void

namespace App\Tests {
use ApiPlatform\Playground\Test\TestGuideTrait;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;
use App\Entity\Book;

final class BookTest extends ApiTestCase
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/doctrine-entity-as-resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function load(ObjectManager $manager): void

namespace App\Tests {
use ApiPlatform\Playground\Test\TestGuideTrait;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;

final class BookTest extends ApiTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/doctrine-search-filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function load(ObjectManager $manager): void

namespace App\Tests {
use ApiPlatform\Playground\Test\TestGuideTrait;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;
use App\Entity\Book;

final class BookTest extends ApiTestCase
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/error-provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function configure(ContainerConfigurator $configurator): void

namespace App\Tests {
use ApiPlatform\Playground\Test\TestGuideTrait;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;

final class BookTest extends ApiTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/error-resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function provide(Operation $operation, array $uriVariables = [], a

namespace App\Tests {
use ApiPlatform\Playground\Test\TestGuideTrait;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;

final class BookTest extends ApiTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/extend-openapi-documentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Book

namespace App\Tests {
use ApiPlatform\Playground\Test\TestGuideTrait;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;

final class BookTest extends ApiTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/how-to.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function request(): Request

namespace App\Tests {
use ApiPlatform\Playground\Test\TestGuideTrait;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;
use App\Entity\Book;

final class BookTest extends ApiTestCase
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/http-cache-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function request(): Request

namespace App\Tests {
use ApiPlatform\Playground\Test\TestGuideTrait;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;

final class BookTest extends ApiTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/return-the-iri-of-your-resources-relations.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function request(): Request
}

namespace App\Tests {
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;
use App\ApiResource\Brand;

final class BrandTest extends ApiTestCase
Expand Down
6 changes: 3 additions & 3 deletions docs/guides/test-your-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@

namespace App\Tests {
use ApiPlatform\Playground\Test\TestGuideTrait;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;
use App\ApiResource\Book;

// API Platform [testing utilities](/docs/core/testing/) provides an [ApiTestCase](/docs/reference/Symfony/Bundle/Test/ApiTestCase/)
// API Platform [testing utilities](/docs/core/testing/) provides an [ApiTestCase](/docs/reference/Test/ApiTestCase/)
// that allows you to send an HTTP Request, and to perform assertions on the Response.
final class BookTest extends ApiTestCase
{
use TestGuideTrait;

public function testBookDoesNotExists(): void
{
// For starters we can get an [HTTP Client](/docs/reference/Symfony/Bundle/Test/Client/) with the `createClient` method.
// For starters we can get an [HTTP Client](/docs/reference/Test/Client/) with the `createClient` method.
$client = static::createClient();
// Then, issue an HTTP request via this client, as we didn't load any data we'd expect this to send a 404 Not found.
$client->request(method: 'GET', url: '/books/1');
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/validate-incoming-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function request(): Request

namespace App\Tests {
use ApiPlatform\Playground\Test\TestGuideTrait;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;

final class BookTest extends ApiTestCase
{
Expand Down
6 changes: 3 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ parameters:
objectManagerLoader: tests/Fixtures/app/object-manager.php
bootstrapFiles:
# We're aliasing classes for phpunit in this file, it needs to be added here see phpstan/#2194
- src/Symfony/Bundle/Test/Constraint/ArraySubset.php
- src/Test/Constraint/ArraySubset.php
- tests/Fixtures/app/AppKernel.php

excludePaths:
Expand Down Expand Up @@ -152,7 +152,7 @@ parameters:
- src/Metadata/Tests
- src/OpenApi/Tests
- src/Serializer/Tests
- src/Symfony/Bundle/Test
- src/Test
- src/Symfony/Tests
- tests
-
Expand All @@ -174,7 +174,7 @@ parameters:
-
identifier: argument.templateType
paths:
- src/Symfony/Bundle/Test
- src/Test
- tests
- src # TODO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler;

use ApiPlatform\Symfony\Bundle\Test\Client;
use ApiPlatform\Test\Client;
use Symfony\Component\BrowserKit\AbstractBrowser;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

declare(strict_types=1);

namespace ApiPlatform\Symfony\Bundle\Test;
namespace ApiPlatform\Test;

use ApiPlatform\JsonSchema\BackwardCompatibleSchemaFactory;
use ApiPlatform\JsonSchema\Schema;
use ApiPlatform\JsonSchema\SchemaFactoryInterface;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
use ApiPlatform\Symfony\Bundle\Test\Constraint\ArraySubset;
use ApiPlatform\Symfony\Bundle\Test\Constraint\MatchesJsonSchema;
use ApiPlatform\Test\Constraint\ArraySubset;
use ApiPlatform\Test\Constraint\MatchesJsonSchema;
use PHPUnit\Framework\Constraint\JsonMatches;
use PHPUnit\Framework\ExpectationFailedException;
use Symfony\Bundle\FrameworkBundle\Test\BrowserKitAssertionsTrait;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Symfony\Bundle\Test;
namespace ApiPlatform\Test;

use ApiPlatform\Metadata\IriConverterInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Test/Client.php → src/Test/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Symfony\Bundle\Test;
namespace ApiPlatform\Test;

use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Component\BrowserKit\CookieJar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Symfony\Bundle\Test;
namespace ApiPlatform\Test;

trait ClientTrait
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Symfony\Bundle\Test\Constraint;
namespace ApiPlatform\Test\Constraint;

use PHPUnit\Framework\Constraint\Constraint;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Symfony\Bundle\Test\Constraint;
namespace ApiPlatform\Test\Constraint;

use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Exporter\Exporter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Symfony\Bundle\Test\Constraint;
namespace ApiPlatform\Test\Constraint;

use JsonSchema\Validator;
use PHPUnit\Framework\Constraint\Constraint;
Expand Down
14 changes: 14 additions & 0 deletions src/Test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# API Platform - Test

Functional testing utilities for the [API Platform](https://api-platform.com) framework.

Provides `ApiTestCase` and test assertions for building functional tests for API Platform applications.

[Documentation](https://api-platform.com/docs/core/testing/)

> [!CAUTION]
>
> This is a read-only sub split of `api-platform/core`, please
> [report issues](https://github.com/api-platform/core/issues) and
> [send Pull Requests](https://github.com/api-platform/core/pulls)
> in the [core API Platform repository](https://github.com/api-platform/core).
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Symfony\Bundle\Test;
namespace ApiPlatform\Test;

use Symfony\Component\BrowserKit\Response as BrowserKitResponse;
use Symfony\Component\HttpClient\Exception\ClientException;
Expand Down
68 changes: 68 additions & 0 deletions src/Test/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "api-platform/test",
"description": "Testing utilities for API Platform",
"type": "library",
"keywords": [
"REST",
"API",
"GraphQL",
"JSON-LD",
"Test",
"PHPUnit"
],
"homepage": "https://api-platform.com",
"license": "MIT",
"authors": [
{
"name": "Kévin Dunglas",
"email": "kevin@dunglas.fr",
"homepage": "https://dunglas.fr"
},
{
"name": "Antoine Bluchet",
"email": "soyuka@gmail.com",
"homepage": "https://soyuka.me"
}
],
"require": {
"php": ">=8.2",
"api-platform/metadata": "^4.3",
"api-platform/json-schema": "^4.3",
"phpunit/phpunit": "^12.2",
"symfony/browser-kit": "^6.4 || ^7.0 || ^8.0",
"symfony/http-client": "^6.4 || ^7.0 || ^8.0",
"symfony/framework-bundle": "^6.4 || ^7.0 || ^8.0"
},
"suggest": {
"doctrine/orm": "To use findIriBy() with Doctrine ORM",
"doctrine/mongodb-odm": "To use findIriBy() with MongoDB",
"justinrainbow/json-schema": "To validate JSON schemas in assertions"
},
"autoload": {
"psr-4": {
"ApiPlatform\\Test\\": ""
}
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": true,
"phpstan/extension-installer": true,
"php-http/discovery": true
}
},
"extra": {
"branch-alias": {
"dev-main": "4.4.x-dev"
},
"thanks": {
"name": "api-platform/api-platform",
"url": "https://github.com/api-platform/api-platform"
}
},
"minimum-stability": "beta",
"prefer-stable": true
}
2 changes: 1 addition & 1 deletion tests/Behat/JsonContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Tests\Behat;

use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Mink\Exception\ExpectationException;
use Behatch\Context\JsonContext as BaseJsonContext;
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/ArrayDtoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Tests\Functional;

use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6211\ArrayPropertyDtoOperation;
use ApiPlatform\Tests\SetupClassResourcesTrait;

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/BackedEnumFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Tests\Functional;

use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue7126\DummyForBackedEnumFilter;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue7126\IntegerBackedEnum;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue7126\StringBackedEnum;
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/BackedEnumPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Tests\Functional;

use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;
use ApiPlatform\Tests\Fixtures\TestBundle\Document\Person as PersonDocument;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Person;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\PersonToPet;
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/BackedEnumResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\BackedEnumIntegerResource;
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\BackedEnumStringResource;
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6264\Availability;
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/DateTimeNormalizerPriorityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Tests\Functional;

use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Test\ApiTestCase;
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\DateTimeNormalizationIssue;
use ApiPlatform\Tests\SetupClassResourcesTrait;

Expand Down
Loading
Loading