Skip to content

Commit

Permalink
update system to php7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sveneld committed May 25, 2024
1 parent 77246c1 commit 8341a86
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [5.6, 7.0, 7.1]
php-version: [7.4, 8.0]
fail-fast: false

steps:
Expand Down
15 changes: 3 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
FROM php:5.6-apache
FROM php:7.4-apache

RUN docker-php-ext-install mysqli pdo pdo_mysql
RUN a2enmod rewrite

# Because we using and old php version 5.6 some packages are not available and we should update source list or install directly
RUN sed -i '/security.debian.org/d' /etc/apt/sources.list \
&& sed -i '/deb.debian.org/d' /etc/apt/sources.list

RUN echo "deb http://archive.debian.org/debian/ stretch main" > /etc/apt/sources.list \
&& echo "deb http://archive.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list

RUN apt-get update && apt-get install -y zlib1g-dev libicu-dev g++ wget git zip

RUN wget --no-check-certificate https://pecl.php.net/get/xdebug-2.5.5.tgz \
&& pecl install --offline ./xdebug-2.5.5.tgz \

RUN pecl install xdebug-3.1.6
RUN docker-php-ext-configure intl
RUN docker-php-ext-install intl

RUN apt-get install -y gettext
RUN docker-php-ext-install gettext

COPY --from=composer:1 /usr/bin/composer /usr/local/bin/composer
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer

RUN cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini
2 changes: 1 addition & 1 deletion common.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function checktopofstack($standid)
}
if (count($currentbikes)) {
// find last returned bike at stand
$result = $db->query("SELECT bikeNum FROM history WHERE action IN ('RETURN','FORCERETURN') AND parameter='$standid' AND bikeNum IN (" . implode($currentbikes, ',') . ') ORDER BY time DESC LIMIT 1');
$result = $db->query("SELECT bikeNum FROM history WHERE action IN ('RETURN','FORCERETURN') AND parameter='$standid' AND bikeNum IN (" . implode(',', $currentbikes) . ') ORDER BY time DESC LIMIT 1');
if ($result->num_rows) {
$row = $result->fetch_assoc();
return $row['bikeNum'];
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
},
"require": {
"php": ">=5.6.0",
"php": "^7.4",
"phpmailer/phpmailer": "^5.2.9",
"tecnickcom/tcpdf": "^6.2.6",
"ext-json": "*",
Expand All @@ -30,8 +30,8 @@
"monolog/monolog": "^1.27"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.0",
"phpunit/phpunit": "^5.7",
"php-mock/php-mock-phpunit": "^1.1"
"squizlabs/php_codesniffer": "^3.10|^4.0",
"phpunit/phpunit": "^9.5",
"php-mock/php-mock-phpunit": "^2.3"
}
}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
links:
- web
db:
image: mysql:5
image: mariadb:10.3
ports:
- 3306:3306
environment:
Expand Down
15 changes: 5 additions & 10 deletions docker-data/php/xdebug.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
[xdebug]
zend_extension = "xdebug.so"
xdebug.remote_enable = 1
;xdebug.remote_log = /var/www/html/xdebug.log ;for debug if can not establish connect
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal
xdebug.remote_port = 9000
xdebug.remote_autostart = on
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_dir = /var/www/html
zend_extension = xdebug.so
xdebug.mode = debug,develop
xdebug.client_host = host.docker.internal
xdebug.client_port = 9003
xdebug.output_dir = /var/www/html
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
<description>The coding standard for Open Source Bike Sharing.</description>

<config name="php_version" value="506000"/>
<config name="php_version" value="704000"/>
<file>src</file>
<file>tests</file>

Expand Down
5 changes: 0 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
stopOnWarning="true"
stopOnFailure="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<filter>
<whitelist>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
Expand Down
5 changes: 1 addition & 4 deletions src/Authentication/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

