Skip to content

Commit b4f7541

Browse files
committed
test: 💍 fix tests
1 parent f0b0ad9 commit b4f7541

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

tests/Functional/OpenApiTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Crud;
1818
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\CrudOpenApiApiPlatformTag;
1919
use ApiPlatform\Tests\SetupClassResourcesTrait;
20+
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
2021

2122
class OpenApiTest extends ApiTestCase
2223
{
@@ -32,8 +33,11 @@ public static function getResources(): array
3233
return [Crud::class, CrudOpenApiApiPlatformTag::class];
3334
}
3435

36+
#[IgnoreDeprecations]
3537
public function testErrorsAreDocumented(): void
3638
{
39+
$this->expectUserDeprecationMessage("Since api-platform/core 4.2: Set 'enable_json_merge_patch_schema' on extra properties to enable JSON Schema, where all required properties are optional, for JSON Merge Patch requests. This behavior will be the default starting from 5.0.");
40+
3741
$response = self::createClient()->request('GET', '/docs', [
3842
'headers' => ['Accept' => 'application/vnd.openapi+json'],
3943
]);

tests/JsonSchema/Command/JsonSchemaGenerateCommandTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\RelatedDummy;
3333
use ApiPlatform\Tests\SetupClassResourcesTrait;
3434
use PHPUnit\Framework\Attributes\DataProvider;
35+
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
3536
use Symfony\Bundle\FrameworkBundle\Console\Application;
3637
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
3738
use Symfony\Component\Console\Tester\ApplicationTester;
@@ -121,8 +122,11 @@ public function testExecuteWithJsonldTypeInput(): void
121122
$this->assertStringNotContainsString('@type', $result);
122123
}
123124

125+
#[IgnoreDeprecations]
124126
public function testExecuteWithJsonMergePatchTypeInput(): void
125127
{
128+
$this->expectUserDeprecationMessage("Since api-platform/core 4.2: Set 'enable_json_merge_patch_schema' on extra properties to enable JSON Schema, where all required properties are optional, for JSON Merge Patch requests. This behavior will be the default starting from 5.0.");
129+
126130
$this->tester->run(['command' => 'api:json-schema:generate', 'resource' => $this->entityClass, '--operation' => '_api_/dummies/{id}{._format}_patch', '--format' => 'json', '--type' => 'input']);
127131
$result = $this->tester->getDisplay();
128132
$json = json_decode($result, associative: true);

tests/OpenApi/Command/OpenApiCommandTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6317\Issue6317;
2020
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue5625\Currency;
2121
use ApiPlatform\Tests\SetupClassResourcesTrait;
22+
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
2223
use Symfony\Bundle\FrameworkBundle\Console\Application;
2324
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
2425
use Symfony\Component\Console\Tester\ApplicationTester;
@@ -57,16 +58,22 @@ public static function getResources(): array
5758
];
5859
}
5960

61+
#[IgnoreDeprecations]
6062
public function testExecute(): void
6163
{
64+
$this->expectUserDeprecationMessage("Since api-platform/core 4.2: Set 'enable_json_merge_patch_schema' on extra properties to enable JSON Schema, where all required properties are optional, for JSON Merge Patch requests. This behavior will be the default starting from 5.0.");
65+
6266
$this->tester->run(['command' => 'api:openapi:export']);
6367

6468
$this->assertJson($this->tester->getDisplay());
6569
}
6670

6771
#[\PHPUnit\Framework\Attributes\Group('orm')]
72+
#[IgnoreDeprecations]
6873
public function testExecuteWithYaml(): void
6974
{
75+
$this->expectUserDeprecationMessage("Since api-platform/core 4.2: Set 'enable_json_merge_patch_schema' on extra properties to enable JSON Schema, where all required properties are optional, for JSON Merge Patch requests. This behavior will be the default starting from 5.0.");
76+
7077
$this->tester->run(['command' => 'api:openapi:export', '--yaml' => true]);
7178

7279
$result = $this->tester->getDisplay();
@@ -119,8 +126,11 @@ public function testExecuteWithYaml(): void
119126
$this->assertStringContainsString($expected, $result);
120127
}
121128

129+
#[IgnoreDeprecations]
122130
public function testWriteToFile(): void
123131
{
132+
$this->expectUserDeprecationMessage("Since api-platform/core 4.2: Set 'enable_json_merge_patch_schema' on extra properties to enable JSON Schema, where all required properties are optional, for JSON Merge Patch requests. This behavior will be the default starting from 5.0.");
133+
124134
/** @var non-falsy-string $tmpFile */
125135
$tmpFile = tempnam(sys_get_temp_dir(), 'test_write_to_file');
126136

@@ -133,8 +143,11 @@ public function testWriteToFile(): void
133143
/**
134144
* Test issue #6317.
135145
*/
146+
#[IgnoreDeprecations]
136147
public function testBackedEnumExamplesAreNotLost(): void
137148
{
149+
$this->expectUserDeprecationMessage("Since api-platform/core 4.2: Set 'enable_json_merge_patch_schema' on extra properties to enable JSON Schema, where all required properties are optional, for JSON Merge Patch requests. This behavior will be the default starting from 5.0.");
150+
138151
$this->tester->run(['command' => 'api:openapi:export']);
139152
$result = $this->tester->getDisplay();
140153
$json = json_decode($result, true, 512, \JSON_THROW_ON_ERROR);

tests/Symfony/Bundle/Twig/ApiPlatformProfilerPanelTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\RelatedOwnedDummy;
2020
use ApiPlatform\Tests\RecreateSchemaTrait;
2121
use ApiPlatform\Tests\SetupClassResourcesTrait;
22+
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
2223
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
2324

2425
/**
@@ -41,8 +42,11 @@ public static function getResources(): array
4142
];
4243
}
4344

45+
#[IgnoreDeprecations]
4446
public function testDebugBarContentNotResourceClass(): void
4547
{
48+
$this->expectUserDeprecationMessage("Since api-platform/core 4.2: Set 'enable_json_merge_patch_schema' on extra properties to enable JSON Schema, where all required properties are optional, for JSON Merge Patch requests. This behavior will be the default starting from 5.0.");
49+
4650
$client = static::createClient();
4751
$client->enableProfiler();
4852
// Using html to get default Swagger UI
@@ -80,8 +84,11 @@ public function testDebugBarContent(): void
8084
$this->assertSame($this->isMongoDB() ? DocumentDummy::class : Dummy::class, $block->filterXPath('//div[@class="sf-toolbar-info-piece"][./b[contains(., "Resource Class")]]/span')->html());
8185
}
8286

87+
#[IgnoreDeprecations]
8388
public function testProfilerGeneralLayoutNotResourceClass(): void
8489
{
90+
$this->expectUserDeprecationMessage("Since api-platform/core 4.2: Set 'enable_json_merge_patch_schema' on extra properties to enable JSON Schema, where all required properties are optional, for JSON Merge Patch requests. This behavior will be the default starting from 5.0.");
91+
8592
$client = static::createClient();
8693
$client->enableProfiler();
8794
// Using html to get default Swagger UI

0 commit comments

Comments
 (0)