Skip to content

Commit

Permalink
tests: add paratest permutation
Browse files Browse the repository at this point in the history
  • Loading branch information
nikophil committed Dec 8, 2024
1 parent c8f5046 commit 628d46f
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 20 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,36 @@ jobs:
run: ./phpunit
shell: bash

test-with-paratest:
name: Test with paratest
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
coverage: none
tools: flex

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
dependency-versions: highest
composer-options: --prefer-dist
env:
SYMFONY_REQUIRE: 7.2.*

- name: Set up MySQL
if: contains(matrix.database, 'mysql')
run: sudo /etc/init.d/mysql start

- name: Test
run: vendor/bin/paratest --processes 1 --configuration phpunit-paratest.xml.dist
shell: bash

code-coverage:
name: Code Coverage
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8",
"brianium/paratest": "^7.6",
"dama/doctrine-test-bundle": "^7.0|^8.0",
"doctrine/collections": "^1.7|^2.0",
"doctrine/common": "^3.2",
Expand Down
30 changes: 30 additions & 0 deletions phpunit-paratest.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
bootstrap="tests/bootstrap.php"
colors="true"
failOnRisky="true"
failOnWarning="true"
cacheDirectory=".phpunit.cache">
<php>
<ini name="error_reporting" value="-1"/>
<server name="KERNEL_CLASS" value="Zenstruck\Foundry\Tests\Fixture\TestKernel"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
</php>
<testsuites>
<testsuite name="zenstruck/foundry Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<source ignoreSuppressionOfDeprecations="true">
<include>
<directory>src</directory>
</include>
</source>
<extensions>
<bootstrap class="Zenstruck\Foundry\PHPUnit\FoundryExtension" />
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
</extensions>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use PHPUnit\Framework\Attributes\RequiresPhpunit;
use PHPUnit\Framework\Attributes\RequiresPhpunitExtension;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Zenstruck\Foundry\Attribute\WithStory;
use Zenstruck\Foundry\PHPUnit\FoundryExtension;
Expand All @@ -27,9 +28,9 @@

