Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
realFlowControl committed Nov 29, 2020
1 parent d86b1ee commit 92fbf4f
Show file tree
Hide file tree
Showing 16 changed files with 7 additions and 267 deletions.
2 changes: 0 additions & 2 deletions phpunit.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,6 @@
<xs:attribute name="timeoutForSmallTests" type="xs:integer" default="1"/>
<xs:attribute name="timeoutForMediumTests" type="xs:integer" default="10"/>
<xs:attribute name="timeoutForLargeTests" type="xs:integer" default="60"/>
<xs:attribute name="testSuiteLoaderClass" type="xs:string" default="PHPUnit\Runner\StandardTestSuiteLoader"/>
<xs:attribute name="testSuiteLoaderFile" type="xs:anyURI"/>
<xs:attribute name="defaultTestSuite" type="xs:string" default=""/>
<xs:attribute name="verbose" type="xs:boolean" default="false"/>
<xs:attribute name="testdox" type="xs:boolean" default="false"/>
Expand Down
12 changes: 3 additions & 9 deletions src/Runner/BaseTestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ abstract class BaseTestRunner
*/
public const SUITE_METHODNAME = 'suite';

/**
* Returns the loader to be used.
*/
public function getLoader(): TestSuiteLoader
{
return new StandardTestSuiteLoader;
}

/**
* Returns the Test corresponding to the given suite.
* This is a template method, subclasses override
Expand Down Expand Up @@ -140,10 +132,12 @@ public function getTest(string $suiteClassFile, $suffixes = ''): ?TestSuite

/**
* Returns the loaded ReflectionClass for a suite name.
*
* @throws \PHPUnit\Runner\Exception
*/
protected function loadSuiteClass(string $suiteClassFile): ReflectionClass
{
return $this->getLoader()->load($suiteClassFile);
return (new StandardTestSuiteLoader)->load($suiteClassFile);
}

/**
Expand Down
8 changes: 0 additions & 8 deletions src/TextUI/CliArguments/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ final class Builder
'list-suites',
'list-tests',
'list-tests-xml=',
'loader=',
'log-junit=',
'log-teamcity=',
'migrate-configuration',
Expand Down Expand Up @@ -196,7 +195,6 @@ public function fromParameters(array $parameters, array $additionalLongOptions):
$listSuites = null;
$listTests = null;
$listTestsXml = null;
$loader = null;
$noCoverage = null;
$noExtensions = null;
$noInteraction = null;
Expand Down Expand Up @@ -433,11 +431,6 @@ public function fromParameters(array $parameters, array $additionalLongOptions):

break;

case '--loader':
$loader = $option[1];

break;

case '--log-junit':
$junitLogfile = $option[1];

Expand Down Expand Up @@ -846,7 +839,6 @@ public function fromParameters(array $parameters, array $additionalLongOptions):
$listSuites,
$listTests,
$listTestsXml,
$loader,
$noCoverage,
$noExtensions,
$noInteraction,
Expand Down
25 changes: 1 addition & 24 deletions src/TextUI/CliArguments/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,6 @@ final class Configuration
*/
private $listTestsXml;

/**
* @var ?string
*/
private $loader;

