Skip to content

Commit

Permalink
Merge pull request bernardphp#410 from bernardphp/upgrade-php
Browse files Browse the repository at this point in the history
Upgrade required PHP version to 7.4
  • Loading branch information
sagikazarmark authored Dec 29, 2020
2 parents a68cf65 + 5e25d64 commit 1f15a9f
Show file tree
Hide file tree
Showing 37 changed files with 73 additions and 77 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '5.6'
php-version: '7.4'
coverage: none
extensions: mbstring, intl
tools: composer:v2
Expand All @@ -38,7 +38,7 @@ jobs:
strategy:
max-parallel: 10
matrix:
php: ['5.6', '7.2', '7.3', '7.4']
php: ['7.4', '8.0']

steps:
- name: Set up PHP
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.php_cs
.php_cs.cache
.phpunit.result.cache
/_build/
/build/
/composer.lock
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</p>

[![Latest Version](https://img.shields.io/github/release/bernardphp/bernard.svg?style=flat-square)](https://github.com/bernardphp/bernard/releases)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.4-8892BF.svg?style=flat-square)](https://php.net/)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/bernardphp/bernard/CI?style=flat-square)](https://github.com/bernardphp/bernard/actions?query=workflow%3ACI)
[![Total Downloads](https://img.shields.io/packagist/dt/bernard/bernard.svg?style=flat-square)](https://packagist.org/packages/bernard/bernard)

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"homepage": "https://github.com/bernardphp/bernard",
"type": "library",
"require": {
"php": "^5.6 || ^7.0",
"php": ">=7.4",
"beberlei/assert": "^2.1 || ^3.0",
"bernard/normalt": "^1.0",
"symfony/event-dispatcher": "^3.0 || ^4.0"
Expand All @@ -16,11 +16,11 @@
"doctrine/dbal": "^2.5",
"doctrine/instantiator": "^1.0.5",
"iron-io/iron_mq": "^4.0",
"leanphp/phpspec-code-coverage": "^3.0 || ^4.0",
"friends-of-phpspec/phpspec-code-coverage": "^6.0",
"pda/pheanstalk": "^3.0",
"php-amqplib/php-amqplib": "^2.5",
"phpspec/phpspec": "^3.0 || ^4.0",
"phpunit/phpunit": "^5.7 || ^6.0 || ^7.0",
"phpspec/phpspec": "^7.0",
"phpunit/phpunit": "^9.5",
"predis/predis": "^1.0",
"psr/container": "^1.0",
"psr/log": "^1.0",
Expand Down
2 changes: 1 addition & 1 deletion phpspec.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ suites:
psr4_prefix: Bernard
formatter.name: pretty
extensions:
LeanPHP\PhpSpec\CodeCoverage\CodeCoverageExtension:
FriendsOfPhpSpec\PhpSpec\CodeCoverage\CodeCoverageExtension:
format:
- clover
output:
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/ConsumeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ConsumeCommandTest extends \PHPUnit\Framework\TestCase
{
public function setUp()
public function setUp(): void
{
$this->queues = new InMemoryFactory();
$this->consumer = $this->getMockBuilder('Bernard\Consumer')
Expand Down
7 changes: 3 additions & 4 deletions tests/Command/ProduceCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ProduceCommandTest extends \PHPUnit\Framework\TestCase
{
protected $producer;

public function setUp()
public function setUp(): void
{
$this->producer = $this->getMockBuilder('Bernard\Producer')
->disableOriginalConstructor()->getMock();
Expand All @@ -29,11 +29,10 @@ public function testProduceMessageWithNoArguments()
]);
}

/**
* @expectedException \RuntimeException
*/
public function testInvalidJsonThrowsException()
{
$this->expectException(\RuntimeException::class);

$command = new ProduceCommand($this->producer);

$tester = new CommandTester($command);
Expand Down
10 changes: 5 additions & 5 deletions tests/ConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ConsumerTest extends \PHPUnit\Framework\TestCase
*/
private $consumer;

public function setUp()
public function setUp(): void
{
$this->router = $this->prophesize(Router::class);

Expand Down Expand Up @@ -193,11 +193,10 @@ public function testStopAfterLastMessage()
$this->assertFalse($this->consumer->tick($queue, ['stop-when-empty' => true]));
}

/**
* @expectedException \Bernard\Exception\ReceiverNotFoundException
*/
public function testStopOnError()
{
$this->expectException(\Bernard\Exception\ReceiverNotFoundException::class);

$envelope = new Envelope($message = new PlainMessage('DifferentMessageKey'));

$queue = new InMemoryQueue('send-newsletter');
Expand Down Expand Up @@ -230,10 +229,11 @@ public function testEnvelopeWillBeInvoked()

/**
* @requires PHP 7.0
* @expectedException \TypeError
*/
public function testWillRejectDispatchOnThrowableError()
{
$this->expectException(\TypeError::class);

$envelope = new Envelope($message = new PlainMessage('ImportReport'));

$queue = new InMemoryQueue('send-newsletter');
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/Amqp/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class DriverTest extends TestCase

const EXCHANGE_NAME = 'foo-exchange';

protected function setUp()
protected function setUp(): void
{
$this->phpAmqpChannel = $this->getMockBuilder('\PhpAmqpLib\Channel\AMQPChannel')
->setMethods([
Expand Down
6 changes: 3 additions & 3 deletions tests/Driver/AppEngine/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ class DriverTest extends \PHPUnit\Framework\TestCase
/** @var Driver */
private $driver;

public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
// Very ugly hack! But AppEngine SDK isn't available outside appengine
// environment.
class_alias('Bernard\Tests\Fixtures\PushTask', 'google\appengine\api\taskqueue\PushTask');
}

public function setUp()
public function setUp(): void
{
$this->driver = new Driver([
'send-newsletter' => '/url_endpoint',
]);
}

public function tearDown()
public function tearDown(): void
{
PushTask::$messages = [];
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Driver/Doctrine/AbstractDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class AbstractDriverTest extends \PHPUnit\Framework\TestCase
*/
protected $driver;

public function setUp()
public function setUp(): void
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('Doctrine have incompatibility issues with HHVM.');
Expand All @@ -33,7 +33,7 @@ public function setUp()
$this->driver = new Driver($this->connection);
}

protected function tearDown()
protected function tearDown(): void
{
if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
$this->connection->exec('SET FOREIGN_KEY_CHECKS = 0');
Expand Down Expand Up @@ -117,7 +117,7 @@ public function testItIsAQueue()
self::assertContains($message, $messages);

// No messages when all are invisible
$this->assertInternalType('null', $this->driver->popMessage('import-users', 0.0001));
$this->assertNull($this->driver->popMessage('import-users', 0.0001));
}

public function testCountMessages()
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/Doctrine/Command/AbstractCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AbstractCommandTest extends \PHPUnit\Framework\TestCase
{
protected $command;

public function setUp()
public function setUp(): void
{
$connection = $this->getMockBuilder('Doctrine\\DBAL\\Connection')
->disableOriginalConstructor()->getMock();
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/Doctrine/Command/BaseCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class BaseCommandTest extends \PHPUnit\Framework\TestCase

protected $sync;

public function setUp()
public function setUp(): void
{
$connection = $this->getMockBuilder('Doctrine\\DBAL\\Connection')
->disableOriginalConstructor()->getMock();
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/Doctrine/ConnectionListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class ConnectionListenerTest extends \PHPUnit\Framework\TestCase
{
protected function setUp()
protected function setUp(): void
{
$this->connection = $this->prophesize('Doctrine\DBAL\Connection');

Expand Down
6 changes: 3 additions & 3 deletions tests/Driver/FlatFile/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DriverTest extends \PHPUnit\Framework\TestCase
*/
private $driver;

protected function setUp()
protected function setUp(): void
{
$this->baseDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'bernard-flat';

Expand All @@ -25,7 +25,7 @@ protected function setUp()
$this->driver = new Driver($this->baseDir);
}

protected function tearDown()
protected function tearDown(): void
{
if ((strtoupper(substr(\PHP_OS, 0, 3)) === 'WIN')) {
system('rd /s /q '.$this->baseDir);
Expand Down Expand Up @@ -96,7 +96,7 @@ public function testPopMessageWhichPushedAfterTheInitialCollect()
{
$this->driver->createQueue('send-newsletter');

$pid = pcntl_fork();
$pid = \pcntl_fork();

if ($pid === -1) {
$this->fail('Failed to fork the currently running process: ' . pcntl_strerror(pcntl_get_last_error()));
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/InMemory/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class DriverTest extends \PHPUnit\Framework\TestCase
*/
private $driver;

protected function setUp()
protected function setUp(): void
{
$this->driver = new Driver();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/IronMQ/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DriverTest extends \PHPUnit\Framework\TestCase
/** @var Driver */
private $driver;

public function setUp()
public function setUp(): void
{
$this->ironmq = $this->getMockBuilder(IronMQ::class)
->setMethods([
Expand Down
4 changes: 2 additions & 2 deletions tests/Driver/MongoDB/DriverFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DriverFunctionalTest extends \PHPUnit\Framework\TestCase
/** @var Driver */
private $driver;

public function setUp()
public function setUp(): void
{
if (!class_exists('MongoClient')) {
$this->markTestSkipped('MongoDB extension is not available.');
Expand All @@ -43,7 +43,7 @@ public function setUp()
$this->driver = new Driver($this->queues, $this->messages);
}

public function tearDown()
public function tearDown(): void
{
if (!$this->messages instanceof MongoCollection) {
return;
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/MongoDB/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DriverTest extends \PHPUnit\Framework\TestCase
/** @var Driver */
private $driver;

public function setUp()
public function setUp(): void
{
if (!class_exists('MongoCollection')) {
$this->markTestSkipped('MongoDB extension is not available.');
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/Pheanstalk/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DriverTest extends \PHPUnit\Framework\TestCase
/** @var Driver */
private $driver;

public function setUp()
public function setUp(): void
{
$this->pheanstalk = $this->getMockBuilder(Pheanstalk::class)
->setMethods([
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/PhpRedis/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class DriverTest extends \PHPUnit\Framework\TestCase
{
public function setUp()
public function setUp(): void
{
if (!extension_loaded('redis')) {
$this->markTestSkipped('"redis" extension is not loaded.');
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/Predis/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class DriverTest extends \Bernard\Tests\Driver\PhpRedis\DriverTest
{
public function setUp()
public function setUp(): void
{
// Because predis uses __call all methods that needs mocking must be
// explicitly defined.
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/PrefetchMessageCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public function testPushesAndPop()
$cache->push('my-queue', ['message1', 'r0']);

$this->assertEquals(['message1', 'r0'], $cache->pop('my-queue'));
$this->assertInternalType('null', $cache->pop('my-queue'));
$this->assertNull($cache->pop('my-queue'));
}
}
9 changes: 4 additions & 5 deletions tests/Driver/Sqs/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DriverTest extends \PHPUnit\Framework\TestCase
/** @var Driver */
private $driver;

public function setUp()
public function setUp(): void
{
$this->sqs = $this->getMockBuilder(SqsClient::class)
->disableOriginalConstructor()
Expand Down Expand Up @@ -123,12 +123,11 @@ public function testItCountsNumberOfMessagesInQueue()
$this->assertEquals(4, $this->driver->countMessages(self::DUMMY_QUEUE_NAME));
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Queue "unknown" cannot be resolved to an url.
*/
public function testUnresolveableQueueNameThrowsException()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Queue "unknown" cannot be resolved to an url.');

$this->driver->popMessage('unknown');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Event/EnvelopeEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class EnvelopeEventTest extends \PHPUnit\Framework\TestCase
{
public function setUp()
public function setUp(): void
{
$message = $this->getMockBuilder(Message::class)->disableOriginalConstructor()
->getMock();
Expand Down
2 changes: 1 addition & 1 deletion tests/Event/RejectEnvelopeEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RejectEnvelopeEventTest extends \PHPUnit\Framework\TestCase
*/
private $queue;

public function setUp()
public function setUp(): void
{
$message = $this->getMockBuilder(Message::class)->disableOriginalConstructor()
->getMock();
Expand Down
4 changes: 2 additions & 2 deletions tests/EventListener/ErrorLogSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ErrorLogSubscriberTest extends \PHPUnit\Framework\TestCase
private $iniErrorLog;
private $errorLogFile;

public function setUp()
public function setUp(): void
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped("HHVM does not support `ini_set('error_log', '/path/to/log')`");
Expand All @@ -35,7 +35,7 @@ public function setUp()
ini_set('error_log', $this->errorLogFile);
}

public function tearDown()
public function tearDown(): void
{
ini_set('error_log', $this->iniErrorLog);
unlink($this->errorLogFile);
Expand Down
2 changes: 1 addition & 1 deletion tests/EventListener/FailureSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class FailureSubscriberTest extends \PHPUnit\Framework\TestCase
private $producer;
private $subscriber;

public function setUp()
public function setUp(): void
{
$this->producer = $this->getMockBuilder('Bernard\Producer')->disableOriginalConstructor()->getMock();
$this->subscriber = new FailureSubscriber($this->producer, 'failures');
Expand Down
Loading

0 comments on commit 1f15a9f

Please sign in to comment.