Skip to content

Commit

Permalink
Merge branch '6.0' into 6
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Feb 24, 2025
2 parents 90d280e + e9d95b9 commit c502abe
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
11 changes: 11 additions & 0 deletions src/Dev/SapphireTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ abstract class SapphireTest extends TestCase implements TestOnly

protected FixtureFactory|bool $fixtureFactory;

/**
* The original value of ini 'max_execution_time' before any code or tests change it
*/
private int $origMaxExecutionTime;

/**
* @return TempDatabase
*/
Expand Down Expand Up @@ -341,6 +346,8 @@ protected function setUp(): void
Email::config()->remove('send_all_emails_from');
Email::config()->remove('cc_all_emails_to');
Email::config()->remove('bcc_all_emails_to');

$this->origMaxExecutionTime = ini_get('max_execution_time');
}

/**
Expand Down Expand Up @@ -612,6 +619,10 @@ protected function tearDown(): void
restore_error_handler();
$this->oldErrorHandler = null;
}

// Reset max_execution_time in case some code or a unit test changed it,
// either via ini_set() or set_time_limit()
ini_set('max_execution_time', $this->origMaxExecutionTime);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/Security/SudoMode/SudoModeServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public function check(Session $session): bool;
*/
public function activate(Session $session): bool;

/**
* De-register sudo mode permission in the provided session.
*/
public function deactivate(Session $session): void;

/**
* How long the sudo mode activation lasts for in minutes.
*/
Expand Down
7 changes: 3 additions & 4 deletions tests/php/Control/Middleware/AllowedHostsMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
use SilverStripe\Core\Environment;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Control\Middleware\AllowedHostsMiddleware;
use PHPUnit\Framework\Attributes\DataProvider;

class AllowedHostsMiddlewareTest extends SapphireTest
{
protected $usesDatabase = false;

public function provideProcess(): array
public static function provideProcess(): array
{
return [
'cli allow all' => [
Expand Down Expand Up @@ -75,9 +76,7 @@ public function provideProcess(): array
];
}

/**
* @dataProvider provideProcess
*/
#[DataProvider('provideProcess')]
public function testProcess(string|array $allowedHosts, bool $isCli, bool $allowed): void
{
$reflectionEnvironment = new ReflectionClass(Environment::class);
Expand Down
7 changes: 3 additions & 4 deletions tests/php/Core/KernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use SilverStripe\ORM\DB;
use ReflectionObject;
use SilverStripe\Core\Tests\KernelTest\TestFlushable;
use PHPUnit\Framework\Attributes\DataProvider;

class KernelTest extends SapphireTest
{
Expand Down Expand Up @@ -131,7 +132,7 @@ public function testImplementorsAreCalled()
$kernel->boot();
}

public function provideAllowedHostsWarning(): array
public static function provideAllowedHostsWarning(): array
{
$scenarios = [
[
Expand All @@ -158,9 +159,7 @@ public function provideAllowedHostsWarning(): array
return $scenarios;
}

/**
* @dataProvider provideAllowedHostsWarning
*/
#[DataProvider('provideAllowedHostsWarning')]
public function testAllowedHostsWarning(array $config, bool $isCli, bool $shouldLog): void
{
// Prepare mock to check if a warning is logged or not
Expand Down
4 changes: 4 additions & 0 deletions tests/php/Forms/FormFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
use SilverStripe\Forms\SegmentField;
use SilverStripe\Core\Validation\FieldValidation\TimeFieldValidator;
use SilverStripe\Core\Validation\FieldValidation\DatetimeFieldValidator;
use SilverStripe\Forms\SudoModePasswordField;

class FormFieldTest extends SapphireTest
{
Expand Down Expand Up @@ -936,6 +937,9 @@ public function testFieldValidatorConfig(): void
CompositeFieldValidator::class,
],
SingleLookupField::class => [],
SudoModePasswordField::class => [
StringFieldValidator::class,
],
Tab::class => [
CompositeFieldValidator::class,
],
Expand Down

0 comments on commit c502abe

Please sign in to comment.