/**
* @var ?bool
*/
Expand Down Expand Up @@ -475,7 +470,7 @@ final class Configuration
/**
* @param null|int|string $columns
*/
public function __construct(?string $argument, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticAttributes, ?bool $beStrictAboutChangesToGlobalState, ?bool $beStrictAboutResourceUsageDuringSmallTests, ?string $bootstrap, ?bool $cacheResult, ?string $cacheResultFile, ?bool $checkVersion, ?string $colors, $columns, ?string $configuration, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4J, ?string $coverageHtml, ?string $coveragePhp, ?string $coverageText, ?bool $coverageTextShowUncoveredFiles, ?bool $coverageTextShowOnlySummary, ?string $coverageXml, ?bool $pathCoverage, ?string $coverageCacheDirectory, ?bool $warmCoverageCache, ?bool $debug, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $disallowTodoAnnotatedTests, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?array $extensions, ?array $unavailableExtensions, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?string $filter, ?bool $generateConfiguration, ?bool $migrateConfiguration, ?array $groups, ?array $testsCovering, ?array $testsUsing, ?bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, ?bool $listGroups, ?bool $listSuites, ?bool $listTests, ?string $listTestsXml, ?string $loader, ?bool $noCoverage, ?bool $noExtensions, ?bool $noInteraction, ?bool $noLogging, ?string $printer, ?bool $processIsolation, ?int $randomOrderSeed, ?int $repeat, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?bool $stopOnDefect, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $teamcityLogfile, ?array $testdoxExcludeGroups, ?array $testdoxGroups, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?string $testdoxXmlFile, ?array $testSuffixes, ?string $testSuite, array $unrecognizedOptions, ?string $unrecognizedOrderBy, ?bool $useDefaultConfiguration, ?bool $verbose, ?bool $version, ?array $coverageFilter, ?string $xdebugFilterFile)
public function __construct(?string $argument, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticAttributes, ?bool $beStrictAboutChangesToGlobalState, ?bool $beStrictAboutResourceUsageDuringSmallTests, ?string $bootstrap, ?bool $cacheResult, ?string $cacheResultFile, ?bool $checkVersion, ?string $colors, $columns, ?string $configuration, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4J, ?string $coverageHtml, ?string $coveragePhp, ?string $coverageText, ?bool $coverageTextShowUncoveredFiles, ?bool $coverageTextShowOnlySummary, ?string $coverageXml, ?bool $pathCoverage, ?string $coverageCacheDirectory, ?bool $warmCoverageCache, ?bool $debug, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $disallowTodoAnnotatedTests, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?array $extensions, ?array $unavailableExtensions, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?string $filter, ?bool $generateConfiguration, ?bool $migrateConfiguration, ?array $groups, ?array $testsCovering, ?array $testsUsing, ?bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, ?bool $listGroups, ?bool $listSuites, ?bool $listTests, ?string $listTestsXml, ?bool $noCoverage, ?bool $noExtensions, ?bool $noInteraction, ?bool $noLogging, ?string $printer, ?bool $processIsolation, ?int $randomOrderSeed, ?int $repeat, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?bool $stopOnDefect, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $teamcityLogfile, ?array $testdoxExcludeGroups, ?array $testdoxGroups, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?string $testdoxXmlFile, ?array $testSuffixes, ?string $testSuite, array $unrecognizedOptions, ?string $unrecognizedOrderBy, ?bool $useDefaultConfiguration, ?bool $verbose, ?bool $version, ?array $coverageFilter, ?string $xdebugFilterFile)
{
$this->argument = $argument;
$this->atLeastVersion = $atLeastVersion;
Expand Down Expand Up @@ -533,7 +528,6 @@ public function __construct(?string $argument, ?string $atLeastVersion, ?bool $b
$this->listSuites = $listSuites;
$this->listTests = $listTests;
$this->listTestsXml = $listTestsXml;
$this->loader = $loader;
$this->noCoverage = $noCoverage;
$this->noExtensions = $noExtensions;
$this->noInteraction = $noInteraction;
Expand Down Expand Up @@ -1488,23 +1482,6 @@ public function listTestsXml(): string
return $this->listTestsXml;
}

public function hasLoader(): bool
{
return $this->loader !== null;
}

/**
* @throws Exception
*/
public function loader(): string
{
if ($this->loader === null) {
throw new Exception;
}

return $this->loader;
}

public function hasNoCoverage(): bool
{
return $this->noCoverage !== null;
Expand Down
5 changes: 0 additions & 5 deletions src/TextUI/CliArguments/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public function mapToLegacyArray(Configuration $arguments): array
'listSuites' => false,
'listTests' => false,
'listTestsXml' => false,
'loader' => null,
'useDefaultConfiguration' => true,
'loadedExtensions' => [],
'unavailableExtensions' => [],
Expand Down Expand Up @@ -164,10 +163,6 @@ public function mapToLegacyArray(Configuration $arguments): array
$result['printer'] = $arguments->printer();
}

if ($arguments->hasLoader()) {
$result['loader'] = $arguments->loader();
}

if ($arguments->hasJunitLogfile()) {
$result['junitLogfile'] = $arguments->junitLogfile();
}
Expand Down
80 changes: 1 addition & 79 deletions src/TextUI/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
use function version_compare;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Runner\Extension\PharLoader;
use PHPUnit\Runner\StandardTestSuiteLoader;
use PHPUnit\Runner\TestSuiteLoader;
use PHPUnit\Runner\Version;
use PHPUnit\TextUI\CliArguments\Builder;
use PHPUnit\TextUI\CliArguments\Configuration;
Expand Down Expand Up @@ -164,7 +162,7 @@ public function run(array $argv, bool $exit = true): int
*/
protected function createRunner(): TestRunner
{
return new TestRunner($this->arguments['loader']);
return new TestRunner();
}

/**
Expand Down Expand Up @@ -294,10 +292,6 @@ protected function handleArguments(array $argv): void
}
}

if ($this->arguments['loader'] !== null) {
$this->arguments['loader'] = $this->handleLoader($this->arguments['loader']);
}

if (isset($this->arguments['configuration'])) {
if (is_dir($this->arguments['configuration'])) {
$candidate = $this->configurationFileInDirectory($this->arguments['configuration']);
Expand Down Expand Up @@ -369,15 +363,6 @@ protected function handleArguments(array $argv): void
);
}

if ($phpunitConfiguration->hasTestSuiteLoaderClass()) {
$file = $phpunitConfiguration->hasTestSuiteLoaderFile() ? $phpunitConfiguration->testSuiteLoaderFile() : '';

$this->arguments['loader'] = $this->handleLoader(
$phpunitConfiguration->testSuiteLoaderClass(),
$file
);
}

if (!isset($this->arguments['testsuite']) && $phpunitConfiguration->hasDefaultTestSuite()) {
$this->arguments['testsuite'] = $phpunitConfiguration->defaultTestSuite();
}
Expand Down Expand Up @@ -415,69 +400,6 @@ protected function handleArguments(array $argv): void
}
}

/**
* Handles the loading of the PHPUnit\Runner\TestSuiteLoader implementation.
*
* @deprecated see https://github.com/sebastianbergmann/phpunit/issues/4039
*/
protected function handleLoader(string $loaderClass, string $loaderFile = ''): ?TestSuiteLoader
{
$this->warnings[] = 'Using a custom test suite loader is deprecated';

if (!class_exists($loaderClass, false)) {
if ($loaderFile == '') {
$loaderFile = Filesystem::classNameToFilename(
$loaderClass
);
}

$loaderFile = stream_resolve_include_path($loaderFile);

if ($loaderFile) {
/**
* @noinspection PhpIncludeInspection
* @psalm-suppress UnresolvableInclude
*/
require $loaderFile;
}
}

if (class_exists($loaderClass, false)) {
try {
$class = new ReflectionClass($loaderClass);
// @codeCoverageIgnoreStart
} catch (\ReflectionException $e) {
throw new ReflectionException(
$e->getMessage(),
(int) $e->getCode(),
$e
);
}
// @codeCoverageIgnoreEnd

if ($class->implementsInterface(TestSuiteLoader::class) && $class->isInstantiable()) {
$object = $class->newInstance();

assert($object instanceof TestSuiteLoader);

return $object;
}
}

if ($loaderClass == StandardTestSuiteLoader::class) {
return null;
}

$this->exitWithErrorMessage(
sprintf(
'Could not use "%s" as loader.',
$loaderClass
)
);

return null;
}

/**
* Handles the loading of the PHPUnit\Util\Printer implementation.
*
Expand Down
22 changes: 1 addition & 21 deletions src/TextUI/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@
use PHPUnit\Runner\Hook;
use PHPUnit\Runner\NullTestResultCache;
use PHPUnit\Runner\ResultCacheExtension;
use PHPUnit\Runner\StandardTestSuiteLoader;
use PHPUnit\Runner\TestHook;
use PHPUnit\Runner\TestListenerAdapter;
use PHPUnit\Runner\TestSuiteLoader;
use PHPUnit\Runner\TestSuiteSorter;
use PHPUnit\Runner\Version;
use PHPUnit\TextUI\XmlConfiguration\CodeCoverage\FilterMapper;
Expand Down Expand Up @@ -102,11 +100,6 @@ final class TestRunner extends BaseTestRunner
*/
private $codeCoverageFilter;

/**
* @var TestSuiteLoader
*/
private $loader;

/**
* @var ResultPrinter
*/
Expand All @@ -127,14 +120,13 @@ final class TestRunner extends BaseTestRunner
*/
private $timer;

public function __construct(TestSuiteLoader $loader = null, CodeCoverageFilter $filter = null)
public function __construct(CodeCoverageFilter $filter = null)
{
if ($filter === null) {
$filter = new CodeCoverageFilter;
}

$this->codeCoverageFilter = $filter;
$this->loader = $loader;
$this->timer = new Timer;
}

Expand Down Expand Up @@ -833,18 +825,6 @@ public function run(TestSuite $suite, array $arguments = [], array $warnings = [
return $result;
}

/**
* Returns the loader to be used.
*/
public function getLoader(): TestSuiteLoader
{
if ($this->loader === null) {
$this->loader = new StandardTestSuiteLoader;
}

return $this->loader;
}

public function addExtension(Hook $extension): void
{
$this->extensions[] = $extension;
Expand Down
8 changes: 0 additions & 8 deletions src/TextUI/XmlConfiguration/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -1014,12 +1014,6 @@ private function phpunit(string $filename, DOMDocument $document): PHPUnit
$extensionsDirectory = $this->toAbsolutePath($filename, $extensionsDirectory);
}

$testSuiteLoaderFile = $this->getStringAttribute($document->documentElement, 'testSuiteLoaderFile');

if ($testSuiteLoaderFile !== null) {
$testSuiteLoaderFile = $this->toAbsolutePath($filename, $testSuiteLoaderFile);
}

$printerFile = $this->getStringAttribute($document->documentElement, 'printerFile');

if ($printerFile !== null) {
Expand Down Expand Up @@ -1055,8 +1049,6 @@ private function phpunit(string $filename, DOMDocument $document): PHPUnit
$this->getBooleanAttribute($document->documentElement, 'stopOnRisky', false),
$this->getBooleanAttribute($document->documentElement, 'stopOnSkipped', false),
$extensionsDirectory,
$this->getStringAttribute($document->documentElement, 'testSuiteLoaderClass'),
$testSuiteLoaderFile,
$printerClass,
$printerFile,
$this->getBooleanAttribute($document->documentElement, 'beStrictAboutChangesToGlobalState', false),
Expand Down
Loading

0 comments on commit 92fbf4f

Please sign in to comment.