Skip to content

Commit

Permalink
ENH CMS 6 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Dec 5, 2024
1 parent 9365784 commit 3bde587
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 184 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[![CI](https://github.com/silverstripe/doorman/actions/workflows/ci.yml/badge.svg)](https://github.com/silverstripe/doorman/actions/workflows/ci.yml)

Child process management. Compatible from PHP `5.3` to PHP `7`. Needs no extensions.
Child process management. Needs no extensions.

> `2.x` supports PHP `5.5.9` and upwards. If you need PHP `5.3/4` support, use a `1.x` release.
The is currently only intended for use with Silverstripe CMS.

## Usage

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"description": "Child process management",
"license": "MIT",
"require": {
"php": "^8.1",
"silverstripe/closure": "^3.6"
"php": "^8.3",
"laravel/serializable-closure": "^2"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^11.3",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
Expand Down
21 changes: 3 additions & 18 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="false"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<phpunit colors="true">
<testsuites>
<testsuite>
<directory suffix="Test.php">tests</directory>
<testsuite name="Default">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
2 changes: 1 addition & 1 deletion src/Task/CallbackTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use AsyncPHP\Doorman\Task;
use Closure;
use Opis\Closure\SerializableClosure;
use Laravel\SerializableClosure\SerializableClosure;

class CallbackTask implements Task
{
Expand Down
15 changes: 3 additions & 12 deletions tests/Handler/CallbackHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,23 @@

use AsyncPHP\Doorman\Handler\CallbackHandler;
use AsyncPHP\Doorman\Task\CallbackTask;
use AsyncPHP\Doorman\Tests\Test;
use PHPUnit\Framework\TestCase;

/**
* @covers AsyncPHP\Doorman\Handler\CallbackHandler
*/
class CallbackHandlerTest extends Test
class CallbackHandlerTest extends TestCase
{
/**
* @var CallbackHandler
*/
protected $handler;

/**
* @inheritdoc
*/
public function setUp(): void
{
parent::setUp();

$this->handler = new CallbackHandler();
}

/**
* @test
*/
public function handlesCallbackTasks()
public function testHandlesCallbackTasks()
{
$store = 0;

Expand Down
16 changes: 4 additions & 12 deletions tests/Manager/GroupProcessManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@
use AsyncPHP\Doorman\Manager\GroupProcessManager;
use AsyncPHP\Doorman\Manager\ProcessManager;
use AsyncPHP\Doorman\Task\ProcessCallbackTask;
use AsyncPHP\Doorman\Tests\Test;
use PHPUnit\Framework\TestCase;

/**
* @covers AsyncPHP\Doorman\Manager\GroupProcessManager
*/
class GroupProcessManagerTest extends Test
class GroupProcessManagerTest extends TestCase
{
/**
* @var GroupProcessManager
*/
protected $manager;

/**
* @inheritdoc
*/
public function setUp(): void
{
parent::setUp();
Expand All @@ -29,11 +23,9 @@ public function setUp(): void
);
}

/**
* @test
*/
public function groupsExecuteInPredictableOrder()
public function testGroupsExecuteInPredictableOrder()
{
$this->expectNotToPerformAssertions();
$this->unlink("task1");
$this->unlink("task2");
$this->unlink("task3");
Expand Down
21 changes: 5 additions & 16 deletions tests/Manager/ProcessManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,23 @@
use AsyncPHP\Doorman\Rules\InMemoryRules;
use AsyncPHP\Doorman\Shell\BashShell;
use AsyncPHP\Doorman\Task\ProcessCallbackTask;
use AsyncPHP\Doorman\Tests\Test;
use PHPUnit\Framework\TestCase;

/**
* @covers AsyncPHP\Doorman\Manager\ProcessManager
*/
class ProcessManagerTest extends Test
class ProcessManagerTest extends TestCase
{
/**
* @var ProcessManager
*/
protected $manager;

/**
* @inheritdoc
*/
public function setUp(): void
{
parent::setUp();

$this->manager = new ProcessManager();
}

/**
* @test
*/
public function gettersAndSettersWork()
public function testGettersAndSettersWork()
{
$this->manager->setLogPath(__DIR__);

Expand All @@ -55,11 +46,9 @@ public function gettersAndSettersWork()
$this->assertEquals($rules, $this->manager->getRules());
}

/**
* @test
*/
public function basicRulesAndTasksWork()
public function testBasicRulesAndTasksWork()
{
$this->expectNotToPerformAssertions();
$task1 = new ProcessCallbackTask(function () {
touch(__DIR__ . "/task1.temp");

Expand Down
22 changes: 10 additions & 12 deletions tests/Manager/SynchronousManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,23 @@

use AsyncPHP\Doorman\Manager\SynchronousManager;
use AsyncPHP\Doorman\Task\CallbackTask;
use AsyncPHP\Doorman\Tests\Test;
use PHPUnit\Framework\TestCase;

/**
* @covers AsyncPHP\Doorman\Manager\SynchronousManager
*/
class SynchronousManagerTest extends Test
class SynchronousManagerTest extends TestCase
{
/**
* @var SynchronousManager
*/
protected $manager;

/**
* @inheritdoc
*/
public function setUp(): void
{
parent::setUp();

$this->manager = new SynchronousManager();
}

/**
* @test
*/
public function handlesCallbackTasks()
public function testHandlesCallbackTasks()
{
$task1 = new CallbackTask(function () {
touch(__DIR__ . "/task1.tmp");
Expand All @@ -55,4 +46,11 @@ public function handlesCallbackTasks()
$this->unlink(__DIR__ . "/task1.tmp");
$this->unlink(__DIR__ . "/task2.tmp");
}

private function unlink($file)
{
if (file_exists($file)) {
unlink($file);
}
}
}
20 changes: 6 additions & 14 deletions tests/Profile/InMemoryProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@

use AsyncPHP\Doorman\Profile\InMemoryProfile;
use AsyncPHP\Doorman\Task\ProcessCallbackTask;
use AsyncPHP\Doorman\Tests\Test;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* @covers AsyncPHP\Doorman\Profile\InMemoryProfile
*/
class InMemoryProfileTest extends Test
class InMemoryProfileTest extends TestCase
{
/**
* @var InMemoryProfile
*/
protected $rule;

/**
* @inheritdoc
*/
public function setUp(): void
{
parent::setUp();
Expand All @@ -27,15 +22,12 @@ public function setUp(): void
}

/**
* @test
*
* @dataProvider gettersAndSettersProvider
*
* @param string $getter
* @param string $setter
* @param mixed $value
*/
public function gettersAndSettersWork($getter, $setter, $value)
#[DataProvider('provideGettersAndSetters')]
public function testGettersAndSettersWork($getter, $setter, $value)
{
$this->rule->$setter($value);

Expand All @@ -45,7 +37,7 @@ public function gettersAndSettersWork($getter, $setter, $value)
/**
* @return array
*/
public function gettersAndSettersProvider()
public static function provideGettersAndSetters()
{
$task = new ProcessCallbackTask(function () {
return;
Expand Down
20 changes: 6 additions & 14 deletions tests/Rule/InMemoryRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@
namespace AsyncPHP\Doorman\Tests\Rule;

use AsyncPHP\Doorman\Rule\InMemoryRule;
use AsyncPHP\Doorman\Tests\Test;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* @covers AsyncPHP\Doorman\Rule\InMemoryRule
*/
class InMemoryRuleTest extends Test
class InMemoryRuleTest extends TestCase
{
/**
* @var InMemoryRule
*/
protected $rule;

/**
* @inheritdoc
*/
public function setUp(): void
{
parent::setUp();
Expand All @@ -26,15 +21,12 @@ public function setUp(): void
}

/**
* @test
*
* @dataProvider gettersAndSettersProvider
*
* @param string $getter
* @param string $setter
* @param mixed $value
*/
public function gettersAndSettersWork($getter, $setter, $value)
#[DataProvider('provideGettersAndSetters')]
public function testGettersAndSettersWork($getter, $setter, $value)
{
$this->rule->$setter($value);

Expand All @@ -44,7 +36,7 @@ public function gettersAndSettersWork($getter, $setter, $value)
/**
* @return array
*/
public function gettersAndSettersProvider()
public static function provideGettersAndSetters()
{
return array(
array("getProcesses", "setProcesses", 3),
Expand Down
20 changes: 4 additions & 16 deletions tests/Rules/InMemoryRulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,23 @@
use AsyncPHP\Doorman\Rule\InMemoryRule;
use AsyncPHP\Doorman\Rules\InMemoryRules;
use AsyncPHP\Doorman\Task\ProcessCallbackTask;
use AsyncPHP\Doorman\Tests\Test;
use PHPUnit\Framework\TestCase;

/**
* @covers AsyncPHP\Doorman\Rules\InMemoryRules
*/
class InMemoryRulesTest extends Test
class InMemoryRulesTest extends TestCase
{
/**
* @var InMemoryRules
*/
protected $rules;

/**
* @inheritdoc
*/
public function setUp(): void
{
parent::setUp();

$this->rules = new InMemoryRules();
}

/**
* @test
*/
public function rulesLimitParallelProcesses()
public function testRulesLimitParallelProcesses()
{
$task1 = new ProcessCallbackTask(function () {
return;
Expand Down Expand Up @@ -79,10 +70,7 @@ public function rulesLimitParallelProcesses()
$this->assertTrue($this->rules->canRunTask($task2, $profile2));
}

/**
* @test
*/
public function rulesLimitProcessorAndMemoryUsage()
public function testRulesLimitProcessorAndMemoryUsage()
{
$task1 = new ProcessCallbackTask(function () {
return;
Expand Down
Loading

0 comments on commit 3bde587

Please sign in to comment.