Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aa06987

Browse files
committed
chore: skip legacy proxy tests using #[RequiresMethod]
1 parent d7add25 commit aa06987

14 files changed

Lines changed: 30 additions & 33 deletions

phpunit

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ case ${PHPUNIT_VERSION} in
8888
if [ "${WITH_LOWEST_DEPENDENCIES:-0}" = "1" ]; then
8989
PHPUNIT_EXEC="${PHPUNIT_EXEC} --do-not-fail-on-deprecation --do-not-fail-on-phpunit-deprecation"
9090
fi
91-
92-
if [ "$(can_use_legacy_proxies)" = "0" ]; then
93-
PHPUNIT_EXEC="${PHPUNIT_EXEC} --exclude-group legacy-proxy"
94-
fi
9591
;;
9692
esac
9793

phpunit-deprecation-baseline.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<issue><![CDATA[Since symfony/var-exporter 7.3: Generating lazy proxy for class "Zenstruck\Foundry\Tests\Integration\ForceFactoriesTraitUsage\SomeObject" is deprecated; leverage native lazy objects instead.]]></issue>
88
<issue><![CDATA[Since symfony/var-exporter 7.3: Using ProxyHelper::generateLazyGhost() is deprecated, use native lazy objects instead.]]></issue>
99
<issue><![CDATA[Since symfony/var-exporter 7.3: The "Symfony\Component\VarExporter\LazyGhostTrait" trait is deprecated, use native lazy objects instead.]]></issue>
10+
<issue><![CDATA[Since symfony/var-exporter 7.3: The "Symfony\Component\VarExporter\LazyProxyTrait" trait is deprecated, use native lazy objects instead.]]></issue>
1011

