Skip to content

Add PHP 8 support #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
103 changes: 103 additions & 0 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: PHP Test

on:
pull_request:
push:
branches:
- 'master'
- '[0-9]+.x'
- '[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.x'

jobs:
test:
name: '${{ matrix.php-version }} ${{ matrix.dependencies }}, Storage ${{ matrix.storage }}, Coverage ${{ matrix.coverage }}'
runs-on: ubuntu-20.04
env:
COVERAGE: ${{ matrix.coverage }}
STORAGE: ${{ matrix.storage }}

strategy:
fail-fast: false
matrix:
include:
- php-version: '5.6'
dependencies: 'lowest'
storage: doctrine
- php-version: '5.6'
storage: doctrine
- php-version: '5.6'
storage: array

- php-version: '7.0'
dependencies: 'lowest'
storage: doctrine
- php-version: '7.0'
storage: doctrine
- php-version: '7.0'
storage: array

- php-version: '7.1'
dependencies: 'lowest'
storage: doctrine
- php-version: '7.1'
storage: doctrine
- php-version: '7.1'
storage: array

- php-version: '7.2'
dependencies: 'lowest'
storage: doctrine
- php-version: '7.2'
storage: doctrine
- php-version: '7.2'
storage: array

- php-version: '7.3'
storage: doctrine
- php-version: '7.3'
storage: array

- php-version: '7.4'
coverage: '--coverage-clover=coverage.clover'
storage: doctrine
- php-version: '7.4'
storage: array

- php-version: '8.0'
storage: doctrine
- php-version: '8.0'
storage: array

steps:
- name: Checkout project
uses: actions/checkout@v2

- name: Install and configure PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: "pdo, pdo_sqlite"
coverage: "pcov"
tools: 'composer:v2'

- name: Install dependencies with Composer
uses: ramsey/composer-install@v1
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist --no-suggest

- name: Doctrine
if: matrix.storage == 'doctrine'
run: |
tests/app/console doctrine:database:create
tests/app/console doctrine:schema:create

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

- name: Coverage
if: matrix.coverage
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --access-token="230ec5e01daf5bb3e46ea304fb20348b52d80de73463ec08ee9c96fcd1349e35" --format=php-clover coverage.clover
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ composer.phar
/tests/app/cache/
/tests/app/logs/
/tests/app/data/
var/
88 changes: 0 additions & 88 deletions .travis.yml

This file was deleted.

10 changes: 4 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": "^5.6 || ^7.0",
"php": "^5.6 || ^7.0 || ^8.0",
"php-task/php-task": "^1.4",
"symfony/http-kernel": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"symfony/dependency-injection": "^2.8 || ^3.4 || ^4.0 || ^5.0",
Expand All @@ -21,13 +21,12 @@
"doctrine/orm": "^2.5"
},
"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.0",
"sebastian/comparator": "^1.2.3",
"symfony/debug": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"symfony/framework-bundle": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"symfony/framework-bundle": "^2.8.18 || ^3.4 || ^4.0 || ^5.0",
"symfony/finder": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"symfony/yaml": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"doctrine/doctrine-bundle": "^1.5",
"symfony/phpunit-bridge": "^5.2.3",
"doctrine/doctrine-bundle": "^1.5 || ^2.0",
"doctrine/data-fixtures": "^1.1"
},
"autoload": {
Expand All @@ -40,7 +39,6 @@
"Task\\TaskBundle\\Tests\\": "tests"
}
},
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<ini name="error_reporting" value="-1" />
<server name="KERNEL_DIR" value="tests/app" />
<server name="KERNEL_CLASS" value="TestKernel" />
<env name="SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT" value="1"/>
<env name="SYMFONY_PHPUNIT_REMOVE" value="symfony/yaml"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
</php>

<testsuites>
Expand Down
2 changes: 2 additions & 0 deletions src/Command/RunHandlerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
$output->writeln(sprintf('Result: %s', json_encode($result)));
}

return 0;
}
}
7 changes: 4 additions & 3 deletions src/EventListener/RunListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

namespace Task\TaskBundle\EventListener;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\Event as LegacyEvent;
use Symfony\Contracts\EventDispatcher\Event;
use Task\Runner\TaskRunnerInterface;

/**
Expand All @@ -35,9 +36,9 @@ public function __construct(TaskRunnerInterface $taskRunner)
/**
* Run scheduled tasks.
*
* @param Event $event
* @param Event|LegacyEvent $event
*/
public function run(Event $event)
public function run($event)
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure how this did ever work with symfony 5 /cc @wachterjohannes

{
$this->taskRunner->runTasks();
}
Expand Down
28 changes: 14 additions & 14 deletions tests/Functional/Command/DebugTasksCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public function testExecute()
);

