Skip to content

Commit

Permalink
DEP Use PHPUnit 11
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Sep 9, 2024
1 parent 1a53bc1 commit 1835859
Show file tree
Hide file tree
Showing 102 changed files with 447 additions and 485 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"m1/env": "^2.2.0",
"masterminds/html5": "^2.7.6",
"monolog/monolog": "^3.2.0",
"nikic/php-parser": "^4.15.0",
"nikic/php-parser": "^5.1.0",
"psr/container": "^1.1 || ^2.0",
"psr/http-message": "^1",
"sebastian/diff": "^4.0",
"sebastian/diff": "^6.0",
"silverstripe/config": "^3",
"silverstripe/assets": "^3",
"silverstripe/vendor-plugin": "^2",
Expand Down Expand Up @@ -63,7 +63,7 @@
},
"require-dev": {
"composer/semver": "^3.4",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^11.3",
"silverstripe/versioned": "^3",
"squizlabs/php_codesniffer": "^3.7",
"silverstripe/standards": "^1",
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Manifest/ClassManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public function init($includeTests = false, $forceRegen = false)
public function getParser()
{
if (!$this->parser) {
$this->parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
$this->parser = (new ParserFactory)->createForHostVersion();
}

return $this->parser;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Manifest/ClassManifestErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct($pathname)
$this->pathname = $pathname;
}

public function handleError(Error $error)
public function handleError(Error $error): void
{
$newMessage = sprintf('%s in %s', $error->getRawMessage(), $this->pathname);
$error->setRawMessage($newMessage);
Expand Down
5 changes: 0 additions & 5 deletions src/Dev/Constraint/SSListContains.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\ExpectationFailedException;
use SilverStripe\Dev\SSListExporter;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\SS_List;
use SilverStripe\View\ViewableData;
Expand All @@ -20,8 +19,6 @@ class SSListContains extends Constraint implements TestOnly
*/
protected $matches = [];

protected SSListExporter $exporter;

/**
* Check if the list has left over items that don't match
*
Expand All @@ -31,8 +28,6 @@ class SSListContains extends Constraint implements TestOnly

public function __construct(array $matches)
{
$this->exporter = new SSListExporter();

$this->matches = $matches;
}

Expand Down
5 changes: 0 additions & 5 deletions src/Dev/Constraint/SSListContainsOnlyMatchingItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\ExpectationFailedException;
use SilverStripe\Dev\SSListExporter;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\SS_List;

Expand All @@ -19,17 +18,13 @@ class SSListContainsOnlyMatchingItems extends Constraint implements TestOnly
*/
private $match;

protected SSListExporter $exporter;

/**
* @var ViewableDataContains
*/
private $constraint;

public function __construct($match)
{
$this->exporter = new SSListExporter();

$this->constraint = new ViewableDataContains($match);
$this->match = $match;
}
Expand Down
85 changes: 0 additions & 85 deletions src/Dev/SSListExporter.php

This file was deleted.

30 changes: 23 additions & 7 deletions src/Dev/SapphireTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mailer\Transport\NullTransport;
use ReflectionMethod;
use ReflectionClass;

/**
* Test case class for the Silverstripe framework.
Expand Down Expand Up @@ -1212,16 +1214,30 @@ public static function createInvalidArgumentException($argument, $type, $value =
}

/**
* Returns the annotations for this test.
*
* @return array
* Returns the annotations for this test
*/
public function getAnnotations(): array
{
return TestUtil::parseTestMethodAnnotations(
get_class($this),
$this->getName(false)
);
$class = get_class($this);
$method = $this->name();
$ret = [];
foreach (['method', 'class'] as $what) {
if ($what === 'method') {
$reflection = new ReflectionMethod($class, $method);
} else {
$reflection = new ReflectionClass($class);
}
preg_match_all('#@(.*?)\n#s', $reflection->getDocComment(), $annotations);
$ret[$what] = [];
foreach ($annotations[1] as $annotation) {
$parts = explode(' ', $annotation);
$key = array_shift($parts);
$value = implode(' ', $parts);
$ret[$what][$key] ??= [];
$ret[$what][$key][] = $value;
}
}
return $ret;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Control/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public function testJoinLinks()
);
}

public function provideNormaliseTrailingSlash(): array
public static function provideNormaliseTrailingSlash(): array
{
// note 93.184.215.14 is the IP address for example.com
return [
Expand Down
Loading

0 comments on commit 1835859

Please sign in to comment.