1112
<issue><![CDATA[Since zenstruck/foundry 2.7: Proxy usage is deprecated in PHP 8.4. Use directly PersistentObjectFactory, Foundry now leverages the native PHP lazy system to auto-refresh objects.]]></issue>
1213
<issue><![CDATA[Since zenstruck/foundry 2.7: Proxy usage is deprecated in PHP 8.4. You should extend directly PersistentObjectFactory in your factories.

tests/Integration/DataProvider/DataProviderWithPersistentFactoryInKernelTestCase.php

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use PHPUnit\Framework\Attributes\DataProvider;
1717
use PHPUnit\Framework\Attributes\Group;
1818
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
19+
use PHPUnit\Framework\Attributes\RequiresMethod;
1920
use PHPUnit\Framework\Attributes\RequiresPhp;
2021
use PHPUnit\Framework\Attributes\RequiresPhpunit;
2122
use PHPUnit\Framework\Attributes\RequiresPhpunitExtension;
@@ -46,7 +47,7 @@ abstract class DataProviderWithPersistentFactoryInKernelTestCase extends KernelT
4647

4748
#[Test]
4849
#[DataProvider('createOneProxyObjectInDataProvider')]
49-
#[Group('legacy-proxy')]
50+
#[RequiresMethod(\Symfony\Component\VarExporter\LazyProxyTrait::class, 'createLazyProxy')]
5051
public function assert_it_can_create_one_object_in_data_provider(?GenericModel $providedData): void
5152
{
5253
static::proxyFactory()::assert()->count(1);
@@ -58,12 +59,6 @@ public function assert_it_can_create_one_object_in_data_provider(?GenericModel $
5859

5960
public static function createOneProxyObjectInDataProvider(): iterable
6061
{
61-
if (!TestKernel::canUseLegacyProxy()) {
62-
yield [null];
63-
64-
return;
65-
}
66-
6762
yield 'createOne()' => [
6863
static::proxyFactory()::createOne(['prop1' => 'value set in data provider']),
6964
];
@@ -75,7 +70,7 @@ public static function createOneProxyObjectInDataProvider(): iterable
7570

7671
#[Test]
7772
#[DataProvider('createMultipleObjectsInDataProvider')]
78-
#[Group('legacy-proxy')]
73+
#[RequiresMethod(\Symfony\Component\VarExporter\LazyProxyTrait::class, 'createLazyProxy')]
7974
public function assert_it_can_create_multiple_objects_in_data_provider(?array $providedData): void
8075
{
8176
self::assertIsArray($providedData);
@@ -86,12 +81,6 @@ public function assert_it_can_create_multiple_objects_in_data_provider(?array $p
8681

8782
public static function createMultipleObjectsInDataProvider(): iterable
8883
{
89-
if (!TestKernel::canUseLegacyProxy()) {
90-
yield [[]];
91-
92-
return;
93-
}
94-
9584
yield 'createSequence()' => [
9685
static::proxyFactory()::createSequence([
9786
['prop1' => 'prop 1'],
@@ -109,7 +98,7 @@ public static function createMultipleObjectsInDataProvider(): iterable
10998

11099
#[Test]
111100
#[DataProvider('useGetterOnProxyObjectCreatedInDataProvider')]
112-
#[Group('legacy-proxy')]
101+
#[RequiresMethod(\Symfony\Component\VarExporter\LazyProxyTrait::class, 'createLazyProxy')]
113102
public function assert_using_getter_proxy_object_created_in_a_data_provider_throws(?\Throwable $e): void
114103
{
115104
self::assertInstanceOf(\LogicException::class, $e);

tests/Integration/DataProvider/GenericEntityProxyFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\Attributes\Group;
1515
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
16+
use PHPUnit\Framework\Attributes\RequiresMethod;
1617
use PHPUnit\Framework\Attributes\RequiresPhpunit;
1718
use PHPUnit\Framework\Attributes\RequiresPhpunitExtension;
1819
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;
@@ -28,7 +29,7 @@
2829
#[RequiresPhpunit('>=11.4')]
2930
#[RequiresPhpunitExtension(FoundryExtension::class)]
3031
#[IgnoreDeprecations]
31-
#[Group('legacy-proxy')]
32+
#[RequiresMethod(\Symfony\Component\VarExporter\LazyProxyTrait::class, 'createLazyProxy')]
3233
final class GenericEntityProxyFactoryTest extends DataProviderWithPersistentFactoryInKernelTestCase
3334
{
3435
use RequiresORM;

tests/Integration/ForceFactoriesTraitUsage/ClassExtendingBaseTestCaseNotUsingFactoriesTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use PHPUnit\Framework\Attributes\Group;
1717
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
18+
use PHPUnit\Framework\Attributes\RequiresMethod;
1819
use PHPUnit\Framework\Attributes\RequiresPhpunit;
1920
use PHPUnit\Framework\Attributes\Test;
2021

@@ -28,7 +29,7 @@ final class ClassExtendingBaseTestCaseNotUsingFactoriesTest extends AnotherBaseT
2829

2930
#[Test]
3031
#[IgnoreDeprecations]
31-
#[Group('legacy-proxy')]
32+
#[RequiresMethod(\Symfony\Component\VarExporter\LazyProxyTrait::class, 'createLazyProxy')]
3233
public function using_foundry_should_trigger_deprecation(): void
3334
{
3435
$this->assertDeprecation();

tests/Integration/ForceFactoriesTraitUsage/ClassExtendingBaseTestCaseUsingFactoriesTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use PHPUnit\Framework\Attributes\Group;
1717
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
18+
use PHPUnit\Framework\Attributes\RequiresMethod;
1819
use PHPUnit\Framework\Attributes\RequiresPhpunit;
1920
use PHPUnit\Framework\Attributes\Test;
2021

@@ -26,7 +27,7 @@
2627
final class ClassExtendingBaseTestCaseUsingFactoriesTest extends KernelTestCaseWithFactoriesTraitBaseTestCase
2728
{
2829
#[Test]
29-
#[Group('legacy-proxy')]
30+
#[RequiresMethod(\Symfony\Component\VarExporter\LazyProxyTrait::class, 'createLazyProxy')]
3031
public function not_using_foundry_should_not_throw(): void
3132
{
3233
$this->expectNotToPerformAssertions();

tests/Integration/InMemory/DoctrineInMemoryDecoratorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use PHPUnit\Framework\Attributes\Group;
1717
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
18+
use PHPUnit\Framework\Attributes\RequiresMethod;
1819
use PHPUnit\Framework\Attributes\RequiresPhpunit;
1920
use PHPUnit\Framework\Attributes\RequiresPhpunitExtension;
2021
use PHPUnit\Framework\Attributes\Test;
@@ -183,7 +184,7 @@ public function it_can_find_by_entity(): void
183184
*/
184185
#[Test]
185186
#[IgnoreDeprecations]
186-
#[Group('legacy-proxy')]
187+
#[RequiresMethod(\Symfony\Component\VarExporter\LazyProxyTrait::class, 'createLazyProxy')]
187188
public function it_can_find_by_entity_proxified(): void
188189
{
189190
ContactFactory::createMany(2, fn() => ['category' => CategoryFactory::createOne()]);

tests/Integration/Mongo/GenericDocumentProxyFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\Attributes\Group;
1515
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
16+
use PHPUnit\Framework\Attributes\RequiresMethod;
1617
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
1718
use Zenstruck\Foundry\Tests\Fixture\Document\DocumentWithReadonly;
1819
use Zenstruck\Foundry\Tests\Fixture\Factories\Document\GenericProxyDocumentFactory;
@@ -25,7 +26,7 @@
2526
* @author Kevin Bond <[email protected]>
2627
*/
2728
#[IgnoreDeprecations]
28-
#[Group('legacy-proxy')]
29+
#[RequiresMethod(\Symfony\Component\VarExporter\LazyProxyTrait::class, 'createLazyProxy')]
2930
final class GenericDocumentProxyFactoryTest extends GenericProxyFactoryTestCase
3031
{
3132
use RequiresMongo;

tests/Integration/ORM/EntityRelationship/ProxyEntityFactoryRelationshipTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use PHPUnit\Framework\Attributes\Group;
2121
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
2222
use PHPUnit\Framework\Attributes\IgnorePhpunitWarnings;
23+
use PHPUnit\Framework\Attributes\RequiresMethod;
2324
use PHPUnit\Framework\Attributes\RequiresPhp;
2425
use PHPUnit\Framework\Attributes\RequiresPhpunit;
2526
use PHPUnit\Framework\Attributes\Test;
@@ -39,7 +40,7 @@
3940
*/
4041
#[RequiresPhpunit('>=11.4')]
4142
#[IgnoreDeprecations]
42-
#[Group('legacy-proxy')]
43+
#[RequiresMethod(\Symfony\Component\VarExporter\LazyProxyTrait::class, 'createLazyProxy')]
4344
final class ProxyEntityFactoryRelationshipTest extends EntityFactoryRelationshipTestCase
4445
{
4546
/** @test */

tests/Integration/ORM/GenericEntityProxyFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\Attributes\Group;
1515
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
16+
use PHPUnit\Framework\Attributes\RequiresMethod;
1617
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
1718
use Zenstruck\Foundry\Tests\Fixture\Entity\EdgeCases\EntityWithReadonly\EntityWithReadonly;
1819
use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericProxyEntityFactory;
@@ -26,7 +27,7 @@
2627
* @group legacy
2728
*/
2829
#[IgnoreDeprecations]
29-
#[Group('legacy-proxy')]
30+
#[RequiresMethod(\Symfony\Component\VarExporter\LazyProxyTrait::class, 'createLazyProxy')]
3031
final class GenericEntityProxyFactoryTest extends GenericProxyFactoryTestCase
3132
{
3233
use RequiresORM;

0 commit comments

Comments
 (0)