Skip to content

Commit d295c65

Browse files
committed
minor: remove Factories trait usage in test when possible
1 parent d7496e8 commit d295c65

20 files changed

+38
-38
lines changed

phpunit-deprecation-baseline.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
Foundry now leverages the native PHP lazy system to auto-refresh objects (it can be enabled with "zenstruck_foundry.enable_auto_refresh_with_lazy_objects" configuration).
1414
See https://github.com/zenstruck/foundry/blob/2.x/UPGRADE-2.7.md to upgrade.]]></issue>
1515

16-
<issue><![CDATA[Since zenstruck/foundry 2.8: Trait Zenstruck\Foundry\Test\Factories is deprecated and will be removed in Foundry 3. See https://github.com/zenstruck/foundry/blob/2.x/UPGRADE-2.8.md to upgrade.]]></issue>
17-
<issue><![CDATA[Since zenstruck/foundry 2.8: Not using Foundry's PHPUnit extension is deprecated and will throw an error in Foundry 3. See https://github.com/zenstruck/foundry/blob/2.x/UPGRADE-2.8.md to upgrade.]]></issue>
16+
<issue><![CDATA[Since zenstruck/foundry 2.9: Trait Zenstruck\Foundry\Test\Factories is deprecated and will be removed in Foundry 3. See https://github.com/zenstruck/foundry/blob/2.x/UPGRADE-2.9.md to upgrade.]]></issue>
17+
<issue><![CDATA[Since zenstruck/foundry 2.9: Not using Foundry's PHPUnit extension is deprecated and will throw an error in Foundry 3. See https://github.com/zenstruck/foundry/blob/2.x/UPGRADE-2.9.md to upgrade.]]></issue>
1818

1919
<issue><![CDATA[Since doctrine/mongodb-odm 2.14: Not using native lazy objects is deprecated and will be impossible in Doctrine MongoDB ODM 3.0.]]></issue>
2020
</line>

src/Configuration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Zenstruck\Foundry\Persistence\PersistedObjectsTracker;
2323
use Zenstruck\Foundry\Persistence\PersistenceManager;
2424
use Zenstruck\Foundry\PHPUnit\FoundryExtension;
25-
use Zenstruck\Foundry\Test\Factories;
2625

2726
/**
2827
* @author Kevin Bond <kevinbond@gmail.com>

src/PHPUnit/BootFoundryOnPreparationStarted.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public function notify(Event\Test\PreparationStarted $event): void
3333
return;
3434
}
3535
/** @var Event\Code\TestMethod $test */
36-
3736
$this->bootFoundry($test->className());
3837
}
3938

src/PHPUnit/DataProvider/TriggerDataProviderPersistenceOnTestPrepared.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public function notify(Event\Test\Prepared $event): void
3030
return;
3131
}
3232
/** @var Event\Code\TestMethod $test */
33-
3433
if (!$test->testData()->hasDataFromDataProvider() || $test->metadata()->isDataProvider()->isEmpty()) {
3534
return;
3635
}

src/PHPUnit/FoundryExtension.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
* @internal
2626
* @author Nicolas PHILIPPE <nikophil@gmail.com>
2727
*/
28-
29-
if (interface_exists(Runner\Extension\Extension::class)) {
28+
if (\interface_exists(Runner\Extension\Extension::class)) {
3029
final class FoundryExtension implements Runner\Extension\Extension
3130
{
3231
private static bool $enabled = false;

src/PHPUnit/KernelTestCaseHelper.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the zenstruck/foundry package.
5+
*
6+
* (c) Kevin Bond <kevinbond@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Zenstruck\Foundry\PHPUnit;
413

514
use PHPUnit\Framework\TestCase;

src/Persistence/PersistentObjectFromDataProviderRegistry.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the zenstruck/foundry package.
5+
*
6+
* (c) Kevin Bond <kevinbond@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Zenstruck\Foundry\Persistence;
413

514
/**
@@ -56,8 +65,8 @@ public function addDataset(string $className, string $methodName, callable $data
5665

5766
$dataProviderResult = $dataProviderResult();
5867

59-
if (!is_array($dataProviderResult)) {
60-
$dataProviderResult = iterator_to_array($dataProviderResult);
68+
if (!\is_array($dataProviderResult)) {
69+
$dataProviderResult = \iterator_to_array($dataProviderResult);
6170
}
6271

6372
$testCaseContext = $this->testCaseContext($className, $methodName);
@@ -79,7 +88,7 @@ public function deferObjectCreation(PersistentObjectFactory $factory): object
7988
return $this->objectsBuffer[] = ProxyGenerator::wrapFactory($factory);
8089
}
8190

82-
return array_shift($this->objectsBuffer); // @phpstan-ignore return.type
91+
return \array_shift($this->objectsBuffer); // @phpstan-ignore return.type
8392
}
8493

8594
public function triggerPersistenceForDataset(string $className, string $methodName, int|string $dataSetName): void

tests/Integration/Attribute/WithStory/ParentClassWithStoryAttributeTestCase.php

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

1616
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1717
use Zenstruck\Foundry\Attribute\WithStory;
18-
use Zenstruck\Foundry\Test\Factories;
1918
use Zenstruck\Foundry\Test\ResetDatabase;
2019
use Zenstruck\Foundry\Tests\Fixture\Stories\EntityStory;
2120
use Zenstruck\Foundry\Tests\Integration\RequiresORM;
@@ -26,5 +25,5 @@
2625
#[WithStory(EntityStory::class)]
2726
abstract class ParentClassWithStoryAttributeTestCase extends KernelTestCase
2827
{
29-
use Factories, RequiresORM, ResetDatabase;
28+
use RequiresORM, ResetDatabase;
3029
}

tests/Integration/Attribute/WithStory/WithStoryOnClassTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
2020
use Zenstruck\Foundry\Attribute\WithStory;
2121
use Zenstruck\Foundry\PHPUnit\FoundryExtension;
22-
use Zenstruck\Foundry\Test\Factories;
2322
use Zenstruck\Foundry\Test\ResetDatabase;
2423
use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory;
2524
use Zenstruck\Foundry\Tests\Fixture\Stories\EntityPoolStory;
@@ -35,7 +34,7 @@
3534
#[WithStory(EntityStory::class)]
3635
final class WithStoryOnClassTest extends KernelTestCase
3736
{
38-
use Factories, RequiresORM, ResetDatabase;
37+
use RequiresORM, ResetDatabase;
3938

4039
#[Test]
4140
public function can_use_story_in_attribute(): void

tests/Integration/Attribute/WithStory/WithStoryOnMethodTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
2020
use Zenstruck\Foundry\Attribute\WithStory;
2121
use Zenstruck\Foundry\PHPUnit\FoundryExtension;
22-
use Zenstruck\Foundry\Test\Factories;
2322
use Zenstruck\Foundry\Test\ResetDatabase;
2423
use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory;
2524
use Zenstruck\Foundry\Tests\Fixture\Stories\EntityPoolStory;
@@ -35,7 +34,7 @@
3534
#[RequiresPhpunitExtension(FoundryExtension::class)]
3635
final class WithStoryOnMethodTest extends KernelTestCase
3736
{
38-
use Factories, RequiresORM, ResetDatabase;
37+
use RequiresORM, ResetDatabase;
3938

4039
#[Test]
4140
#[WithStory(EntityStory::class)]

0 commit comments

Comments
 (0)