class Auth
{
/**
* @phpcs:disable PSR12.Properties.ConstantVisibility
*/
const SESSION_EXPIRATION = 86400 * 14; // 14 days to keep user logged in
private const SESSION_EXPIRATION = 86400 * 14; // 14 days to keep user logged in

/**
* @var DbInterface
Expand Down
6 changes: 1 addition & 5 deletions src/Rent/AbstractRentSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
*/
abstract class AbstractRentSystem implements RentSystemInterface
{
/**
* @phpcs:disable PSR12.Properties.ConstantVisibility
* @private
*/
const ERROR = 1;
private const ERROR = 1;
/**
* @var DbInterface
*/
Expand Down
6 changes: 1 addition & 5 deletions src/SmsConnector/SmsGateway/SmsGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

class SmsGateway
{
/**
* @phpcs:disable PSR12.Properties.ConstantVisibility
*/
const BASE_URL = "https://smsgateway.me";

private const BASE_URL = "https://smsgateway.me";

public function __construct($email, $password)
{
Expand Down
30 changes: 16 additions & 14 deletions tests/Authentication/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,32 @@
use BikeShare\Db\DbInterface;
use BikeShare\Db\DbResultInterface;
use phpmock\phpunit\PHPMock;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class AuthTest extends TestCase
{
use PHPMock;

private const SESSION_EXPIRATION = 86400 * 14;
/**
* @phpcs:disable PSR12.Properties.ConstantVisibility
*/
const SESSION_EXPIRATION = 86400 * 14;
/**
* @var DbInterface|\PHPUnit_Framework_MockObject_MockObject
* @var DbInterface|MockObject
*/
private $db;
/**
* @var Auth
*/
private $auth;

public function setUp()
public function setUp(): void
{
$this->db = $this->createMock(DbInterface::class);
$this->auth = new Auth(
$this->db
);
}

protected function tearDown()
protected function tearDown(): void
{
unset(
$this->db,
Expand All @@ -43,7 +41,7 @@ protected function tearDown()


/**
* @dataProvider testGetUserIdDataProvider
* @dataProvider getUserIdDataProvider
*/
public function testGetUserId(
$cookieValue = null,
Expand All @@ -59,7 +57,7 @@ public function testGetUserId(
$this->assertEquals($expectedUserId, $this->auth->getUserId());
}

public function testGetUserIdDataProvider()
public function getUserIdDataProvider()
{

yield 'no cookie' => [
Expand All @@ -85,7 +83,7 @@ public function testGetUserIdDataProvider()
}

/**
* @dataProvider testGetSessionIdDataProvider
* @dataProvider getSessionIdDataProvider
*/
public function testGetSessionId(
$cookieValue = null,
Expand All @@ -101,7 +99,7 @@ public function testGetSessionId(
$this->assertEquals($expectedSessionId, $this->auth->getSessionId());
}

public function testGetSessionIdDataProvider()
public function getSessionIdDataProvider()
{

yield 'no cookie' => [
Expand Down Expand Up @@ -187,9 +185,9 @@ public function testLogin()
}

/**
* @dataProvider testisLoggedInDataProvider
* @dataProvider isLoggedInDataProvider
*/
public function testisLoggedIn(
public function testIsLoggedIn(
$userId,
$sessionId,
$escapeCallParams,
Expand All @@ -199,9 +197,13 @@ public function testisLoggedIn(
) {
if ($userId) {
$_COOKIE["loguserid"] = $userId;
} else {
$_COOKIE["loguserid"] = null;
}
if ($sessionId) {
$_COOKIE["logsession"] = $sessionId;
} else {
$_COOKIE["logsession"] = null;
}

$this->getFunctionMock('BikeShare\Authentication', 'time')
Expand All @@ -226,7 +228,7 @@ public function testisLoggedIn(
$this->assertEquals($expectedResult, $this->auth->isLoggedIn());
}

public function testisLoggedInDataProvider()
public function isLoggedInDataProvider()
{
yield 'no user id' => [
'userId' => 0,
Expand Down
2 changes: 1 addition & 1 deletion tests/Credit/CodeGenerator/CodeGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testGenerate()
$this->assertCount($count, $codes);
foreach ($codes as $code) {
$this->assertEquals($length, strlen($code));
$this->assertRegExp('/^[' . $this->acceptableChars . ']{' . $length . '}$/', $code);
$this->assertMatchesRegularExpression('/^[' . $this->acceptableChars . ']{' . $length . '}$/', $code);
}
}
}
5 changes: 3 additions & 2 deletions tests/Db/MysqliDbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

use BikeShare\Db\DbResultInterface;
use BikeShare\Db\MysqliDb;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;

class MysqliDbTest extends TestCase
{
/**
* @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
* @var LoggerInterface|MockObject
*/
private $logger;

public function setUp()
public function setUp(): void
{
$this->logger = $this->createMock(LoggerInterface::class);
$db = new MysqliDb('server', 'user', 'password', 'dbname', $this->logger, true);
Expand Down
5 changes: 3 additions & 2 deletions tests/Mail/PHPMailerSenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
namespace Test\BikeShare\Mail;

use BikeShare\Mail\PHPMailerMailSender;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class PHPMailerSenderTest extends TestCase
{
/**
* @var \PHPMailer|\PHPUnit_Framework_MockObject_MockObject
* @var \PHPMailer|MockObject
*/
private $mailer;
/**
* @var PHPMailerMailSender
*/
private $mailSender;

protected function setUp()
protected function setUp(): void
{
$email = [
'smtp' => 'smtp',
Expand Down
4 changes: 2 additions & 2 deletions tests/Sms/SmsSenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

class SmsSenderTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
$this->smsConnector = $this->createMock(SmsConnectorInterface::class);
$this->db = $this->createMock(DbInterface::class);
$this->smsSender = new SmsSender($this->smsConnector, $this->db);
}

protected function tearDown()
protected function tearDown(): void
{
unset(
$this->smsConnector,
Expand Down
4 changes: 2 additions & 2 deletions tests/SmsConnector/EuroSmsConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EuroSmsConnectorTest extends TestCase
*/
private $smsConnector;

protected function setUp()
protected function setUp(): void
{
$this->smsConnector = new EuroSmsConnector(
[
Expand All @@ -27,7 +27,7 @@ protected function setUp()
);
}

protected function tearDown()
protected function tearDown(): void
{
unset($this->smsConnector);
}
Expand Down

0 comments on commit 8341a86

Please sign in to comment.