/**
* @author Nicolas PHILIPPE <[email protected]>
* @requires PHPUnit 11
* @requires PHPUnit ^11.0
*/
#[RequiresPhpunit('11')]
#[RequiresPhpunit('^11.0')]
#[RequiresPhpunitExtension(FoundryExtension::class)]
#[WithStory(EntityStory::class)]
final class WithStoryOnClassTest extends KernelTestCase
Expand All @@ -39,6 +40,7 @@ final class WithStoryOnClassTest extends KernelTestCase
/**
* @test
*/
#[Test]
public function can_use_story_in_attribute(): void
{
GenericEntityFactory::assert()->count(2);
Expand All @@ -50,6 +52,7 @@ public function can_use_story_in_attribute(): void
/**
* @test
*/
#[Test]
#[WithStory(EntityStory::class)]
public function can_use_story_in_attribute_multiple_times(): void
{
Expand All @@ -59,6 +62,7 @@ public function can_use_story_in_attribute_multiple_times(): void
/**
* @test
*/
#[Test]
#[WithStory(EntityPoolStory::class)]
public function can_use_another_story_at_level_class(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use PHPUnit\Framework\Attributes\RequiresPhpunit;
use PHPUnit\Framework\Attributes\RequiresPhpunitExtension;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Zenstruck\Foundry\Attribute\WithStory;
use Zenstruck\Foundry\PHPUnit\FoundryExtension;
Expand All @@ -28,9 +29,9 @@

/**
* @author Nicolas PHILIPPE <[email protected]>
* @requires PHPUnit 11
* @requires PHPUnit ^11.0
*/
#[RequiresPhpunit('11')]
#[RequiresPhpunit('^11.0')]
#[RequiresPhpunitExtension(FoundryExtension::class)]
final class WithStoryOnMethodTest extends KernelTestCase
{
Expand All @@ -39,6 +40,7 @@ final class WithStoryOnMethodTest extends KernelTestCase
/**
* @test
*/
#[Test]
#[WithStory(EntityStory::class)]
public function can_use_story_in_attribute(): void
{
Expand All @@ -51,6 +53,7 @@ public function can_use_story_in_attribute(): void
/**
* @test
*/
#[Test]
#[WithStory(EntityStory::class)]
#[WithStory(EntityPoolStory::class)]
public function can_use_multiple_story_in_attribute(): void
Expand All @@ -61,6 +64,7 @@ public function can_use_multiple_story_in_attribute(): void
/**
* @test
*/
#[Test]
#[WithStory(ServiceStory::class)]
public function can_use_service_story(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,25 @@

use PHPUnit\Framework\Attributes\RequiresPhpunit;
use PHPUnit\Framework\Attributes\RequiresPhpunitExtension;
use PHPUnit\Framework\Attributes\Test;
use Zenstruck\Foundry\Attribute\WithStory;
use Zenstruck\Foundry\PHPUnit\FoundryExtension;
use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory;
use Zenstruck\Foundry\Tests\Fixture\Stories\EntityPoolStory;

/**
* @author Nicolas PHILIPPE <[email protected]>
* @requires PHPUnit 11
* @requires PHPUnit ^11.0
*/
#[RequiresPhpunit('11')]
#[RequiresPhpunit('^11.0')]
#[RequiresPhpunitExtension(FoundryExtension::class)]
#[WithStory(EntityPoolStory::class)]
final class WithStoryOnParentClassTest extends ParentClassWithStoryAttributeTestCase
{
/**
* @test
*/
#[Test]
public function can_use_story_in_attribute_from_parent_class(): void
{
GenericEntityFactory::assert()->count(5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

/**
* @author Nicolas PHILIPPE <[email protected]>
* @requires PHPUnit 11.4
* @requires PHPUnit ^11.4
*/
#[RequiresPhpunit('11.4')]
#[RequiresPhpunit('^11.4')]
#[RequiresPhpunitExtension(FoundryExtension::class)]
final class DataProviderForServiceFactoryInKernelTestCaseTest extends KernelTestCase
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/DataProvider/DataProviderInUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

/**
* @author Nicolas PHILIPPE <[email protected]>
* @requires PHPUnit 11.4
* @requires PHPUnit ^11.4
*/
#[RequiresPhpunit('11.4')]
#[RequiresPhpunit('^11.4')]
#[RequiresPhpunitExtension(FoundryExtension::class)]
final class DataProviderInUnitTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

/**
* @author Nicolas PHILIPPE <[email protected]>
* @requires PHPUnit 11.4
* @requires PHPUnit ^11.4
*/
#[RequiresPhpunit('11.4')]
#[RequiresPhpunit('^11.4')]
#[RequiresPhpunitExtension(FoundryExtension::class)]
final class DataProviderWithNonProxyFactoryInKernelTestCaseTest extends KernelTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

/**
* @author Nicolas PHILIPPE <[email protected]>
* @requires PHPUnit 11.4
* @requires PHPUnit ^11.4
*/
#[RequiresPhpunit('11.4')]
#[RequiresPhpunit('^11.4')]
#[RequiresPhpunitExtension(FoundryExtension::class)]
abstract class DataProviderWithProxyFactoryInKernelTestCase extends KernelTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

/**
* @author Nicolas PHILIPPE <[email protected]>
* @requires PHPUnit 11.4
* @requires PHPUnit ^11.4
*/
#[RequiresPhpunit('11.4')]
#[RequiresPhpunit('^11.4')]
#[RequiresPhpunitExtension(FoundryExtension::class)]
final class GenericDocumentProxyFactoryTest extends DataProviderWithProxyFactoryInKernelTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

/**
* @author Nicolas PHILIPPE <[email protected]>
* @requires PHPUnit 11.4
* @requires PHPUnit ^11.4
*/
#[RequiresPhpunit('11.4')]
#[RequiresPhpunit('^11.4')]
#[RequiresPhpunitExtension(FoundryExtension::class)]
final class GenericEntityProxyFactoryTest extends DataProviderWithProxyFactoryInKernelTestCase
{
Expand Down
1 change: 0 additions & 1 deletion tests/Integration/Maker/MakeStoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
/**
* @author Kevin Bond <[email protected]>
* @group maker
* @requires PHP 8.1
*/
final class MakeStoryTest extends MakerTestCase
{
Expand Down
1 change: 0 additions & 1 deletion tests/Integration/Maker/MakerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
/**
* @author Kevin Bond <[email protected]>
* @group maker
* @requires PHP 8.1
*/
abstract class MakerTestCase extends KernelTestCase
{
Expand Down

0 comments on commit 628d46f

Please sign in to comment.