Skip to content

Commit

Permalink
Merge pull request #187 from martin-helmich/chore/bump-phpunit
Browse files Browse the repository at this point in the history
Bump PHPUnit to v10
  • Loading branch information
martin-helmich authored Mar 3, 2024
2 parents e7effe9 + 18e6648 commit de3260a
Show file tree
Hide file tree
Showing 64 changed files with 60 additions and 125 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"ext-dom": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.6.8",
"phpunit/phpunit": "^10.5.11",
"mikey179/vfsstream": "^1.6.11",
"vimeo/psalm": "^5.22.2",
"phpspec/prophecy-phpunit": "^2.0.2"
Expand Down
15 changes: 5 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
backupGlobals="true"
bootstrap="vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true">

xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="true"
bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Unit tests">
<directory>tests/unit</directory>
Expand All @@ -15,10 +11,9 @@
<directory>tests/functional</directory>
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</source>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Helmich\TypoScriptLint\Logging\NullLogger;
use Helmich\TypoScriptParser\Parser\Parser;
use Helmich\TypoScriptParser\Tokenizer\Tokenizer;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Yaml\Yaml;
Expand All @@ -32,12 +33,7 @@ public function setUp(): void
);
}

/**
* @dataProvider getFunctionalTestFixtures
*
* @param string $typoscriptFile
* @param array $expectedWarnings
*/
#[DataProvider('getFunctionalTestFixtures')]
public function testLinterCreatesExpectedOutput(string $typoscriptFile, array $expectedWarnings): void
{
$localConfigFilename = dirname($typoscriptFile) . '/tslint.yml';
Expand Down Expand Up @@ -95,7 +91,7 @@ public function testLinterCreatesExpectedOutput(string $typoscriptFile, array $e
/**
* @return array<string, mixed[]>
*/
public function getFunctionalTestFixtures(): array
public static function getFunctionalTestFixtures(): array
{
$files = glob(__DIR__ . '/Fixtures/*/*.typoscript');
$testCases = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,32 @@
use Helmich\TypoScriptLint\Logging\LinterLoggerBuilder;
use Helmich\TypoScriptLint\Logging\NullLogger;
use Helmich\TypoScriptLint\Util\Finder;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;

use function PHPUnit\Framework\any;
use function PHPUnit\Framework\once;

/**
* Class LintCommandTest
*
* @package Helmich\TypoScriptLint\Command
* @covers \Helmich\TypoScriptLint\Command\LintCommand
*/
#[CoversClass(LintCommand::class)]
class LintCommandTest extends TestCase
{
use ProphecyTrait;

private LintCommand $command;

/** @var MockObject */
private
private MockObject
$linter,
$linterConfigurationLocator,
$finder;

/** @var ObjectProphecy */
private $loggerBuilder, $eventDispatcher;
private ObjectProphecy $loggerBuilder, $eventDispatcher;

public function setUp(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,19 @@

use Helmich\TypoScriptLint\Linter\Configuration\ConfigurationLocator;
use Helmich\TypoScriptLint\Linter\LinterConfiguration;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\Loader\LoaderInterface;

use function PHPUnit\Framework\any;

/**
* Class ConfigurationLocatorTest
*
* @package \Helmich\TypoScriptLint\Linter\Configuration
* @covers \Helmich\TypoScriptLint\Linter\Configuration\ConfigurationLocator
*/
#[CoversClass(ConfigurationLocator::class)]
class ConfigurationLocatorTest extends TestCase
{

/** @var MockObject */
private $loader, $processor;
private MockObject $loader, $processor;

private ConfigurationLocator $locator;

Expand All @@ -30,7 +25,6 @@ public function setUp(): void
$this->loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
$this->processor = $this->getMockBuilder(Processor::class)->getMock();

/** @noinspection PhpParamsInspection */
$this->locator = new ConfigurationLocator(
$this->loader,
$this->processor
Expand All @@ -57,7 +51,6 @@ public function testConfigurationIsLoadedAndProcessed(): void
->with($this->isInstanceOf(LinterConfiguration::class), [$distConfig, $localConfig])
->willReturn($mergedConfig);

/** @noinspection PhpParamsInspection */
$loadedConfiguration = $this->locator->loadConfiguration(['test.yml'], $configuration);
$this->assertSame($loadedConfiguration, $configuration);
}
Expand All @@ -81,7 +74,6 @@ public function testConfigurationIsLoadedAndProcessedWithDefaultConfigFile(): vo
->with($this->isInstanceOf(LinterConfiguration::class), [$distConfig])
->willReturn($mergedConfig);

/** @noinspection PhpParamsInspection */
$loadedConfiguration = $this->locator->loadConfiguration([], $configuration);
$this->assertSame($loadedConfiguration, $configuration);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@

use Helmich\TypoScriptLint\Linter\Configuration\YamlConfigurationLoader;
use Helmich\TypoScriptLint\Util\Filesystem;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException;
use Symfony\Component\Config\FileLocatorInterface;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\Yaml\Parser;

/**
* @covers \Helmich\TypoScriptLint\Linter\Configuration\YamlConfigurationLoader
*/
#[CoversClass(YamlConfigurationLoader::class)]
class YamlConfigurationLoaderTest extends TestCase
{

/** @var MockObject */
private
private MockObject
$fileLocator,
$yamlParser,
$filesystem;
Expand All @@ -31,7 +29,6 @@ public function setUp(): void
$this->yamlParser = $this->getMockBuilder(Parser::class)->disableOriginalConstructor()->getMock();
$this->filesystem = $this->getMockBuilder(Filesystem::class)->getMock();

/** @noinspection PhpParamsInspection */
$this->loader = new YamlConfigurationLoader($this->fileLocator, $this->yamlParser, $this->filesystem);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

use Helmich\TypoScriptLint\Linter\LinterConfiguration;
use Helmich\TypoScriptLint\Linter\Sniff\DeadCodeSniff;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Processor;

use function PHPUnit\Framework\assertThat;
use function PHPUnit\Framework\equalTo;

/**
* @package Helmich\TypoScriptLint\Linter
* @covers \Helmich\TypoScriptLint\Linter\LinterConfiguration
*/
#[CoversClass(LinterConfiguration::class)]
class LinterConfigurationTest extends TestCase
{
public function testPathsAreCorrectlyMapped(): void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<?php declare(strict_types=1);

namespace Helmich\TypoScriptLint\Tests\Unit\Logging;
namespace Helmich\TypoScriptLint\Tests\Unit\Linter\Logging;

use Helmich\TypoScriptLint\Logging\CompactConsoleLogger;
use Helmich\TypoScriptLint\Logging\LinterLoggerBuilder;
use Helmich\TypoScriptLint\Logging\MinimalConsoleLogger;
use Helmich\TypoScriptLint\Logging\VerboseConsoleLogger;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\BufferedOutput;

use function PHPUnit\Framework\assertThat;
use function PHPUnit\Framework\isInstanceOf;

/**
* @covers \Helmich\TypoScriptLint\Logging\LinterLoggerBuilder
*/
#[CoversClass(LinterLoggerBuilder::class)]
class LinterLoggerBuilderTest extends TestCase
{
private LinterLoggerBuilder $builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Helmich\TypoScriptLint\Linter\Report\File;
use Helmich\TypoScriptLint\Linter\Report\Issue;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

use function PHPUnit\Framework\assertThat;
Expand All @@ -13,12 +14,7 @@
use function PHPUnit\Framework\identicalTo;
use function PHPUnit\Framework\any;

/**
* Class FileTest
*
* @package Helmich\TypoScriptLint\Linter\Report
* @covers \Helmich\TypoScriptLint\Linter\Report\File
*/
#[CoversClass(File::class)]
class FileTest extends TestCase
{

Expand All @@ -36,7 +32,7 @@ public function testConstructorSetsFilename(): void

public function testWarningsCanBeAdded(): void
{
$warning = $this->getMockBuilder(Issue::class)->disableOriginalConstructor()->getMock();
$warning = new Issue(1, 1, "some warning", Issue::SEVERITY_WARNING, self::class);
$this->file->addIssue($warning);

assertCount(1, $this->file->getIssues());
Expand All @@ -48,12 +44,8 @@ public function testWarningsCanBeAdded(): void
*/
public function testWarningsAreSortedByLineNumber(): void
{
$warningBuilder = $this->getMockBuilder(Issue::class)->disableOriginalConstructor();

$warning1 = $warningBuilder->getMock();
$warning1->expects(any())->method('getLine')->willReturn(10);
$warning2 = $warningBuilder->getMock();
$warning2->expects(any())->method('getLine')->willReturn(1);
$warning1 = new Issue(10, 1, "some warning", Issue::SEVERITY_WARNING, self::class);
$warning2 = new Issue(1, 1, "some warning", Issue::SEVERITY_WARNING, self::class);

$this->file->addIssue($warning1);
$this->file->addIssue($warning2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
use Helmich\TypoScriptLint\Linter\Report\Issue;
use Helmich\TypoScriptParser\Parser\ParseError;
use Helmich\TypoScriptParser\Tokenizer\TokenizerException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

use function PHPUnit\Framework\assertEquals;

/**
* @covers \Helmich\TypoScriptLint\Linter\Report\Issue
* @uses \Helmich\TypoScriptParser\Parser\ParseError
*/
#[CoversClass(Issue::class)]
class IssueTest extends TestCase
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
use Helmich\TypoScriptLint\Linter\Report\File;
use Helmich\TypoScriptLint\Linter\Report\Issue;
use Helmich\TypoScriptLint\Linter\Report\Report;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

use function PHPUnit\Framework\assertThat;
use function PHPUnit\Framework\assertCount;
use function PHPUnit\Framework\assertSame;
use function PHPUnit\Framework\equalTo;

/**
* @covers \Helmich\TypoScriptLint\Linter\Report\Report
*/
#[CoversClass(Report::class)]
class ReportTest extends TestCase
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@
use Helmich\TypoScriptLint\Linter\Report\Issue;
use Helmich\TypoScriptLint\Linter\Report\Report;
use Helmich\TypoScriptLint\Linter\ReportPrinter\CheckstyleReportPrinter;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\OutputInterface;

use function PHPUnit\Framework\once;

/**
* @covers \Helmich\TypoScriptLint\Linter\ReportPrinter\CheckstyleReportPrinter
* @uses \Helmich\TypoScriptLint\Linter\Report\File
* @uses \Helmich\TypoScriptLint\Linter\Report\Report
* @uses \Helmich\TypoScriptLint\Linter\Report\Issue
*/
#[CoversClass(CheckstyleReportPrinter::class)]
class CheckstyleReportPrinterTest extends TestCase
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
use Helmich\TypoScriptLint\Linter\Report\Report;
use Helmich\TypoScriptLint\Linter\Report\Issue;
use Helmich\TypoScriptLint\Linter\ReportPrinter\ConsoleReportPrinter;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\BufferedOutput;

use function PHPUnit\Framework\assertEquals;

/**
* @covers \Helmich\TypoScriptLint\Linter\ReportPrinter\ConsoleReportPrinter
* @uses \Helmich\TypoScriptLint\Linter\Report\File
* @uses \Helmich\TypoScriptLint\Linter\Report\Report
* @uses \Helmich\TypoScriptLint\Linter\Report\Issue
*/
#[CoversClass(ConsoleReportPrinter::class)]
class ConsoleReportPrinterTest extends TestCase
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
use Helmich\TypoScriptLint\Linter\Report\Report;
use Helmich\TypoScriptLint\Linter\Report\Issue;
use Helmich\TypoScriptLint\Linter\ReportPrinter\GccReportPrinter;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\BufferedOutput;

use function PHPUnit\Framework\assertEquals;

/**
* @covers \Helmich\TypoScriptLint\Linter\ReportPrinter\GccReportPrinter
* @uses \Helmich\TypoScriptLint\Linter\Report\File
* @uses \Helmich\TypoScriptLint\Linter\Report\Report
* @uses \Helmich\TypoScriptLint\Linter\Report\Issue
*/
#[CoversClass(GccReportPrinter::class)]
class GccReportPrinterTest extends TestCase
{

Expand Down
Loading

0 comments on commit de3260a

Please sign in to comment.