Skip to content

Commit

Permalink
Prepare tests for PHPUnit 10 (#778)
Browse files Browse the repository at this point in the history
* Migrate phpunit XML configuration

* Use TestCase suffix for abstract test classes

* Make data providers static

* Mark risky test as it does not perform assertions

* Rename Test.php classes
  • Loading branch information
franmomu authored Jul 31, 2023
1 parent 294b0fb commit 8134a6e
Show file tree
Hide file tree
Showing 18 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Tests/CacheWarmer/HydratorCacheWarmerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function testWarmerNotExecuted(int $autoGenerate): void
}

/** @return array<array{int}> */
public function provideWarmerNotExecuted(): array
public static function provideWarmerNotExecuted(): array
{
return [
[ Configuration::AUTOGENERATE_ALWAYS ],
Expand Down
2 changes: 1 addition & 1 deletion Tests/CacheWarmer/PersistentCollectionCacheWarmerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testWarmerNotExecuted(int $autoGenerate): void
$this->warmer->warmUp('meh');
}

public function provideWarmerNotExecuted(): array
public static function provideWarmerNotExecuted(): array
{
return [
[ Configuration::AUTOGENERATE_ALWAYS ],
Expand Down
4 changes: 2 additions & 2 deletions Tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testLoggerConfig(bool $expected, array $config, bool $debug): vo
}

/** @return array<string, array{expected: bool, config: array, debug: bool}> */
public function provideLoggerConfigs(): array
public static function provideLoggerConfigs(): array
{
$config = ['connections' => ['default' => []]];

Expand Down Expand Up @@ -109,7 +109,7 @@ public function testDataCollectorConfig(bool $expected, array $config, bool $deb
}

/** @return array<string, array{expected: bool, config: array, debug: bool}> */
public function provideDataCollectorConfigs(): array
public static function provideDataCollectorConfigs(): array
{
$config = ['connections' => ['default' => []]];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use function is_dir;
use function reset;

abstract class AbstractMongoDBExtensionTest extends TestCase
abstract class AbstractMongoDBExtensionTestCase extends TestCase
{
abstract protected function loadFromFile(ContainerBuilder $container, string $file): void;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
self::assertTrue($kernel->isBooted());
}

/** @group legacy */
/**
* @group legacy
* @doesNotPerformAssertions
*/
public function testMetadataCacheConfigUsingNonPsr6ServiceDefinedByApplication(): void
{
$this->expectDeprecation('Since doctrine/mongodb-odm-bundle 4.4: Configuring doctrine/cache is deprecated. Please update the cache service "custom_cache_service" to use a PSR-6 cache.');
Expand Down
8 changes: 4 additions & 4 deletions Tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function testFullConfiguration(array $config): void
}

/** @return array<mixed[]> */
public function provideFullConfiguration(): array
public static function provideFullConfiguration(): array
{
$yaml = Yaml::parse(file_get_contents(__DIR__ . '/Fixtures/config/yml/full.yml'));
$yaml = $yaml['doctrine_mongodb'];
Expand Down Expand Up @@ -249,7 +249,7 @@ public function testMergeOptions(array $configs, array $expected): void
}

/** @return array<mixed[]> */
public function provideMergeOptions(): array
public static function provideMergeOptions(): array
{
$cases = [];

Expand Down Expand Up @@ -371,7 +371,7 @@ public function testNormalizeOptions(array $config, array $expected): void
}

/** @return array<mixed[]> */
public function provideNormalizeOptions(): array
public static function provideNormalizeOptions(): array
{
$cases = [];

Expand Down Expand Up @@ -527,7 +527,7 @@ public function testFixtureLoaderValidation(array $config): void
}

/** @return array<mixed[]> */
public function provideExceptionConfiguration(): array
public static function provideExceptionConfiguration(): array
{
$yaml = Yaml::parse(file_get_contents(__DIR__ . '/Fixtures/config/yml/exception.yml'));
$yaml = $yaml['doctrine_mongodb'];
Expand Down
4 changes: 2 additions & 2 deletions Tests/DependencyInjection/DoctrineMongoDBExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ private function getContainer($bundles = 'OtherXmlBundle'): ContainerBuilder
]));
}

public function parameterProvider(): array
public static function parameterProvider(): array
{
return [
['proxy_namespace', 'proxy_namespace', 'foo'],
['proxy-namespace', 'proxy_namespace', 'bar'],
];
}

public function getAutomappingConfigurations(): array
public static function getAutomappingConfigurations(): array
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

/** @MongoDB\Document */
class Test
class TestDocument
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

#[MongoDB\Document]
class Test
class TestDocument
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

#[MongoDB\Document]
class Test
class TestDocument
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

namespace Doctrine\Bundle\MongoDBBundle\Tests\DependencyInjection\Fixtures\Bundles\NewXmlBundle\Document;

class Test
class TestDocument
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

namespace Doctrine\Bundle\MongoDBBundle\Tests\DependencyInjection\Fixtures\Bundles\OtherXmlBundle\Document;

class Test
class TestDocument
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

namespace Doctrine\Bundle\MongoDBBundle\Tests\DependencyInjection\Fixtures\Bundles\XmlBundle\Document;

class Test
class TestDocument
{
}
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/XmlMongoDBExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

class XmlMongoDBExtensionTest extends AbstractMongoDBExtensionTest
class XmlMongoDBExtensionTest extends AbstractMongoDBExtensionTestCase
{
protected function loadFromFile(ContainerBuilder $container, string $file): void
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/YamlMongoDBExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

class YamlMongoDBExtensionTest extends AbstractMongoDBExtensionTest
class YamlMongoDBExtensionTest extends AbstractMongoDBExtensionTestCase
{
protected function loadFromFile(ContainerBuilder $container, string $file): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use PHPUnit\Framework\TestCase;
use ReflectionProperty;

abstract class AbstractDriverTest extends TestCase
abstract class AbstractDriverTestCase extends TestCase
{
public function testFindMappingFile(): void
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Mapping/Driver/XmlDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Doctrine\Bundle\MongoDBBundle\Mapping\Driver\XmlDriver;

class XmlDriverTest extends AbstractDriverTest
class XmlDriverTest extends AbstractDriverTestCase
{
protected function getFileExtension(): string
{
Expand Down
18 changes: 9 additions & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=1"/>
</php>

<filter>
<whitelist>
<coverage>
<include>
<directory>./</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</include>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
Expand Down

0 comments on commit 8134a6e

Please sign in to comment.