Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ jobs:
include:
- php-version: '8.0'
dependencies: 'lowest'
phpunit-config: 'phpunit-9.xml.dist'
- php-version: '8.0'
phpunit-config: 'phpunit-9.xml.dist'
- php-version: '8.1'
- php-version: '8.2'
- php-version: '8.3'
coverage: 'true'
- php-version: '8.4'
composer-flags: '--ignore-platform-reqs'
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed as soon as prophecy supports 8.4 officially: https://github.com/phpspec/prophecy/blob/f9e07be0992e7bf1cad210829055b99318df142f/composer.json#L21 but mostly it takes some time.


steps:
- name: Checkout project
Expand All @@ -44,10 +50,10 @@ jobs:
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist --no-suggest
composer-options: --prefer-dist --no-suggest ${{ matrix.composer-flags }}

- name: Execute test
run: vendor/bin/simple-phpunit -c phpunit.xml.dist --coverage-clover=coverage.clover
run: vendor/bin/phpunit --config ${{ matrix.phpunit-config || 'phpunit.xml.dist' }} --coverage-clover=coverage.clover

- name: Coverage
if: ${{ matrix.coverage }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ composer.phar

*.iml
.idea
.phpunit.cache
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
}
],
"require": {
"php": "^8.0 || ^8.1",
"doctrine/collections": "^1.0",
"php": "^8.0",
"doctrine/collections": "^1.0 || ^2.0",
"ramsey/uuid": "^3.1 || ^4.0",
"symfony/event-dispatcher": "^5.4 || ^6.0",
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0",
"dragonmantank/cron-expression": "^1.1 || ^2.0 || ^3.0"
},
"require-dev": {
"mikey179/vfsstream": "^1.6.7",
"psr/log": "^1.0",
"symfony/phpunit-bridge": "^5.4 || ^6.0"
"psr/log": "^1.0 || ^2.0 || ^3.0",
"phpunit/phpunit": "^9.6.5 || ^10 || ^11",
"phpspec/prophecy-phpunit": "^2.0.1",
"phpspec/prophecy": "^1.14"
},
"autoload": {
"psr-4": {
Expand Down
28 changes: 28 additions & 0 deletions phpunit-9.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php">
<php>
<ini name="error_reporting" value="-1" />
<ini name="date.timezone" value="UTC" />
</php>

<testsuites>
<testsuite name="php-task Library Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
26 changes: 12 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php">
<php>
<ini name="error_reporting" value="-1" />
<env name="SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT" value="1"/>
<env name="SYMFONY_PHPUNIT_REMOVE" value="symfony/yaml"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
<ini name="error_reporting" value="-1"/>
<ini name="date.timezone" value="UTC"/>
</php>

<testsuites>
Expand All @@ -18,13 +15,14 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<source>
<include>
<directory>./</directory>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
</exclude>
</whitelist>
</filter>
</include>

<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
</exclude>
</source>
</phpunit>
3 changes: 3 additions & 0 deletions tests/Unit/Builder/TaskBuilderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Task\Tests\Unit\Builder;

use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Task\Builder\TaskBuilderFactory;
use Task\Builder\TaskBuilderInterface;
use Task\Scheduler\TaskSchedulerInterface;
Expand All @@ -22,6 +23,8 @@
*/
class TaskBuilderFactoryTest extends TestCase
{
use ProphecyTrait;

public function testCreate()
{
$task = $this->prophesize(TaskInterface::class);
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Builder/TaskBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Cron\CronExpression;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Task\Builder\TaskBuilder;
use Task\Scheduler\TaskSchedulerInterface;
use Task\TaskInterface;
Expand All @@ -22,6 +23,8 @@
*/
class TaskBuilderTest extends TestCase
{
use ProphecyTrait;

public function testHourly()
{
$task = $this->prophesize(TaskInterface::class);
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Event/TaskEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Task\Tests\Unit\Event;

use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Task\Event\TaskEvent;
use Task\TaskInterface;

Expand All @@ -20,6 +21,8 @@
*/
class TaskEventTest extends TestCase
{
use ProphecyTrait;

public function testGetTask()
{
$task = $this->prophesize(TaskInterface::class);
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Event/TaskExecutionEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Task\Tests\Unit\Event;

use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Task\Event\TaskExecutionEvent;
use Task\Execution\TaskExecutionInterface;
use Task\TaskInterface;
Expand All @@ -21,6 +22,8 @@
*/
class TaskExecutionEventTest extends TestCase
{
use ProphecyTrait;

public function testGetTask()
{
$task = $this->prophesize(TaskInterface::class);
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Event/TaskFailedEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Task\Tests\Unit\Event;

use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Task\Event\TaskFailedEvent;
use Task\TaskInterface;

Expand All @@ -20,6 +21,8 @@
*/
class TaskFailedEventTest extends TestCase
{
use ProphecyTrait;

public function testGetTask()
{
$task = $this->prophesize(TaskInterface::class);
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Execution/TaskExecutionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Task\Tests\Unit\Execution;

use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Task\Execution\TaskExecution;
use Task\Task;
use Task\TaskStatus;
Expand All @@ -21,6 +22,8 @@
*/
class TaskExecutionTest extends TestCase
{
use ProphecyTrait;

public function testUuid()
{
$task = $this->prophesize(Task::class);
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Lock/LockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
namespace Task\Tests\Unit\Lock;

use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Task\Lock\Exception\LockConflictException;
use Task\Lock\Lock;
use Task\Lock\LockInterface;
use Task\Lock\LockStorageInterface;

class LockTest extends TestCase
{
use ProphecyTrait;

/**
* @var LockStorageInterface
*/
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Runner/InsideProcessExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Unit\Runner;

use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Task\Execution\TaskExecutionInterface;
use Task\Executor\FailedException;
use Task\Executor\InsideProcessExecutor;
Expand All @@ -22,6 +23,8 @@

class InsideProcessExecutorTest extends TestCase
{
use ProphecyTrait;

/**
* @var TaskHandlerFactoryInterface
*/
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Runner/PendingExecutionFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Ramsey\Uuid\Uuid;
use Task\Execution\TaskExecutionInterface;
use Task\Handler\TaskHandlerFactoryInterface;
Expand All @@ -24,6 +25,8 @@

class PendingExecutionFinderTest extends TestCase
{
use ProphecyTrait;

const HANDLER = 'AppBundle\\Handler\\TestHandler';

const LOCKING_HANDLER = 'AppBundle\\Handler\\LockingTestHandler';
Expand Down
11 changes: 7 additions & 4 deletions tests/Unit/Runner/TaskRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
use Task\Event\Events;
Expand All @@ -33,6 +34,8 @@
*/
class TaskRunnerTest extends TestCase
{
use ProphecyTrait;

/**
* @var TaskExecutionRepositoryInterface
*/
Expand Down Expand Up @@ -81,8 +84,8 @@ public function testRunTasks()
$this->createTaskExecution($task, new \DateTime(), 'Test 2')->setStatus(TaskStatus::PLANNED),
];

$this->taskExecutionRepository->save($executions[0])->willReturnArgument(0)->shouldBeCalledTimes(2);
$this->taskExecutionRepository->save($executions[1])->willReturnArgument(0)->shouldBeCalledTimes(2);
$this->taskExecutionRepository->save($executions[0])->willReturnArgument(0)->shouldBeCalledTimes(3);
$this->taskExecutionRepository->save($executions[1])->willReturnArgument(0)->shouldBeCalledTimes(3);
Comment on lines +87 to +88
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failing since: #47


$this->executor->execute($executions[0])->willReturn(strrev('Test 1'));
$this->executor->execute($executions[1])->willReturn(strrev('Test 2'));
Expand Down Expand Up @@ -115,8 +118,8 @@ public function testRunTasksFailed()
$this->createTaskExecution($task, new \DateTime(), 'Test 2')->setStatus(TaskStatus::PLANNED),
];

$this->taskExecutionRepository->save($executions[0])->willReturnArgument(0)->shouldBeCalledTimes(2);
$this->taskExecutionRepository->save($executions[1])->willReturnArgument(0)->shouldBeCalledTimes(2);
$this->taskExecutionRepository->save($executions[0])->willReturnArgument(0)->shouldBeCalledTimes(3);
$this->taskExecutionRepository->save($executions[1])->willReturnArgument(0)->shouldBeCalledTimes(3);
Comment on lines +121 to +122
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failing since: #47


$this->executor->execute($executions[0])->willThrow(new \Exception());
$this->executor->execute($executions[1])->willReturn(strrev('Test 2'));
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Scheduler/TaskSchedulerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Cron\CronExpression;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
use Task\Builder\TaskBuilderFactoryInterface;
Expand All @@ -35,6 +36,8 @@
*/
class TaskSchedulerTest extends TestCase
{
use ProphecyTrait;

/**
* @var TaskBuilderFactoryInterface
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Task\Execution\TaskExecution;
use Task\Execution\TaskExecutionInterface;
use Task\Storage\ArrayStorage\ArrayTaskExecutionRepository;
Expand All @@ -25,6 +26,8 @@
*/
class ArrayTaskExecutionRepositoryTest extends TestCase
{
use ProphecyTrait;

public function testSave()
{
$taskExecutionCollection = $this->prophesize(Collection::class);
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Storage/ArrayStorage/ArrayTaskRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Task\Storage\ArrayStorage\ArrayTaskRepository;
use Task\Task;
use Task\TaskInterface;
Expand All @@ -24,6 +25,8 @@
*/
class ArrayTaskRepositoryTest extends TestCase
{
use ProphecyTrait;

public function testFindByUuid()
{
$tasks = [
Expand Down