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 13, 2024
1 parent dc13324 commit 8bdeb50
Show file tree
Hide file tree
Showing 133 changed files with 1,316 additions and 1,626 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
2 changes: 0 additions & 2 deletions src/Dev/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ protected function withBaseFolder($folder, $callback)

/**
* Submit a get request
* @uses Director::test()
*
* @param string $url
* @param Session $session
Expand All @@ -155,7 +154,6 @@ public function get($url, $session = null, $headers = null, $cookies = null)
/**
* Submit a post request
*
* @uses Director::test()
* @param string $url
* @param array $data
* @param array $headers
Expand Down
99 changes: 0 additions & 99 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 src/ORM/FieldType/DBClassNameTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace SilverStripe\ORM\FieldType;

use RuntimeException;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Config\Config;
use SilverStripe\ORM\DataObject;
use RuntimeException;
use SilverStripe\View\ViewableData;

trait DBClassNameTrait
Expand Down
3 changes: 2 additions & 1 deletion src/View/Parsers/HtmlDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SebastianBergmann\Diff\Differ;
use SilverStripe\Core\Convert;
use SilverStripe\Core\Injector\Injector;
use SebastianBergmann\Diff\Output\DiffOnlyOutputBuilder;

/**
* Class representing a 'diff' between two sequences of HTML strings.
Expand Down Expand Up @@ -285,7 +286,7 @@ private static function cleanHTML(string $content, ?HTMLCleaner $cleaner = null)
private static function getDiffer(): Differ
{
if (!HtmlDiff::$differ) {
HtmlDiff::$differ = new Differ();
HtmlDiff::$differ = new Differ(new DiffOnlyOutputBuilder());
}
return HtmlDiff::$differ;
}
Expand Down
10 changes: 3 additions & 7 deletions tests/php/Control/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use SilverStripe\Dev\FunctionalTest;
use SilverStripe\Security\Member;
use SilverStripe\View\SSViewer;
use PHPUnit\Framework\Attributes\DataProvider;

class ControllerTest extends FunctionalTest
{
Expand Down Expand Up @@ -462,7 +463,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 Expand Up @@ -670,9 +671,7 @@ public function provideNormaliseTrailingSlash(): array
];
}

/**
* @dataProvider provideNormaliseTrailingSlash
*/
#[DataProvider('provideNormaliseTrailingSlash')]
public function testNormaliseTrailingSlash(string $path, string $withSlash, string $withoutSlash): void
{
$absBaseUrlNoSlash = rtrim(Director::absoluteBaseURL(), '/');
Expand Down Expand Up @@ -704,9 +703,6 @@ public function testLink()
$this->assertEquals('HasAction/allowed-action/', $controller->Link('allowed-action'));
}

/**
* @covers \SilverStripe\Control\Controller::hasAction
*/
public function testHasAction()
{
$controller = new HasAction();
Expand Down
Loading

0 comments on commit 8bdeb50

Please sign in to comment.