$output = $this->commandTester->getDisplay();
$this->assertContains($executions[0]->getUuid(), $output);
$this->assertContains($executions[1]->getUuid(), $output);
$this->assertContains('100000ms', $output);
$this->assertContains('100ms', $output);
$this->assertContains('completed', $output);
$this->assertStringContainsString($executions[0]->getUuid(), $output);
$this->assertStringContainsString($executions[1]->getUuid(), $output);
$this->assertStringContainsString('100000ms', $output);
$this->assertStringContainsString('100ms', $output);
$this->assertStringContainsString('completed', $output);
}

public function testExecutePaginated()
Expand All @@ -76,9 +76,9 @@ public function testExecutePaginated()
);

$output = $this->commandTester->getDisplay();
$this->assertContains($executions[0]->getUuid(), $output);
$this->assertContains($executions[1]->getUuid(), $output);
$this->assertNotContains($executions[2]->getUuid(), $output);
$this->assertStringContainsString($executions[0]->getUuid(), $output);
$this->assertStringContainsString($executions[1]->getUuid(), $output);
$this->assertStringNotContainsString($executions[2]->getUuid(), $output);

$this->commandTester->execute(
[
Expand All @@ -89,9 +89,9 @@ public function testExecutePaginated()
);

$output = $this->commandTester->getDisplay();
$this->assertNotContains($executions[0]->getUuid(), $output);
$this->assertNotContains($executions[1]->getUuid(), $output);
$this->assertContains($executions[2]->getUuid(), $output);
$this->assertStringNotContainsString($executions[0]->getUuid(), $output);
$this->assertStringNotContainsString($executions[1]->getUuid(), $output);
$this->assertStringContainsString($executions[2]->getUuid(), $output);

$this->commandTester->execute(
[
Expand All @@ -102,9 +102,9 @@ public function testExecutePaginated()
);

$output = $this->commandTester->getDisplay();
$this->assertNotContains($executions[0]->getUuid(), $output);
$this->assertNotContains($executions[1]->getUuid(), $output);
$this->assertNotContains($executions[2]->getUuid(), $output);
$this->assertStringNotContainsString($executions[0]->getUuid(), $output);
$this->assertStringNotContainsString($executions[1]->getUuid(), $output);
$this->assertStringNotContainsString($executions[2]->getUuid(), $output);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Command/RunCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testExecute()
);

$execution = $this->taskExecutionRepository->findByUuid($executions[0]->getUuid());
$this->assertEquals(TaskStatus::COMPLETED, $execution->getStatus(), $execution->getException());
$this->assertEquals(TaskStatus::COMPLETED, $execution->getStatus(), $execution->getException() ?: '');
$this->assertEquals(strrev('Test workload 1'), $execution->getResult());
$this->assertGreaterThan(0, $execution->getDuration());
$this->assertGreaterThanOrEqual($execution->getStartTime(), $execution->getEndTime());
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Command/RunHandlerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testExecute()
);

$output = $this->commandTester->getDisplay();
$this->assertContains('No workload.', $output);
$this->assertStringContainsString('No workload.', $output);
}

public function testExecuteWithWorkload()
Expand All @@ -50,7 +50,7 @@ public function testExecuteWithWorkload()
);

$output = $this->commandTester->getDisplay();
$this->assertContains(strrev('Test workload 1'), $output);
$this->assertStringContainsString(strrev('Test workload 1'), $output);
}

public function testExecuteWithWorkloadNoVerbosity()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testExecute()
);

$output = $this->commandTester->getDisplay();
$this->assertContains('System-tasks successfully scheduled', $output);
$this->assertStringContainsString('System-tasks successfully scheduled', $output);

$taskRepository = self::$kernel->getContainer()->get('task.repository.task');
$this->assertNotNull($taskRepository->findBySystemKey('testing'));
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Command/ScheduleTaskCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function testExecuteWithWorkloadAndIntervalAndEndDate()
$this->assertEquals(TestHandler::class, $tasks[0]->getHandlerClass());
$this->assertEquals('Test workload 1', $tasks[0]->getWorkload());
$this->assertEquals('0 * * * *', $tasks[0]->getInterval());
$this->assertEquals($date, $tasks[0]->getLastExecution(), '', 2);
$this->assertEquals($date->format('Y-m-d H:i:s'), $tasks[0]->getLastExecution()->format('Y-m-d H:i:s'));
}

public function testExecuteWithExecutionDate()
Expand Down
6 changes: 3 additions & 3 deletions tests/Functional/Handler/TaskHandlerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Task\TaskBundle\Tests\Functional\Handler;

use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Task\Handler\TaskHandlerNotExistsException;
use Task\TaskBundle\Handler\TaskHandlerFactory;
use Task\TaskBundle\Tests\Functional\TestHandler;

Expand All @@ -38,11 +39,10 @@ public function testCreate()
$this->assertInstanceOf(TestHandler::class, $this->taskHandlerFactory->create(TestHandler::class));
}

/**
* @expectedException \Task\Handler\TaskHandlerNotExistsException
*/
public function testCreateNotExists()
{
$this->expectException(TaskHandlerNotExistsException::class);

$this->taskHandlerFactory->create(\stdClass::class);
}
}
Loading